From f3c74a6632c5ced8c25f5811315e3d943be13c17 Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Mon, 20 Sep 2021 20:54:42 +0200 Subject: Fix timeout calc of nested resource groups The timeout calculation of nested resource groups are using seconds but then it passing the value in seconds to the stack resource that is expected it in minutes. This leads to a rapidly increasing timeout value in each nesting levels. This patch converts the seconds to minutes before passing it forward. Story: 2009237 Task: 43372 Change-Id: I3f132d4889723f7b4a3a416779ac5ee7663249b8 (cherry picked from commit ef731bca05ea683c30448a2db397ae631c121d95) --- heat/engine/resources/openstack/heat/resource_group.py | 18 ++++++++++++------ .../functional/test_resource_group.py | 10 +--------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/heat/engine/resources/openstack/heat/resource_group.py b/heat/engine/resources/openstack/heat/resource_group.py index 48ef05ae9..1bdc0c312 100644 --- a/heat/engine/resources/openstack/heat/resource_group.py +++ b/heat/engine/resources/openstack/heat/resource_group.py @@ -15,6 +15,7 @@ import collections import copy import functools import itertools +import math from oslo_log import log as logging @@ -433,18 +434,18 @@ class ResourceGroup(stack_resource.StackResource): return False return True - def _run_to_completion(self, template, timeout): + def _run_to_completion(self, template, timeout_mins): updater = self.update_with_template(template, {}, - timeout) + timeout_mins) while not super(ResourceGroup, self).check_update_complete(updater): yield - def _run_update(self, total_capacity, max_updates, timeout): + def _run_update(self, total_capacity, max_updates, timeout_mins): template = self._assemble_for_rolling_update(total_capacity, max_updates) - return self._run_to_completion(template, timeout) + return self._run_to_completion(template, timeout_mins) def check_update_complete(self, checkers): for checker in checkers: @@ -776,13 +777,18 @@ class ResourceGroup(stack_resource.StackResource): batches = list(self._get_batches(self.get_size(), curr_cap, batch_size, min_in_service)) - update_timeout = self._update_timeout(len(batches), pause_sec) + update_timeout_secs = self._update_timeout(len(batches), pause_sec) + + # NOTE(gibi) update_timeout is in seconds but the _run_update + # eventually calls StackResource.update_with_template that takes + # timeout in minutes so we need to convert here. + update_timeout_mins = math.ceil(update_timeout_secs / 60) def tasks(): for index, (curr_cap, max_upd) in enumerate(batches): yield scheduler.TaskRunner(self._run_update, curr_cap, max_upd, - update_timeout) + update_timeout_mins) if index < (len(batches) - 1) and pause_sec > 0: yield scheduler.TaskRunner(pause_between_batch, pause_sec) diff --git a/heat_integrationtests/functional/test_resource_group.py b/heat_integrationtests/functional/test_resource_group.py index 999d41122..07be7f24c 100644 --- a/heat_integrationtests/functional/test_resource_group.py +++ b/heat_integrationtests/functional/test_resource_group.py @@ -181,15 +181,7 @@ resources: nested_stack = self.client.stacks.get(res.physical_resource_id) timeouts.add(nested_stack.timeout_mins) - # FIXME(gibi): This is bug story/2009237 as the timeout calculation of - # nested resource groups are broken. It is using seconds for the - # calculation but then pass that to functions expecting timeouts in - # minutes leading to increasing timeout value with each nesting level. - self.assertEqual({35939, 599}, timeouts) - # After the bug is fixed we expect timeouts less than the overall - # timeout requested for the whole stack. - - # self.assertEqual({10}, timeouts) + self.assertEqual({10}, timeouts) def test_update_increase_decrease_count(self): # create stack with resource group count 2 -- cgit v1.2.1