add sanity check functions
diff --git a/planetstack/hpc_observer/steps/sync_originserver.py b/planetstack/hpc_observer/steps/sync_originserver.py
index 4f0ba4c..b93f8dd 100644
--- a/planetstack/hpc_observer/steps/sync_originserver.py
+++ b/planetstack/hpc_observer/steps/sync_originserver.py
@@ -24,6 +24,23 @@
         SyncStep.__init__(self, **args)
         HpcLibrary.__init__(self)
 
+    def fetch_pending(self, deleted):
+        self.sanity_check()
+
+        return SyncStep.fetch_pending(self, deleted)
+
+    def sanity_check(self):
+        # sanity check to make sure our PS objects have CMI objects behind them
+        all_ors_ids = [x["origin_server_id"] for x in self.client.onev.ListAll("OriginServer")]
+        for ors in OriginServer.objects.all():
+            if (ors.origin_server_id is not None) and (ors.origin_server_id not in all_ors_ids):
+                # we have an origin server ID, but it doesn't exist in the CMI
+                # something went wrong
+                # start over
+                logger.info("origin server %s was not found on CMI" % ors.origin_server_id)
+                ors.origin_server_id=None
+                ors.save()
+
     def sync_record(self, ors):
         logger.info("sync'ing origin server %s" % str(ors))
 
@@ -45,7 +62,7 @@
             id = self.client.onev.Create("OriginServer", ors_dict)
             ors.origin_server_id = id
         else:
-            self.client.onev.Update("OriginServer", ors.origin_server_id, ors_dict)
+            id = self.client.onev.Update("OriginServer", ors.origin_server_id, ors_dict)
 
         # ... something breaks (analytics) if the URL starts with http://, so we
         # change it in cob after we added it via onev.