diff options
author | Zane Bitter <zbitter@redhat.com> | 2018-07-20 17:30:57 -0400 |
---|---|---|
committer | Zane Bitter <zbitter@redhat.com> | 2018-08-06 09:25:18 -0400 |
commit | 8ca06cfeafc94e739947cf89affa4db57b6bf3c9 (patch) | |
tree | 18c8ace09afb8a39e9531e5ebe72d2b0ad97776f | |
parent | 99cbff3803096741bae5b790744a2eb52057cc0c (diff) | |
download | heat-8ca06cfeafc94e739947cf89affa4db57b6bf3c9.tar.gz |
Store resources convergence-style in stack check/suspend/resume
If there are resources in a template that don't exist in the database at
the time of a stack check (or suspend or resume) operation, running the
stack check will cause them to be stored in the database. Since these
operations have not been converted to convergence (story 1727142), they do
not set the current_template_id as a convergence update would. If this
occurs then the stack will be unrecoverable.
To avoid this, when convergence is enabled store any missing resources in
the same manner that a convergence update would, prior to running the stack
check/suspend/resume.
Just in case, make sure the stack doesn't get stuck if we do end up in the
wrong state, by not trying to load a template with None as an ID.
Change-Id: Iedba67c5de39dc2d58938da5505dda5dd147c130
Story: #2003062
Task: 23101
-rw-r--r-- | heat/engine/resource.py | 5 | ||||
-rw-r--r-- | heat/engine/stack.py | 9 |
2 files changed, 12 insertions, 2 deletions
diff --git a/heat/engine/resource.py b/heat/engine/resource.py index 22c78daff..0965370ff 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -339,13 +339,14 @@ class Resource(status.ResourceStatus): initial_stk_defn = latest_stk_defn = curr_stack.defn - using_new_template = db_res.current_template_id != curr_stack.t.id + current_template_id = db_res.current_template_id + using_new_template = (current_template_id != curr_stack.t.id and + current_template_id is not None) will_create = (db_res.action == cls.INIT and is_update and current_traversal == curr_stack.current_traversal) if using_new_template and not will_create: # load the definition associated with the resource's template - current_template_id = db_res.current_template_id current_template = template.Template.load(context, current_template_id) initial_stk_defn = curr_stack.defn.clone_with_new_template( diff --git a/heat/engine/stack.py b/heat/engine/stack.py index 068f5d791..1ad5f26ba 100644 --- a/heat/engine/stack.py +++ b/heat/engine/stack.py @@ -1214,6 +1214,9 @@ class Stack(collections.Mapping): @profiler.trace('Stack.check', hide_args=False) @reset_state_on_error def check(self, notify=None): + if self.convergence: + self._update_or_store_resources() + self.updated_time = oslo_timeutils.utcnow() checker = scheduler.TaskRunner( self.stack_task, self.CHECK, @@ -1967,6 +1970,9 @@ class Stack(collections.Mapping): LOG.info('%s is already suspended', self) return + if self.convergence: + self._update_or_store_resources() + self.updated_time = oslo_timeutils.utcnow() sus_task = scheduler.TaskRunner( self.stack_task, @@ -1994,6 +2000,9 @@ class Stack(collections.Mapping): LOG.info('%s is already resumed', self) return + if self.convergence: + self._update_or_store_resources() + self.updated_time = oslo_timeutils.utcnow() sus_task = scheduler.TaskRunner( self.stack_task, |