Add cluster record to db right after API request
This commit changes the incorrect behavior of cluster create workflow. Now db record with status CREATE_IN_PROGRESS is created right after related API request. Change-Id: I11692c4126823d49672ba5172fa45774bf0ce544 Closes-bug: #1640729
This commit is contained in:
parent
b38039f3b1
commit
9cbb142c2e
|
@ -47,6 +47,10 @@ class Handler(object):
|
|||
|
||||
osc = clients.OpenStackClients(context)
|
||||
|
||||
cluster.status = fields.ClusterStatus.CREATE_IN_PROGRESS
|
||||
cluster.status_reason = None
|
||||
cluster.create()
|
||||
|
||||
try:
|
||||
# Create trustee/trust and set them to cluster
|
||||
trust_manager.create_trustee_and_trust(osc, cluster)
|
||||
|
@ -60,12 +64,12 @@ class Handler(object):
|
|||
cluster)
|
||||
# Create cluster
|
||||
cluster_driver.create_cluster(context, cluster, create_timeout)
|
||||
cluster.status = fields.ClusterStatus.CREATE_IN_PROGRESS
|
||||
cluster.status_reason = None
|
||||
cluster.save()
|
||||
|
||||
except Exception as e:
|
||||
cluster.status = fields.ClusterStatus.CREATE_FAILED
|
||||
cluster.status_reason = six.text_type(e)
|
||||
cluster.create()
|
||||
cluster.save()
|
||||
conductor_utils.notify_about_cluster_operation(
|
||||
context, taxonomy.ACTION_CREATE, taxonomy.OUTCOME_FAILURE)
|
||||
|
||||
|
@ -75,7 +79,6 @@ class Handler(object):
|
|||
raise e
|
||||
raise
|
||||
|
||||
cluster.create()
|
||||
return cluster
|
||||
|
||||
def cluster_update(self, context, cluster, rollback=False):
|
||||
|
|
|
@ -396,6 +396,7 @@ class TestHandler(db_base.DbTestCase):
|
|||
mock_heat_poller_class):
|
||||
timeout = 15
|
||||
self.cluster.cluster_template_id = self.cluster_template.uuid
|
||||
self.cluster.name = 'cluster1'
|
||||
cluster_name = self.cluster.name
|
||||
mock_poller = mock.MagicMock()
|
||||
mock_poller.poll_and_check.return_value = loopingcall.LoopingCallDone()
|
||||
|
|
Loading…
Reference in New Issue