Fail reconcile if no region found
This commit is contained in:
@@ -120,6 +120,10 @@ class Reconciler(object):
|
|||||||
reconciled = False
|
reconciled = False
|
||||||
launch = models.InstanceUsage.objects.get(id=launched_id)
|
launch = models.InstanceUsage.objects.get(id=launched_id)
|
||||||
region = self._region_for_usage(launch)
|
region = self._region_for_usage(launch)
|
||||||
|
|
||||||
|
if not region:
|
||||||
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
instance = self.client.get_instance(region, launch.instance)
|
instance = self.client.get_instance(region, launch.instance)
|
||||||
if instance['deleted'] and instance['deleted_at'] is not None:
|
if instance['deleted'] and instance['deleted_at'] is not None:
|
||||||
@@ -140,6 +144,10 @@ class Reconciler(object):
|
|||||||
def failed_validation(self, exists):
|
def failed_validation(self, exists):
|
||||||
reconciled = False
|
reconciled = False
|
||||||
region = self._region_for_usage(exists)
|
region = self._region_for_usage(exists)
|
||||||
|
|
||||||
|
if not region:
|
||||||
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
instance = self.client.get_instance(region, exists.instance,
|
instance = self.client.get_instance(region, exists.instance,
|
||||||
get_metadata=True)
|
get_metadata=True)
|
||||||
|
@@ -229,6 +229,21 @@ class ReconcilerTestCase(StacktachBaseTestCase):
|
|||||||
self.assertFalse(result)
|
self.assertFalse(result)
|
||||||
self.mox.VerifyAll()
|
self.mox.VerifyAll()
|
||||||
|
|
||||||
|
def test_missing_exists_for_instance_region_not_found(self):
|
||||||
|
launch_id = 1
|
||||||
|
beginning_d = utils.decimal_utc()
|
||||||
|
launch = self.mox.CreateMockAnything()
|
||||||
|
launch.instance = INSTANCE_ID_1
|
||||||
|
launch.launched_at = beginning_d - (60*60)
|
||||||
|
launch.instance_type_id = 1
|
||||||
|
models.InstanceUsage.objects.get(id=launch_id).AndReturn(launch)
|
||||||
|
launch.deployment().AndReturn(None)
|
||||||
|
self.mox.ReplayAll()
|
||||||
|
result = self.reconciler.missing_exists_for_instance(launch_id,
|
||||||
|
beginning_d)
|
||||||
|
self.assertFalse(result)
|
||||||
|
self.mox.VerifyAll()
|
||||||
|
|
||||||
def test_failed_validation(self):
|
def test_failed_validation(self):
|
||||||
exists = self._fake_usage(is_exists=True, mock_deployment=True)
|
exists = self._fake_usage(is_exists=True, mock_deployment=True)
|
||||||
launched_at = exists.launched_at
|
launched_at = exists.launched_at
|
||||||
@@ -344,6 +359,21 @@ class ReconcilerTestCase(StacktachBaseTestCase):
|
|||||||
self.assertFalse(result)
|
self.assertFalse(result)
|
||||||
self.mox.VerifyAll()
|
self.mox.VerifyAll()
|
||||||
|
|
||||||
|
def test_failed_validation_region_not_found(self):
|
||||||
|
beginning_d = utils.decimal_utc()
|
||||||
|
exists = self.mox.CreateMockAnything()
|
||||||
|
exists.instance = INSTANCE_ID_1
|
||||||
|
launched_at = beginning_d - (60*60)
|
||||||
|
exists.launched_at = launched_at
|
||||||
|
exists.instance_type_id = 1
|
||||||
|
exists.deleted_at = None
|
||||||
|
exists.deployment().AndReturn(None)
|
||||||
|
ex = exceptions.NotFound()
|
||||||
|
self.mox.ReplayAll()
|
||||||
|
result = self.reconciler.failed_validation(exists)
|
||||||
|
self.assertFalse(result)
|
||||||
|
self.mox.VerifyAll()
|
||||||
|
|
||||||
def test_fields_match(self):
|
def test_fields_match(self):
|
||||||
exists = self._fake_usage(is_exists=True)
|
exists = self._fake_usage(is_exists=True)
|
||||||
kwargs = {'launched_at': exists.launched_at}
|
kwargs = {'launched_at': exists.launched_at}
|
||||||
|
Reference in New Issue
Block a user