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

Subscribers

People subscribed via source and target branches