Commit a5c3cf29 authored by Christos Stavrakakis's avatar Christos Stavrakakis

cyclades: Fix bug in reconciliation

VMs at building error that do not exist in Ganeti must not be reported
as stale. The VM is stale only if the user has asked to destroy the VM,
and so the action is DESTROY.
parent a1bb5673
......@@ -146,6 +146,11 @@ class BackendReconciler(object):
self.reconcile_building_server(db_server)
elif build_status != "RUNNING":
stale.append(server_id)
elif (db_server.operstate == "ERROR" and
db_server.action != "DESTROY"):
# Servers at building ERROR are stale only if the user has
# asked to destroy them.
pass
else:
stale.append(server_id)
......
......@@ -89,10 +89,27 @@ class ServerReconciliationTest(TestCase):
vm1 = mfactory.VirtualMachineFactory(backend=self.backend,
deleted=False,
operstate="ERROR")
with mocked_quotaholder():
self.reconciler.reconcile()
vm1 = VirtualMachine.objects.get(id=vm1.id)
self.assertTrue(vm1.deleted)
self.assertFalse(vm1.deleted)
vm2 = mfactory.VirtualMachineFactory(backend=self.backend,
deleted=False,
action="DESTROY",
operstate="ERROR")
with mocked_quotaholder():
self.reconciler.reconcile()
vm2 = VirtualMachine.objects.get(id=vm2.id)
self.assertTrue(vm2.deleted)
vm3 = mfactory.VirtualMachineFactory(backend=self.backend,
deleted=False,
action="DESTROY",
operstate="ACTIVE")
with mocked_quotaholder():
self.reconciler.reconcile()
vm3 = VirtualMachine.objects.get(id=vm3.id)
self.assertTrue(vm3.deleted)
def test_orphan_server(self, mrapi):
cmrapi = self.reconciler.client
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment