Merge ~pponnuvel/ubuntu/+source/heat:lp2019175_ussuri into ~ubuntu-openstack-dev/ubuntu/+source/heat:stable/ussuri

Proposed by Ponnuvel Palaniyappan
Status: Merged
Merged at revision: bbe819ec1cc7d218725700fbf66ab61a81aee4eb
Proposed branch: ~pponnuvel/ubuntu/+source/heat:lp2019175_ussuri
Merge into: ~ubuntu-openstack-dev/ubuntu/+source/heat:stable/ussuri
Diff against target: 145 lines (+125/-0)
3 files modified
debian/changelog (+7/-0)
debian/patches/lp2019175.patch (+117/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
Ubuntu OpenStack uploaders Pending
Review via email: mp+443089@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/debian/changelog b/debian/changelog
index 295df78..09e6db7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
1heat (1:14.2.0-0ubuntu2) UNRELEASED; urgency=medium
2
3 * d/p/lp2019175.patch: Fix None comparision when sorting
4 by `updated_at` (LP: #2019175)
5
6 -- Ponnuvel Palaniyappan <pponnuvel@gmail.com> Mon, 15 May 2023 17:37:30 +0100
7
1heat (1:14.2.0-0ubuntu1) focal; urgency=medium8heat (1:14.2.0-0ubuntu1) focal; urgency=medium
29
3 * d/watch: Add trailing slash to URL.10 * d/watch: Add trailing slash to URL.
diff --git a/debian/patches/lp2019175.patch b/debian/patches/lp2019175.patch
4new file mode 10064411new file mode 100644
index 0000000..8fe7e1c
--- /dev/null
+++ b/debian/patches/lp2019175.patch
@@ -0,0 +1,117 @@
1From 785180ddc7a31bcee1494c7935406cccde902b0d Mon Sep 17 00:00:00 2001
2From: Erik Panter <e.panter@mittwald.de>
3Date: Fri, 29 Oct 2021 11:03:27 +0200
4Subject: [PATCH] Fix None comparision when sorting by `updated_at`
5
6When sorting resource candidates in `_get_best_existing_rsrc_db`,
7resources with the same score are sorted by `updated_at`, which can be
8`None`. If that is the case, use `created_at` instead.
9
10(victoria to ussuri)
11Conflicts:
12 heat/tests/test_convg_stack.py
13
14Resolved conflict caused by the following commit.
15
16commit fd6cf83554db68752278d37f577ba984d9f831b2
17 Use unittest.mock instead of third party mock
18
19Task: 43815
20Story: 2009653
21Change-Id: Ic0265fcf7ceb811803cdebaa8932fe80dc59a627
22(cherry picked from commit 403fa55fe94ae1063d2cb4b8db3b63b76b1ee5cf)
23(cherry picked from commit 5ea5276a3e76829fd72345e3aae7482cbd260b51)
24(cherry picked from commit aa31864de4fe480674a0669c05a024ab28c3c429)
25(cherry picked from commit 26a20de88c0b578422e9847c1210d10f10b04854)
26---
27 heat/engine/stack.py | 5 ++++-
28 heat/tests/test_convg_stack.py | 28 +++++++++++++++++++++++-----
29 2 files changed, 27 insertions(+), 6 deletions(-)
30
31diff --git a/heat/engine/stack.py b/heat/engine/stack.py
32index 1b5f65387..801fce0a0 100644
33--- a/heat/engine/stack.py
34+++ b/heat/engine/stack.py
35@@ -1499,7 +1499,10 @@ class Stack(collections.Mapping):
36 # Rolling back to previous resource
37 score += 10
38
39- return score, ext_rsrc.updated_at
40+ last_changed_at = ext_rsrc.updated_at
41+ if last_changed_at is None:
42+ last_changed_at = ext_rsrc.created_at
43+ return score, last_changed_at
44
45 candidates = sorted((r for r in self.ext_rsrcs_db.values()
46 if r.name == rsrc_name),
47diff --git a/heat/tests/test_convg_stack.py b/heat/tests/test_convg_stack.py
48index 1d2476d0b..466ea11c9 100644
49--- a/heat/tests/test_convg_stack.py
50+++ b/heat/tests/test_convg_stack.py
51@@ -11,7 +11,10 @@
52 # License for the specific language governing permissions and limitations
53 # under the License.
54
55+from datetime import datetime
56+from datetime import timedelta
57 import mock
58+
59 from oslo_config import cfg
60
61 from heat.common import template_format
62@@ -428,22 +431,32 @@ class StackConvergenceCreateUpdateDeleteTest(common.HeatTestCase):
63 stack.prev_raw_template_id = 2
64 stack.t.id = 3
65
66- def db_resource(current_template_id):
67+ def db_resource(current_template_id,
68+ created_at=None,
69+ updated_at=None):
70 db_res = resource_objects.Resource(stack.context)
71 db_res['id'] = current_template_id
72 db_res['name'] = 'A'
73 db_res['current_template_id'] = current_template_id
74- db_res['action'] = 'CREATE'
75+ db_res['action'] = 'UPDATE' if updated_at else 'CREATE'
76 db_res['status'] = 'COMPLETE'
77- db_res['updated_at'] = None
78+ db_res['updated_at'] = updated_at
79+ db_res['created_at'] = created_at
80 db_res['replaced_by'] = None
81 return db_res
82
83+ start_time = datetime.utcfromtimestamp(0)
84+
85+ def t(minutes):
86+ return start_time + timedelta(minutes=minutes)
87+
88 a_res_2 = db_resource(2)
89 a_res_3 = db_resource(3)
90- a_res_1 = db_resource(1)
91+ a_res_0 = db_resource(0, created_at=t(0), updated_at=t(1))
92+ a_res_1 = db_resource(1, created_at=t(2))
93 existing_res = {a_res_2.id: a_res_2,
94 a_res_3.id: a_res_3,
95+ a_res_0.id: a_res_0,
96 a_res_1.id: a_res_1}
97 stack.ext_rsrcs_db = existing_res
98 best_res = stack._get_best_existing_rsrc_db('A')
99@@ -459,9 +472,14 @@ class StackConvergenceCreateUpdateDeleteTest(common.HeatTestCase):
100 # no resource with current template id as 3 or 2
101 del existing_res[2]
102 best_res = stack._get_best_existing_rsrc_db('A')
103- # should return resource with template id 1 existing in DB
104+ # should return resource with template id 1 which is the newest
105 self.assertEqual(a_res_1.id, best_res.id)
106
107+ del existing_res[1]
108+ best_res = stack._get_best_existing_rsrc_db('A')
109+ # should return resource with template id 0 existing in the db
110+ self.assertEqual(a_res_0.id, best_res.id)
111+
112 @mock.patch.object(parser.Stack, '_converge_create_or_update')
113 def test_updated_time_stack_create(self, mock_ccu, mock_cr):
114 stack = parser.Stack(utils.dummy_context(), 'convg_updated_time_test',
115--
1162.39.2
117
diff --git a/debian/patches/series b/debian/patches/series
index e280fc1..71557b4 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
1sudoers_patch.patch1sudoers_patch.patch
2lp2019175.patch

Subscribers

People subscribed via source and target branches