Merge ~ltrager/maas:remove_get_boot_sources_v1 into maas:master

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: 4fd1831ecd69b9b74c0c6f76ca2f39ba6fb960d9
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~ltrager/maas:remove_get_boot_sources_v1
Merge into: maas:master
Diff against target: 316 lines (+8/-183)
5 files modified
src/maasserver/rpc/regionservice.py (+1/-14)
src/maasserver/rpc/tests/test_regionservice_calls.py (+0/-21)
src/provisioningserver/rackdservices/image_download_service.py (+4/-25)
src/provisioningserver/rackdservices/tests/test_image_download_service.py (+2/-85)
src/provisioningserver/rpc/region.py (+1/-38)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Björn Tillenius Approve
Review via email: mp+402296@code.launchpad.net

Commit message

Remove the GetBootSources V1 RPC call.

To post a comment you must log in.
Revision history for this message
Björn Tillenius (bjornt) wrote :

+1

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b remove_get_boot_sources_v1 lp:~ltrager/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 4fd1831ecd69b9b74c0c6f76ca2f39ba6fb960d9

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/rpc/regionservice.py b/src/maasserver/rpc/regionservice.py
2index 1ec0997..950b8d3 100644
3--- a/src/maasserver/rpc/regionservice.py
4+++ b/src/maasserver/rpc/regionservice.py
5@@ -1,4 +1,4 @@
6-# Copyright 2014-2018 Canonical Ltd. This software is licensed under the
7+# Copyright 2014-2021 Canonical Ltd. This software is licensed under the
8 # GNU Affero General Public License version 3 (see the file LICENSE).
9
10 """RPC implementation for regions."""
11@@ -207,19 +207,6 @@ class Region(RPCProtocol):
12
13 @region.GetBootSources.responder
14 def get_boot_sources(self, uuid):
15- """get_boot_sources()
16-
17- Deprecated: get_boot_sources_v2() should be used instead.
18-
19- Implementation of
20- :py:class:`~provisioningserver.rpc.region.GetBootSources`.
21- """
22- d = deferToDatabase(get_simplestream_endpoint)
23- d.addCallback(lambda source: {"sources": [source]})
24- return d
25-
26- @region.GetBootSourcesV2.responder
27- def get_boot_sources_v2(self, uuid):
28 """get_boot_sources_v2()
29
30 Implementation of
31diff --git a/src/maasserver/rpc/tests/test_regionservice_calls.py b/src/maasserver/rpc/tests/test_regionservice_calls.py
32index 2949f9e..604b168 100644
33--- a/src/maasserver/rpc/tests/test_regionservice_calls.py
34+++ b/src/maasserver/rpc/tests/test_regionservice_calls.py
35@@ -56,7 +56,6 @@ from provisioningserver.rpc.region import (
36 GetArchiveMirrors,
37 GetBootConfig,
38 GetBootSources,
39- GetBootSourcesV2,
40 GetControllerType,
41 GetDNSConfiguration,
42 GetProxies,
43@@ -341,26 +340,6 @@ class TestRegionProtocol_GetBootSources(MAASTransactionServerTestCase):
44 return d.addCallback(check)
45
46
47-class TestRegionProtocol_GetBootSourcesV2(MAASTransactionServerTestCase):
48- def test_get_boot_sources_v2_is_registered(self):
49- protocol = Region()
50- responder = protocol.locateResponder(GetBootSourcesV2.commandName)
51- self.assertIsNotNone(responder)
52-
53- @wait_for_reactor
54- def test_get_boot_sources_v2_returns_simplestreams_endpoint(self):
55- uuid = factory.make_name("uuid")
56-
57- d = call_responder(Region(), GetBootSourcesV2, {"uuid": uuid})
58-
59- def check(response):
60- self.assertEqual(
61- {"sources": [get_simplestream_endpoint()]}, response
62- )
63-
64- return d.addCallback(check)
65-
66-
67 class TestRegionProtocol_GetArchiveMirrors(MAASTransactionServerTestCase):
68 def test_get_archive_mirrors_is_registered(self):
69 protocol = Region()
70diff --git a/src/provisioningserver/rackdservices/image_download_service.py b/src/provisioningserver/rackdservices/image_download_service.py
71index a86e879..87e8fb1 100644
72--- a/src/provisioningserver/rackdservices/image_download_service.py
73+++ b/src/provisioningserver/rackdservices/image_download_service.py
74@@ -1,4 +1,4 @@
75-# Copyright 2014-2016 Canonical Ltd. This software is licensed under the
76+# Copyright 2014-2021 Canonical Ltd. This software is licensed under the
77 # GNU Affero General Public License version 3 (see the file LICENSE).
78
79 """Service to periodically refresh the boot images."""
80@@ -7,18 +7,13 @@
81 from datetime import timedelta
82
83 from twisted.application.internet import TimerService
84-from twisted.internet.defer import inlineCallbacks, returnValue
85-from twisted.protocols.amp import UnhandledCommand
86+from twisted.internet.defer import inlineCallbacks
87
88 from provisioningserver.boot import tftppath
89 from provisioningserver.logger import get_maas_logger, LegacyLogger
90 from provisioningserver.rpc.boot_images import import_boot_images
91 from provisioningserver.rpc.exceptions import NoConnectionsAvailable
92-from provisioningserver.rpc.region import (
93- GetBootSources,
94- GetBootSourcesV2,
95- GetProxies,
96-)
97+from provisioningserver.rpc.region import GetBootSources, GetProxies
98 from provisioningserver.utils.twisted import pause, retries
99
100 maaslog = get_maas_logger("boot_image_download_service")
101@@ -58,22 +53,6 @@ class ImageDownloadService(TimerService):
102 return self.maybe_start_download().addErrback(download_failure)
103
104 @inlineCallbacks
105- def _get_boot_sources(self, client):
106- """Gets the boot sources from the region."""
107- try:
108- sources = yield client(GetBootSourcesV2, uuid=client.localIdent)
109- except UnhandledCommand:
110- # Region has not been upgraded to support the new call, use the
111- # old call. The old call did not provide the new os selection
112- # parameter. Region does not support boot source selection by os,
113- # so its set too allow all operating systems.
114- sources = yield client(GetBootSources, uuid=client.localIdent)
115- for source in sources["sources"]:
116- for selection in source["selections"]:
117- selection["os"] = "*"
118- returnValue(sources)
119-
120- @inlineCallbacks
121 def _start_download(self):
122 client = None
123 # Retry a few times, since this service usually comes up before
124@@ -91,7 +70,7 @@ class ImageDownloadService(TimerService):
125 return
126
127 # Get sources from region
128- sources = yield self._get_boot_sources(client)
129+ sources = yield client(GetBootSources, uuid=client.localIdent)
130 # Get http proxy from region
131 proxies = yield client(GetProxies)
132
133diff --git a/src/provisioningserver/rackdservices/tests/test_image_download_service.py b/src/provisioningserver/rackdservices/tests/test_image_download_service.py
134index e4e2462..63254a1 100644
135--- a/src/provisioningserver/rackdservices/tests/test_image_download_service.py
136+++ b/src/provisioningserver/rackdservices/tests/test_image_download_service.py
137@@ -1,24 +1,22 @@
138-# Copyright 2014-2016 Canonical Ltd. This software is licensed under the
139+# Copyright 2014-2021 Canonical Ltd. This software is licensed under the
140 # GNU Affero General Public License version 3 (see the file LICENSE).
141
142 """Tests for provisioningserver.rackdservices.image_download_service"""
143
144
145 from datetime import timedelta
146-from unittest.mock import call, Mock, sentinel
147+from unittest.mock import Mock, sentinel
148 from urllib.parse import urlparse
149
150 from fixtures import FakeLogger
151 from twisted.application.internet import TimerService
152 from twisted.internet import defer
153 from twisted.internet.task import Clock
154-from twisted.protocols.amp import UnhandledCommand
155
156 from maastesting.factory import factory
157 from maastesting.matchers import (
158 get_mock_calls,
159 MockCalledOnceWith,
160- MockCallsMatch,
161 MockNotCalled,
162 )
163 from maastesting.testcase import MAASTestCase, MAASTwistedRunTest
164@@ -30,7 +28,6 @@ from provisioningserver.rackdservices.image_download_service import (
165 from provisioningserver.rpc import boot_images
166 from provisioningserver.rpc.boot_images import _run_import
167 from provisioningserver.rpc.exceptions import NoConnectionsAvailable
168-from provisioningserver.rpc.region import GetBootSources, GetBootSourcesV2
169
170
171 class TestPeriodicImageDownloadService(MAASTestCase):
172@@ -196,83 +193,3 @@ class TestPeriodicImageDownloadService(MAASTestCase):
173 """,
174 logger.output,
175 )
176-
177-
178-class TestGetBootSources(MAASTestCase):
179-
180- run_tests_with = MAASTwistedRunTest.make_factory(timeout=5)
181-
182- @defer.inlineCallbacks
183- def test_get_boot_sources_calls_get_boot_sources_v2_before_v1(self):
184- clock = Clock()
185- client_call = Mock()
186- client_call.side_effect = [
187- defer.succeed(dict(sources=sentinel.sources))
188- ]
189- client_call.localIdent = factory.make_UUID()
190-
191- service = ImageDownloadService(sentinel.rpc, sentinel.tftp_root, clock)
192- sources = yield service._get_boot_sources(client_call)
193- self.assertEqual(sources.get("sources"), sentinel.sources)
194- self.assertThat(
195- client_call,
196- MockCalledOnceWith(GetBootSourcesV2, uuid=client_call.localIdent),
197- )
198-
199- @defer.inlineCallbacks
200- def test_get_boot_sources_calls_get_boot_sources_v1_on_v2_missing(self):
201- clock = Clock()
202- client_call = Mock()
203- client_call.side_effect = [
204- defer.fail(UnhandledCommand()),
205- defer.succeed(dict(sources=[])),
206- ]
207- client_call.localIdent = factory.make_UUID()
208-
209- service = ImageDownloadService(sentinel.rpc, sentinel.tftp_root, clock)
210- yield service._get_boot_sources(client_call)
211- self.assertThat(
212- client_call,
213- MockCallsMatch(
214- call(GetBootSourcesV2, uuid=client_call.localIdent),
215- call(GetBootSources, uuid=client_call.localIdent),
216- ),
217- )
218-
219- @defer.inlineCallbacks
220- def test_get_boot_sources_v1_sets_os_to_wildcard(self):
221- sources = [
222- {
223- "path": factory.make_url(),
224- "selections": [
225- {
226- "release": "trusty",
227- "arches": ["amd64"],
228- "subarches": ["generic"],
229- "labels": ["release"],
230- },
231- {
232- "release": "precise",
233- "arches": ["amd64"],
234- "subarches": ["generic"],
235- "labels": ["release"],
236- },
237- ],
238- }
239- ]
240-
241- clock = Clock()
242- client_call = Mock()
243- client_call.side_effect = [
244- defer.fail(UnhandledCommand()),
245- defer.succeed(dict(sources=sources)),
246- ]
247-
248- service = ImageDownloadService(sentinel.rpc, sentinel.tftp_root, clock)
249- sources = yield service._get_boot_sources(client_call)
250- os_selections = [
251- selection.get("os")
252- for source in sources["sources"]
253- for selection in source["selections"]
254- ]
255- self.assertEqual(["*", "*"], os_selections)
256diff --git a/src/provisioningserver/rpc/region.py b/src/provisioningserver/rpc/region.py
257index 6c1a741..990632a 100644
258--- a/src/provisioningserver/rpc/region.py
259+++ b/src/provisioningserver/rpc/region.py
260@@ -1,4 +1,4 @@
261-# Copyright 2014-2016 Canonical Ltd. This software is licensed under the
262+# Copyright 2014-2021 Canonical Ltd. This software is licensed under the
263 # GNU Affero General Public License version 3 (see the file LICENSE).
264
265 """RPC declarations for the region.
266@@ -13,7 +13,6 @@ __all__ = [
267 "GetArchiveMirrors",
268 "GetBootConfig",
269 "GetBootSources",
270- "GetBootSourcesV2",
271 "GetControllerType",
272 "GetDiscoveryState",
273 "GetDNSConfiguration",
274@@ -162,42 +161,6 @@ class GetBootConfig(amp.Command):
275 class GetBootSources(amp.Command):
276 """Report boot sources and selections for the given cluster.
277
278- :since: 1.6
279- :deprecated: 1.7
280- """
281-
282- arguments = [
283- # The cluster UUID.
284- (b"uuid", amp.Unicode())
285- ]
286- response = [
287- (
288- b"sources",
289- AmpList(
290- [
291- (b"url", amp.Unicode()),
292- (b"keyring_data", Bytes()),
293- (
294- b"selections",
295- AmpList(
296- [
297- (b"release", amp.Unicode()),
298- (b"arches", amp.ListOf(amp.Unicode())),
299- (b"subarches", amp.ListOf(amp.Unicode())),
300- (b"labels", amp.ListOf(amp.Unicode())),
301- ]
302- ),
303- ),
304- ]
305- ),
306- )
307- ]
308- errors = []
309-
310-
311-class GetBootSourcesV2(amp.Command):
312- """Report boot sources and selections for the given cluster.
313-
314 Includes the new os field for the selections.
315
316 :since: 1.7

Subscribers

People subscribed via source and target branches