Merge lp:~allenap/maas/ntp-service-flip-flop into lp:~maas-committers/maas/trunk

Proposed by Gavin Panella
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: 5428
Proposed branch: lp:~allenap/maas/ntp-service-flip-flop
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 308 lines (+52/-36)
10 files modified
src/maasserver/models/service.py (+4/-3)
src/maasserver/regiondservices/ntp.py (+1/-1)
src/maasserver/regiondservices/tests/test_ntp.py (+2/-2)
src/maasserver/service_monitor.py (+5/-5)
src/maasserver/static/partials/node-details.html (+10/-3)
src/maasserver/tests/test_service_monitor.py (+3/-2)
src/provisioningserver/rackdservices/ntp.py (+1/-1)
src/provisioningserver/rackdservices/tests/test_ntp.py (+2/-2)
src/provisioningserver/service_monitor.py (+9/-6)
src/provisioningserver/tests/test_service_monitor.py (+15/-11)
To merge this branch: bzr merge lp:~allenap/maas/ntp-service-flip-flop
Reviewer Review Type Date Requested Status
Andres Rodriguez (community) Approve
Review via email: mp+307323@code.launchpad.net

Commit message

Record status information for NTP under different names for region and rack.

To post a comment you must log in.
Revision history for this message
Andres Rodriguez (andreserl) wrote :

lgtm!

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (414.3 KiB)

The attempt to merge lp:~allenap/maas/ntp-service-flip-flop into lp:maas failed. Below is the output from the failed tests.

Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [94.5 kB]
Hit:2 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial InRelease
Hit:3 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:4 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-backports InRelease
Fetched 94.5 kB in 0s (192 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
    --no-install-recommends install apache2 archdetect-deb authbind avahi-utils bash bind9 bind9utils build-essential bzr bzr-builddeb chromium-browser chromium-chromedriver curl daemontools debhelper dh-apport dh-systemd distro-info dnsutils firefox freeipmi-tools git gjs ipython isc-dhcp-common isc-dhcp-server libjs-angularjs libjs-jquery libjs-jquery-hotkeys libjs-yui3-full libjs-yui3-min libpq-dev make nodejs-legacy npm postgresql pxelinux python3-all python3-apt python3-attr python3-bson python3-convoy python3-crochet python3-cssselect python3-curtin python3-dev python3-distro-info python3-django python3-django-nose python3-django-piston3 python3-dnspython python3-docutils python3-formencode python3-hivex python3-httplib2 python3-jinja2 python3-jsonschema python3-lxml python3-netaddr python3-netifaces python3-novaclient python3-oauth python3-oauthlib python3-openssl python3-paramiko python3-petname python3-pexpect python3-psycopg2 python3-pyinotify python3-pyparsing python3-pyvmomi python3-requests python3-seamicroclient python3-setuptools python3-simplestreams python3-sphinx python3-tempita python3-twisted python3-txtftp python3-tz python3-yaml python3-zope.interface python-bson python-crochet python-django python-django-piston python-djorm-ext-pgarray python-formencode python-lxml python-netaddr python-netifaces python-pocket-lint python-psycopg2 python-simplejson python-tempita python-twisted python-yaml socat syslinux-common tgt ubuntu-cloudimage-keyring wget xvfb
Reading package lists...
Building dependency tree...
Reading state information...
archdetect-deb is already the newest version (1.117ubuntu2).
authbind is already the newest version (2.1.1+nmu1).
avahi-utils is already the newest version (0.6.32~rc+dfsg-1ubuntu2).
build-essential is already the newest version (12.1ubuntu2).
debhelper is already the newest version (9.20160115ubuntu3).
distro-info is already the newest version (0.14build1).
freeipmi-tools is already the newest version (1.4.11-1ubuntu1).
git is already the newest version (1:2.7.4-0ubuntu1).
libjs-angularjs is already the newest version (1.2.28-1ubuntu2).
libjs-jquery is already the newest version (1.11.3+dfsg-4).
libjs-yui3-full is already the newest version (3.5.1-1ubuntu3).
libjs-yui3-min is already the newest version (3.5.1-1ubuntu3).
make is already the newest version (4.1-6).
postgresql is already the newest version (9.5+173).
pxelinux is already the newest version (3:6.03+dfsg-11ubuntu1).
python-formencode is already the newest version (1.3.0-0ubuntu5).
python-lxml is already the newest version (3.5.0-1build1).
python-netaddr is already the newest v...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/models/service.py'
2--- src/maasserver/models/service.py 2016-09-07 14:23:05 +0000
3+++ src/maasserver/models/service.py 2016-10-01 09:05:55 +0000
4@@ -26,7 +26,7 @@
5 REGION_SERVICES = frozenset({
6 "regiond",
7 "bind9",
8- "ntp",
9+ "ntp_region",
10 "proxy",
11 })
12
13@@ -39,7 +39,7 @@
14 "tgt",
15 "dhcpd",
16 "dhcpd6",
17- "ntp",
18+ "ntp_rack",
19 })
20
21 # Statuses that should be set on each service when node is marked dead. NOTE
22@@ -54,7 +54,8 @@
23 "tgt": SERVICE_STATUS.UNKNOWN,
24 "dhcpd": SERVICE_STATUS.DEAD,
25 "dhcpd6": SERVICE_STATUS.DEAD,
26- "ntp": SERVICE_STATUS.DEAD,
27+ "ntp_region": SERVICE_STATUS.DEAD,
28+ "ntp_rack": SERVICE_STATUS.DEAD,
29 }
30
31
32
33=== modified file 'src/maasserver/regiondservices/ntp.py'
34--- src/maasserver/regiondservices/ntp.py 2016-09-29 14:04:47 +0000
35+++ src/maasserver/regiondservices/ntp.py 2016-10-01 09:05:55 +0000
36@@ -108,7 +108,7 @@
37 d = deferToThread(
38 configure_region, configuration.references, configuration.peers)
39 d.addCallback(
40- callOut, service_monitor.restartService, "ntp")
41+ callOut, service_monitor.restartService, "ntp_region")
42 return d
43
44 def _configurationApplied(self, configuration):
45
46=== modified file 'src/maasserver/regiondservices/tests/test_ntp.py'
47--- src/maasserver/regiondservices/tests/test_ntp.py 2016-09-29 14:04:47 +0000
48+++ src/maasserver/regiondservices/tests/test_ntp.py 2016-10-01 09:05:55 +0000
49@@ -95,13 +95,13 @@
50 yield service._tryUpdate()
51 self.assertThat(configure_region, MockCalledOnceWith(
52 configuration.references, configuration.peers))
53- self.assertThat(restartService, MockCalledOnceWith("ntp"))
54+ self.assertThat(restartService, MockCalledOnceWith("ntp_region"))
55 # If the configuration has not changed then a second call to
56 # `_tryUpdate` does not result in another call to `configure_region`.
57 yield service._tryUpdate()
58 self.assertThat(configure_region, MockCalledOnceWith(
59 configuration.references, configuration.peers))
60- self.assertThat(restartService, MockCalledOnceWith("ntp"))
61+ self.assertThat(restartService, MockCalledOnceWith("ntp_region"))
62
63
64 class TestRegionNetworkTimeProtocolService_Errors(
65
66=== modified file 'src/maasserver/service_monitor.py'
67--- src/maasserver/service_monitor.py 2016-08-19 10:22:29 +0000
68+++ src/maasserver/service_monitor.py 2016-10-01 09:05:55 +0000
69@@ -29,10 +29,10 @@
70 service_name = "bind9"
71
72
73-class NTPService(AlwaysOnService):
74- """Monitored NTP service."""
75+class NTPServiceOnRegion(AlwaysOnService):
76+ """Monitored NTP service on a region controller host."""
77
78- name = "ntp"
79+ name = "ntp_region"
80 service_name = "ntp"
81
82
83@@ -53,7 +53,7 @@
84 return (SERVICE_STATE.OFF,
85 "disabled, alternate proxy is configured in settings.")
86 elif proxyconfig.is_config_present() is False:
87- return (SERVICE_STATE.OFF, "No configuration file present.")
88+ return (SERVICE_STATE.OFF, "no configuration file present.")
89 else:
90 return (SERVICE_STATE.ON, None)
91
92@@ -64,6 +64,6 @@
93 # mirrored in maasserver.model.services.
94 service_monitor = ServiceMonitor(
95 BIND9Service(),
96- NTPService(),
97+ NTPServiceOnRegion(),
98 ProxyService(),
99 )
100
101=== modified file 'src/maasserver/static/partials/node-details.html'
102--- src/maasserver/static/partials/node-details.html 2016-09-22 15:15:31 +0000
103+++ src/maasserver/static/partials/node-details.html 2016-10-01 09:05:55 +0000
104@@ -401,6 +401,13 @@
105 <span data-ng-if="services.proxy.status_info"> &mdash; {$ services.proxy.status_info $}</span>
106 </span>
107 </li>
108+ <li class="list__item" data-ng-if="services.ntp_region">
109+ <span>
110+ <span class="icon icon--{$ getServiceClass(services.ntp_region) $}"></span>
111+ &nbsp;ntp
112+ <span data-ng-if="services.ntp_region.status_info"> &mdash; {$ services.ntp_region.status_info $}</span>
113+ </span>
114+ </li>
115 </ul>
116 </div>
117 </div>
118@@ -454,11 +461,11 @@
119 <span data-ng-if="services.tgt.status_info"> &mdash; {$ services.tgt.status_info $}</span>
120 </span>
121 </li>
122- <li class="list__item">
123+ <li class="list__item" data-ng-if="services.ntp_rack">
124 <span>
125- <span class="icon icon--{$ getServiceClass(services.ntp) $}"></span>
126+ <span class="icon icon--{$ getServiceClass(services.ntp_rack) $}"></span>
127 &nbsp;ntp
128- <span data-ng-if="services.ntp.status_info"> &mdash; {$ services.ntp.status_info $}</span>
129+ <span data-ng-if="services.ntp_rack.status_info"> &mdash; {$ services.ntp_rack.status_info $}</span>
130 </span>
131 </li>
132 </ul>
133
134=== modified file 'src/maasserver/tests/test_service_monitor.py'
135--- src/maasserver/tests/test_service_monitor.py 2016-08-19 10:22:29 +0000
136+++ src/maasserver/tests/test_service_monitor.py 2016-10-01 09:05:55 +0000
137@@ -34,7 +34,8 @@
138
139 def test__includes_all_services(self):
140 self.assertItemsEqual(
141- ["bind9", "ntp", "proxy"], service_monitor._services)
142+ ["bind9", "ntp_region", "proxy"],
143+ service_monitor._services)
144
145
146 class TestProxyService(MAASTransactionServerTestCase):
147@@ -70,7 +71,7 @@
148 os.environ['MAAS_PROXY_CONFIG_DIR'] = "/tmp/%s" % factory.make_name()
149 expected_state = yield maybeDeferred(service.getExpectedState)
150 self.assertEqual(
151- (SERVICE_STATE.OFF, "No configuration file present."),
152+ (SERVICE_STATE.OFF, "no configuration file present."),
153 expected_state)
154 del os.environ['MAAS_PROXY_CONFIG_DIR']
155
156
157=== modified file 'src/provisioningserver/rackdservices/ntp.py'
158--- src/provisioningserver/rackdservices/ntp.py 2016-09-29 14:04:47 +0000
159+++ src/provisioningserver/rackdservices/ntp.py 2016-10-01 09:05:55 +0000
160@@ -99,7 +99,7 @@
161 """
162 if configuration.is_rack and not configuration.is_region:
163 d = deferToThread(configure_rack, configuration.references, ())
164- d.addCallback(callOut, service_monitor.restartService, "ntp")
165+ d.addCallback(callOut, service_monitor.restartService, "ntp_rack")
166 return d
167
168 def _configurationApplied(self, configuration):
169
170=== modified file 'src/provisioningserver/rackdservices/tests/test_ntp.py'
171--- src/provisioningserver/rackdservices/tests/test_ntp.py 2016-09-29 14:04:47 +0000
172+++ src/provisioningserver/rackdservices/tests/test_ntp.py 2016-10-01 09:05:55 +0000
173@@ -121,12 +121,12 @@
174
175 yield service._tryUpdate()
176 self.assertThat(configure_rack, MockCalledOnceWith(servers, ()))
177- self.assertThat(restartService, MockCalledOnceWith("ntp"))
178+ self.assertThat(restartService, MockCalledOnceWith("ntp_rack"))
179 # If the configuration has not changed then a second call to
180 # `_tryUpdate` does not result in another call to `configure`.
181 yield service._tryUpdate()
182 self.assertThat(configure_rack, MockCalledOnceWith(servers, ()))
183- self.assertThat(restartService, MockCalledOnceWith("ntp"))
184+ self.assertThat(restartService, MockCalledOnceWith("ntp_rack"))
185
186 @inlineCallbacks
187 def test_is_silent_and_does_nothing_when_region_is_not_available(self):
188
189=== modified file 'src/provisioningserver/service_monitor.py'
190--- src/provisioningserver/service_monitor.py 2016-08-19 15:59:07 +0000
191+++ src/provisioningserver/service_monitor.py 2016-10-01 09:05:55 +0000
192@@ -64,10 +64,10 @@
193 service_name = "tgt"
194
195
196-class NTPService(Service):
197- """Monitored NTP service."""
198+class NTPServiceOnRack(Service):
199+ """Monitored NTP service on a rack controller host."""
200
201- name = "ntp"
202+ name = "ntp_rack"
203 service_name = "ntp"
204
205 def getExpectedState(self):
206@@ -81,8 +81,11 @@
207 return d
208
209 def _getExpectedStateForControllerType(self, controller_type):
210- if controller_type["is_rack"] and not controller_type["is_region"]:
211- return SERVICE_STATE.ON, None
212+ if controller_type["is_rack"]:
213+ if controller_type["is_region"]:
214+ return SERVICE_STATE.ANY, "managed by the region."
215+ else:
216+ return SERVICE_STATE.ON, None
217 else:
218 return SERVICE_STATE.ANY, None
219
220@@ -92,6 +95,6 @@
221 service_monitor = ServiceMonitor(
222 DHCPv4Service(),
223 DHCPv6Service(),
224- NTPService(),
225+ NTPServiceOnRack(),
226 TGTService(),
227 )
228
229=== modified file 'src/provisioningserver/tests/test_service_monitor.py'
230--- src/provisioningserver/tests/test_service_monitor.py 2016-08-19 15:59:07 +0000
231+++ src/provisioningserver/tests/test_service_monitor.py 2016-10-01 09:05:55 +0000
232@@ -19,7 +19,7 @@
233 DHCPService,
234 DHCPv4Service,
235 DHCPv6Service,
236- NTPService,
237+ NTPServiceOnRack,
238 service_monitor,
239 TGTService,
240 )
241@@ -108,15 +108,15 @@
242 self.assertEqual((SERVICE_STATE.ON, None), tgt.getExpectedState())
243
244
245-class TestNTPService(MAASTestCase):
246+class TestNTPServiceOnRack(MAASTestCase):
247
248 def test_name_and_service_name(self):
249- ntp = NTPService()
250+ ntp = NTPServiceOnRack()
251 self.assertEqual("ntp", ntp.service_name)
252- self.assertEqual("ntp", ntp.name)
253-
254-
255-class TestNTPService_Scenarios(MAASTestCase):
256+ self.assertEqual("ntp_rack", ntp.name)
257+
258+
259+class TestNTPServiceOnRack_Scenarios(MAASTestCase):
260
261 run_tests_with = MAASTwistedRunTest.make_factory(timeout=5)
262
263@@ -124,37 +124,41 @@
264 ("rack", dict(
265 is_region=False, is_rack=True,
266 expected_state=SERVICE_STATE.ON,
267+ expected_info=None,
268 )),
269 ("region", dict(
270 is_region=True, is_rack=False,
271 expected_state=SERVICE_STATE.ANY,
272+ expected_info=None,
273 )),
274 ("region+rack", dict(
275 is_region=True, is_rack=True,
276 expected_state=SERVICE_STATE.ANY,
277+ expected_info="managed by the region.",
278 )),
279 ("machine", dict(
280 is_region=False, is_rack=False,
281 expected_state=SERVICE_STATE.ANY,
282+ expected_info=None,
283 )),
284 )
285
286 def setUp(self):
287- super(TestNTPService_Scenarios, self).setUp()
288+ super(TestNTPServiceOnRack_Scenarios, self).setUp()
289 return prepareRegionForGetControllerType(
290 self, is_region=self.is_region, is_rack=self.is_rack)
291
292 @inlineCallbacks
293 def test_getExpectedState(self):
294- ntp = NTPService()
295+ ntp = NTPServiceOnRack()
296 self.assertThat(
297 (yield ntp.getExpectedState()),
298- Equals((self.expected_state, None)))
299+ Equals((self.expected_state, self.expected_info)))
300
301
302 class TestGlobalServiceMonitor(MAASTestCase):
303
304 def test__includes_all_services(self):
305 self.assertItemsEqual(
306- ["dhcpd", "dhcpd6", "ntp", "tgt"],
307+ ["dhcpd", "dhcpd6", "ntp_rack", "tgt"],
308 service_monitor._services)