Merge ~dannf/charms/+source/scalebot-jenkins:go-stop into ~ce-hyperscale/charms/+source/scalebot-jenkins:master

Proposed by dann frazier
Status: Merged
Merged at revision: 9f1e40ed3b4c54d8ceea9936acc968b6dbc836bc
Proposed branch: ~dannf/charms/+source/scalebot-jenkins:go-stop
Merge into: ~ce-hyperscale/charms/+source/scalebot-jenkins:master
Diff against target: 103 lines (+24/-6)
1 file modified
reactive/scalebot-jenkins.py (+24/-6)
Reviewer Review Type Date Requested Status
Taihsiang Ho Approve
dann frazier Pending
Review via email: mp+401253@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Taihsiang Ho (tai271828) wrote :

A cool feature we are looking forward to for a while :)

It's making sense to me to switch over to the "flag" API in the other merge proposal. This merge proposal is focusing on the introduction of "scalebot.go" and "scalebot.stop".

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/reactive/scalebot-jenkins.py b/reactive/scalebot-jenkins.py
2index a08e463..9a8a2b6 100644
3--- a/reactive/scalebot-jenkins.py
4+++ b/reactive/scalebot-jenkins.py
5@@ -22,6 +22,7 @@ from charms.reactive import (
6 hook,
7 when,
8 when_all,
9+ when_none,
10 when_not,
11 set_state,
12 get_flags,
13@@ -82,7 +83,7 @@ def scalebot_install_jjb_workaround():
14 set_state("scalebot.jjb.workaround.installed")
15
16
17-@when("extension.available")
18+@when_all("scalebot.go", "extension.available")
19 def configure_jenkins_jobbuilder(extension):
20 remove_state("scalebot.configured.jobbuilder")
21 status_set("maintenance", "Configuring JobBuilder")
22@@ -179,7 +180,7 @@ def scalebot_git_config_check():
23 return True
24
25
26-@when("apt.installed.git")
27+@when_all("scalebot.go", "apt.installed.git")
28 def scalebot_git_clone():
29 if not scalebot_git_config_check():
30 return
31@@ -244,7 +245,7 @@ def scalebot_git_clone():
32 remove_state("scalebot.repo.init")
33
34
35-@when_not("scalebot.repo.init")
36+@when_not("scalebot.repo.init", "scalebot.stop")
37 def scalebot_repo_init():
38 init_path = os.path.join(SCALEBOT_REPO, "scalebot.d", "init")
39 if os.path.exists(init_path):
40@@ -269,6 +270,7 @@ def scalebot_git_reconfig():
41 "scalebot.configured.repo",
42 "scalebot.configured.jobbuilder",
43 "scalebot.configured.juju",
44+ "scalebot.go",
45 )
46 def scalebot_ready():
47 status_set("active", "ScaleBot is Ready")
48@@ -279,6 +281,7 @@ def scalebot_ready():
49 "scalebot.configured.repo",
50 "scalebot.configured.jobbuilder",
51 "scalebot.configured.env",
52+ "scalebot.go",
53 "scalebot.jjb.workaround.installed",
54 "scalebot.jenkins-http-ready",
55 )
56@@ -306,7 +309,7 @@ def scalebot_juju_reconfig():
57 scalebot_configure_juju()
58
59
60-@when_all("apt.installed.juju")
61+@when_all("apt.installed.juju", "scalebot.go")
62 def scalebot_configure_juju():
63 config = hookenv.config()
64
65@@ -444,8 +447,22 @@ def scalebot_configure_juju_for_lab(clouds, creds, modeldefaults, bootstrapconst
66 set_state("scalebot.configured.juju")
67
68
69+@when_not("scalebot.stop")
70+def scalebot_start():
71+ set_state("scalebot.go")
72+
73+
74 @hook("stop")
75+def scalebot_stop():
76+ set_state("scalebot.stop")
77+ remove_state("scalebot.go")
78+ log("Stopping Scalebot.")
79+ status_set("maintenance", "Stopping ScaleBot")
80+
81+
82+@when("scalebot.stop")
83 def scalebot_juju_destroy_controller():
84+ status_set("maintenance", "Destroying Juju controller")
85 subprocess.run(
86 [
87 "/bin/su",
88@@ -492,13 +509,14 @@ println(lst.size());
89 """
90
91
92-@when_not("scalebot.configured.env")
93+@when_none("scalebot.configured.env", "scalebot.stop")
94 @when_all(
95+ "scalebot.go",
96 "scalebot.jenkins-http-ready",
97 "scalebot.jjb.workaround.installed",
98 "scalebot.written.env",
99 )
100-@when("extension.available")
101+@when_all("extension.available", "scalebot.go")
102 def safe_jenkins_service_restart(extension):
103 """Restart Jenkins service if no jobs are running.
104

Subscribers

People subscribed via source and target branches

to all changes: