Merge ~ltrager/maas:lp1789302 into maas:master

Proposed by Lee Trager
Status: Merged
Approved by: Andres Rodriguez
Approved revision: f12ab7d19b3c0aa3f7193ed3b53c27b84debb7f7
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~ltrager/maas:lp1789302
Merge into: maas:master
Diff against target: 60 lines (+13/-6)
2 files modified
src/provisioningserver/utils/service_monitor.py (+4/-1)
src/provisioningserver/utils/tests/test_service_monitor.py (+9/-5)
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve
Review via email: mp+355871@code.launchpad.net

Commit message

LP: #1789302 - Process systemd unit transitioning statuses.

systemctl reports when a unit is transitioning from one state to another. For
MAAS's proposes consider reloading and activating DEAD because the process
isn't available yet and consider deactiving ON because the process is still
available.

To post a comment you must log in.
Revision history for this message
Blake Rouse (blake-rouse) :
~ltrager/maas:lp1789302 updated
63eed23... by Lee Trager

Merge branch 'master' into lp1789302

2393000... by Lee Trager

Map systemd unit status deactivating to SERVICE_STATE.OFF

f12ab7d... by Lee Trager

Fix lint

Revision history for this message
Lee Trager (ltrager) wrote :

Updated to map systemd unit status deactiving to SERVICE_STATE.OFF

Revision history for this message
Blake Rouse (blake-rouse) wrote :

Looks good, thanks for the change.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/provisioningserver/utils/service_monitor.py b/src/provisioningserver/utils/service_monitor.py
2index 3326f43..ac2b4ed 100644
3--- a/src/provisioningserver/utils/service_monitor.py
4+++ b/src/provisioningserver/utils/service_monitor.py
5@@ -1,4 +1,4 @@
6-# Copyright 2015-2016 Canonical Ltd. This software is licensed under the
7+# Copyright 2015-2018 Canonical Ltd. This software is licensed under the
8 # GNU Affero General Public License version 3 (see the file LICENSE).
9
10 """Services monitor ensures services are in their expected state."""
11@@ -234,8 +234,11 @@ class ServiceMonitor:
12 # Used to convert the systemd state to the `SERVICE_STATE` enum.
13 SYSTEMD_TO_STATE = {
14 "active": SERVICE_STATE.ON,
15+ "reloading": SERVICE_STATE.DEAD,
16 "inactive": SERVICE_STATE.OFF,
17 "failed": SERVICE_STATE.DEAD,
18+ "activating": SERVICE_STATE.DEAD,
19+ "deactivating": SERVICE_STATE.OFF,
20 }
21
22 # Used to convert the supervisor state to the `SERVICE_STATE` enum.
23diff --git a/src/provisioningserver/utils/tests/test_service_monitor.py b/src/provisioningserver/utils/tests/test_service_monitor.py
24index 969fb00..2d5728e 100644
25--- a/src/provisioningserver/utils/tests/test_service_monitor.py
26+++ b/src/provisioningserver/utils/tests/test_service_monitor.py
27@@ -1,4 +1,4 @@
28-# Copyright 2015-2016 Canonical Ltd. This software is licensed under the
29+# Copyright 2015-2018 Canonical Ltd. This software is licensed under the
30 # GNU Affero General Public License version 3 (see the file LICENSE).
31
32 """Tests for `provisioningserver.service_monitor`."""
33@@ -681,9 +681,11 @@ class TestServiceMonitor(MAASTestCase):
34 systemd_status_output = dedent("""\
35 %s.service - LSB: iscsi target daemon
36 Loaded: loaded (/lib/systemd/system/%s.service)
37- Active: inactive (dead)
38+ Active: %s (dead)
39 Docs: man:systemd-sysv-generator(8)
40- """) % (service.service_name, service.service_name)
41+ """) % (
42+ service.service_name, service.service_name,
43+ random.choice(['inactive', 'deactivating']))
44
45 mock_execSystemDServiceAction = self.patch(
46 service_monitor, "_execSystemDServiceAction")
47@@ -701,9 +703,11 @@ class TestServiceMonitor(MAASTestCase):
48 systemd_status_output = dedent("""\
49 %s.service - Fake service
50 Loaded: loaded (/lib/systemd/system/%s.service; ...
51- Active: failed (Result: exit-code) since Wed 2016-01-20...
52+ Active: %s (Result: exit-code) since Wed 2016-01-20...
53 Docs: man:dhcpd(8)
54- """) % (service.service_name, service.service_name)
55+ """) % (
56+ service.service_name, service.service_name,
57+ random.choice(['reloading', 'failed', 'activating']))
58
59 mock_execSystemDServiceAction = self.patch(
60 service_monitor, "_execSystemDServiceAction")

Subscribers

People subscribed via source and target branches