Merge lp:~mthaddon/mojo/mojo-how-to-autodeploy into lp:mojo/mojo-specs
- mojo-how-to-autodeploy
- Merge into mojo-specs
Status: | Merged |
---|---|
Merged at revision: | 11 |
Proposed branch: | lp:~mthaddon/mojo/mojo-how-to-autodeploy |
Merge into: | lp:mojo/mojo-specs |
Diff against target: |
301 lines (+210/-0) 16 files modified
mojo-how-to/README (+7/-0) mojo-how-to/devel/build-desired-revno (+15/-0) mojo-how-to/devel/build-production-revno (+25/-0) mojo-how-to/devel/check_for_diff_production_desired_revno (+10/-0) mojo-how-to/devel/get_common_variables (+5/-0) mojo-how-to/devel/publish_revno (+10/-0) mojo-how-to/devel/store_desired_revno (+9/-0) mojo-how-to/devel/store_production_revno (+9/-0) mojo-how-to/manifests/check-autodeploy (+11/-0) mojo-how-to/manifests/perform-autodeploy (+15/-0) mojo-how-to/manifests/perform-autodeploy-unchecked (+16/-0) mojo-how-to/manifests/prepare-autodeploy (+13/-0) mojo-how-to/manifests/test-autodeploy (+36/-0) mojo-how-to/production/publish_revno (+10/-0) mojo-how-to/production/store_desired_revno (+9/-0) mojo-how-to/production/store_production_revno (+10/-0) |
To merge this branch: | bzr merge lp:~mthaddon/mojo/mojo-how-to-autodeploy |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Paul Collins | Approve | ||
Review via email: mp+273817@code.launchpad.net |
Commit message
Description of the change
Add autodeployment mechanisms for mojo-how-to. This will only address updating built content, not charm upgrades, which will need further work.
- 12. By Tom Haddon
-
Pull in the desired and production build revnos from common script
- 13. By Tom Haddon
-
We need to actually build the env with current production revno on CI first as part of test-autodeploy before updating it
- 14. By Tom Haddon
-
Use the correct option to get stdout for wget
- 15. By Tom Haddon
-
We need bzr as a builddep too
- 16. By Tom Haddon
-
Arithmetic expression for comparing revnos
- 17. By Tom Haddon
-
We need to collect before running store_desired_revno on CI because that tells us what revno to start with
- 18. By Tom Haddon
-
Create dummy secrets file as part of a step that will get run for auto-deploy
- 19. By Tom Haddon
-
Print what revnos we have
- 20. By Tom Haddon
-
We need to pass the BUILD_LABEL to our upload and update script in autodeploy otherwise it'll just overwrite mojo.tar
- 21. By Tom Haddon
-
Print what revno we are publishing
- 22. By Tom Haddon
-
Also print what we're publishing in production
Tom Haddon (mthaddon) wrote : | # |
- 23. By Tom Haddon
-
Missing config from check-autodeploy
- 24. By Tom Haddon
-
Make sure we have the correct builddeps for performing the autodeploy
- 25. By Tom Haddon
-
We need to pass the packages variable, not config to builddeps
Tom Haddon (mthaddon) wrote : | # |
And this has now been tested on production as well. Successfully performed the rollout, and then exited with "Production is on 206 and the desired revno is 206. Nothing to do, exiting..." when rerun.
- 26. By Tom Haddon
-
Add a comment when we've autodeployed so we can more easily look for this and report on it
Paul Collins (pjdc) : | # |
Preview Diff
1 | === modified file 'mojo-how-to/README' | |||
2 | --- mojo-how-to/README 2015-05-07 14:11:05 +0000 | |||
3 | +++ mojo-how-to/README 2015-10-12 10:20:25 +0000 | |||
4 | @@ -20,3 +20,10 @@ | |||
5 | 20 | ksplice: | 20 | ksplice: |
6 | 21 | options: | 21 | options: |
7 | 22 | access-key: $YOUR_KSPLICE_ACCESS_KEY | 22 | access-key: $YOUR_KSPLICE_ACCESS_KEY |
8 | 23 | |||
9 | 24 | |||
10 | 25 | If you are using the autodeploy manifests, you will also need the following in | ||
11 | 26 | a secrets file called "autodeploy-secrets": | ||
12 | 27 | |||
13 | 28 | CI_SWIFT_CONTAINER=URL_OF_SWIFT_CONTAINER | ||
14 | 29 | PROD_SWIFT_CONTAINER=URL_OF_SWIFT_CONTAINER | ||
15 | 23 | 30 | ||
16 | === added file 'mojo-how-to/devel/build-desired-revno' | |||
17 | --- mojo-how-to/devel/build-desired-revno 1970-01-01 00:00:00 +0000 | |||
18 | +++ mojo-how-to/devel/build-desired-revno 2015-10-12 10:20:25 +0000 | |||
19 | @@ -0,0 +1,15 @@ | |||
20 | 1 | #!/bin/bash | ||
21 | 2 | |||
22 | 3 | # Script to generate docs from Mojo source tree | ||
23 | 4 | |||
24 | 5 | set -e | ||
25 | 6 | set -u | ||
26 | 7 | |||
27 | 8 | source ${MOJO_SPEC_DIR}/${MOJO_STAGE}/get_common_variables | ||
28 | 9 | |||
29 | 10 | cd ${MOJO_BUILD_DIR}/mojo | ||
30 | 11 | |||
31 | 12 | bzr pull -r $DESIRED_REVNO --overwrite . | ||
32 | 13 | |||
33 | 14 | make generate-docs | ||
34 | 15 | tar cvpf ${MOJO_LOCAL_DIR}/mojo.tar --directory=docs/www . | ||
35 | 0 | 16 | ||
36 | === added file 'mojo-how-to/devel/build-production-revno' | |||
37 | --- mojo-how-to/devel/build-production-revno 1970-01-01 00:00:00 +0000 | |||
38 | +++ mojo-how-to/devel/build-production-revno 2015-10-12 10:20:25 +0000 | |||
39 | @@ -0,0 +1,25 @@ | |||
40 | 1 | #!/bin/bash | ||
41 | 2 | |||
42 | 3 | # Script to generate docs from Mojo source tree | ||
43 | 4 | |||
44 | 5 | set -e | ||
45 | 6 | set -u | ||
46 | 7 | |||
47 | 8 | source ${MOJO_SPEC_DIR}/${MOJO_STAGE}/get_common_variables | ||
48 | 9 | |||
49 | 10 | cd ${MOJO_BUILD_DIR}/mojo | ||
50 | 11 | |||
51 | 12 | bzr pull -r $PRODUCTION_REVNO --overwrite . | ||
52 | 13 | |||
53 | 14 | make generate-docs | ||
54 | 15 | tar cvpf ${MOJO_LOCAL_DIR}/mojo.tar --directory=docs/www . | ||
55 | 16 | |||
56 | 17 | if [ ${MOJO_STAGE##*/} != "production" ]; then | ||
57 | 18 | # We don't deploy landscape in non-production environments, but we need a | ||
58 | 19 | # dummy secrets file | ||
59 | 20 | echo "Creating dummy services-secret file in ${MOJO_LOCAL_DIR}" | ||
60 | 21 | echo "mojo-how-to: | ||
61 | 22 | services: | ||
62 | 23 | nrpe: | ||
63 | 24 | charm: nrpe-external-master" > ${MOJO_LOCAL_DIR}/services-secret | ||
64 | 25 | fi | ||
65 | 0 | 26 | ||
66 | === added file 'mojo-how-to/devel/check_for_diff_production_desired_revno' | |||
67 | --- mojo-how-to/devel/check_for_diff_production_desired_revno 1970-01-01 00:00:00 +0000 | |||
68 | +++ mojo-how-to/devel/check_for_diff_production_desired_revno 2015-10-12 10:20:25 +0000 | |||
69 | @@ -0,0 +1,10 @@ | |||
70 | 1 | #!/bin/bash | ||
71 | 2 | |||
72 | 3 | source ${MOJO_SPEC_DIR}/${MOJO_STAGE}/get_common_variables | ||
73 | 4 | |||
74 | 5 | if [[ $PRODUCTION_REVNO -ge $DESIRED_REVNO ]]; then | ||
75 | 6 | echo "Production is on ${PRODUCTION_REVNO} and the desired revno is ${DESIRED_REVNO}. Nothing to do, exiting..." | ||
76 | 7 | exit 1 | ||
77 | 8 | fi | ||
78 | 9 | |||
79 | 10 | echo "Production is on ${PRODUCTION_REVNO} and the desired revno is ${DESIRED_REVNO}" | ||
80 | 0 | 11 | ||
81 | === added file 'mojo-how-to/devel/get_common_variables' | |||
82 | --- mojo-how-to/devel/get_common_variables 1970-01-01 00:00:00 +0000 | |||
83 | +++ mojo-how-to/devel/get_common_variables 2015-10-12 10:20:25 +0000 | |||
84 | @@ -0,0 +1,5 @@ | |||
85 | 1 | #!/bin/bash | ||
86 | 2 | |||
87 | 3 | # Source variables used by other scripts | ||
88 | 4 | PRODUCTION_REVNO=$(cat ${MOJO_LOCAL_DIR}/production_revno) | ||
89 | 5 | DESIRED_REVNO=$(cat ${MOJO_LOCAL_DIR}/desired_revno) | ||
90 | 0 | 6 | ||
91 | === added file 'mojo-how-to/devel/publish_revno' | |||
92 | --- mojo-how-to/devel/publish_revno 1970-01-01 00:00:00 +0000 | |||
93 | +++ mojo-how-to/devel/publish_revno 2015-10-12 10:20:25 +0000 | |||
94 | @@ -0,0 +1,10 @@ | |||
95 | 1 | #!/bin/bash | ||
96 | 2 | |||
97 | 3 | source ${MOJO_SPEC_DIR}/${MOJO_STAGE}/get_common_variables | ||
98 | 4 | |||
99 | 5 | echo $DESIRED_REVNO > ${MOJO_LOCAL_DIR}/tested_revno | ||
100 | 6 | |||
101 | 7 | echo "Publishing $DESIRED_REVNO as tested_revno" | ||
102 | 8 | |||
103 | 9 | cd ${MOJO_LOCAL_DIR} | ||
104 | 10 | swift upload mojo-how-to-autodeploy tested_revno | ||
105 | 0 | 11 | ||
106 | === added file 'mojo-how-to/devel/store_desired_revno' | |||
107 | --- mojo-how-to/devel/store_desired_revno 1970-01-01 00:00:00 +0000 | |||
108 | +++ mojo-how-to/devel/store_desired_revno 2015-10-12 10:20:25 +0000 | |||
109 | @@ -0,0 +1,9 @@ | |||
110 | 1 | #!/bin/bash | ||
111 | 2 | |||
112 | 3 | # Store the desired revno we want to upgrade to. In our case this is going to | ||
113 | 4 | # be the current tip of trunk whenever we run this script, which will have been | ||
114 | 5 | # collected already, so we can just query the revno. | ||
115 | 6 | |||
116 | 7 | DESIRED_REVNO=$(bzr revno ${MOJO_BUILD_DIR}/mojo) | ||
117 | 8 | |||
118 | 9 | echo $DESIRED_REVNO > ${MOJO_LOCAL_DIR}/desired_revno | ||
119 | 0 | 10 | ||
120 | === added file 'mojo-how-to/devel/store_production_revno' | |||
121 | --- mojo-how-to/devel/store_production_revno 1970-01-01 00:00:00 +0000 | |||
122 | +++ mojo-how-to/devel/store_production_revno 2015-10-12 10:20:25 +0000 | |||
123 | @@ -0,0 +1,9 @@ | |||
124 | 1 | #!/bin/bash | ||
125 | 2 | |||
126 | 3 | # Store the current revno used on production (grab from production swift | ||
127 | 4 | # container) | ||
128 | 5 | |||
129 | 6 | . ${MOJO_LOCAL_DIR}/autodeploy-secrets | ||
130 | 7 | PRODUCTION_REVNO=$(wget -q -O- ${PROD_SWIFT_CONTAINER}/production_revno) | ||
131 | 8 | |||
132 | 9 | echo $PRODUCTION_REVNO > ${MOJO_LOCAL_DIR}/production_revno | ||
133 | 0 | 10 | ||
134 | === added directory 'mojo-how-to/manifests' | |||
135 | === added file 'mojo-how-to/manifests/check-autodeploy' | |||
136 | --- mojo-how-to/manifests/check-autodeploy 1970-01-01 00:00:00 +0000 | |||
137 | +++ mojo-how-to/manifests/check-autodeploy 2015-10-12 10:20:25 +0000 | |||
138 | @@ -0,0 +1,11 @@ | |||
139 | 1 | ## This manifest should invoke prepare-autodeploy and then verify that the | ||
140 | 2 | ## proposed deployment can be done. This is usually done by invoking | ||
141 | 3 | ## utils/confirm-autodeployable, which will check that the current spec revno has | ||
142 | 4 | ## successfully been used in ci.admin and that the requested build label has been | ||
143 | 5 | ## tested. This manifest may also perhaps run a verify phase to ensure the | ||
144 | 6 | ## environment is healthy. This manifest is usually invoked by | ||
145 | 7 | ## deploy-from-blessed-branch. | ||
146 | 8 | |||
147 | 9 | include config=manifests/prepare-autodeploy | ||
148 | 10 | |||
149 | 11 | include config=manifest-verify | ||
150 | 0 | 12 | ||
151 | === added file 'mojo-how-to/manifests/perform-autodeploy' | |||
152 | --- mojo-how-to/manifests/perform-autodeploy 1970-01-01 00:00:00 +0000 | |||
153 | +++ mojo-how-to/manifests/perform-autodeploy 2015-10-12 10:20:25 +0000 | |||
154 | @@ -0,0 +1,15 @@ | |||
155 | 1 | ## This manifest should invoke check-autodeploy to ensure the deployment can be | ||
156 | 2 | ## done, and then perform the deployment, most preferably by invoking | ||
157 | 3 | ## perform-autodeploy-unchecked. The manifest may invoke database | ||
158 | 4 | ## migrations, if necessary and should also verify that the deployment was | ||
159 | 5 | ## successful. This manifest is usually invoked by deploy-from-blessed-branch. | ||
160 | 6 | |||
161 | 7 | include config=manifests/check-autodeploy | ||
162 | 8 | include config=manifests/perform-autodeploy-unchecked | ||
163 | 9 | include config=manifest-verify | ||
164 | 10 | |||
165 | 11 | script config=publish_revno | ||
166 | 12 | |||
167 | 13 | ## And now just print a comment that we've successfully auto-deployed so it's | ||
168 | 14 | ## easier to report on that | ||
169 | 15 | # Successfully auto-deployed new code for mojo-how-to | ||
170 | 0 | 16 | ||
171 | === added file 'mojo-how-to/manifests/perform-autodeploy-unchecked' | |||
172 | --- mojo-how-to/manifests/perform-autodeploy-unchecked 1970-01-01 00:00:00 +0000 | |||
173 | +++ mojo-how-to/manifests/perform-autodeploy-unchecked 2015-10-12 10:20:25 +0000 | |||
174 | @@ -0,0 +1,16 @@ | |||
175 | 1 | ## This manifest should perform the "meat" of the autodeploy, *without* | ||
176 | 2 | ## checking whether or not do so. In general this manifest is invoked by | ||
177 | 3 | ## perform-autodeploy (below) and by test-autodeploy (further below). | ||
178 | 4 | |||
179 | 5 | # Pull down the latest content | ||
180 | 6 | collect | ||
181 | 7 | # Set builddeps | ||
182 | 8 | builddeps packages=make,markdown,bzr | ||
183 | 9 | # Run the build step | ||
184 | 10 | build config=build-desired-revno | ||
185 | 11 | # Copy our built resources to the instances | ||
186 | 12 | script config=upload-built-content BUILD_LABEL=revno | ||
187 | 13 | # Update the config variable so our content is updated | ||
188 | 14 | script config=update-content BUILD_LABEL=revno | ||
189 | 15 | # Sleep to let the update be applied | ||
190 | 16 | sleep config=60 | ||
191 | 0 | 17 | ||
192 | === added file 'mojo-how-to/manifests/prepare-autodeploy' | |||
193 | --- mojo-how-to/manifests/prepare-autodeploy 1970-01-01 00:00:00 +0000 | |||
194 | +++ mojo-how-to/manifests/prepare-autodeploy 2015-10-12 10:20:25 +0000 | |||
195 | @@ -0,0 +1,13 @@ | |||
196 | 1 | ## This manifest should prepare the workspace for a deployment test or | ||
197 | 2 | ## autodeploy. Tasks commonly performed here are storing the build label to be | ||
198 | 3 | ## deployed and fetching and storing the currently-live build label from the | ||
199 | 4 | ## production environment or elsewhere (but ideally the former). This manifest | ||
200 | 5 | ## exists in particular so that the build label to be deployed is specified in one | ||
201 | 6 | ## and only one location. | ||
202 | 7 | |||
203 | 8 | script config=store_production_revno | ||
204 | 9 | collect | ||
205 | 10 | script config=store_desired_revno | ||
206 | 11 | |||
207 | 12 | # Now check there's actually a rollout that we want to attempt | ||
208 | 13 | script config=check_for_diff_production_desired_revno | ||
209 | 0 | 14 | ||
210 | === added file 'mojo-how-to/manifests/test-autodeploy' | |||
211 | --- mojo-how-to/manifests/test-autodeploy 1970-01-01 00:00:00 +0000 | |||
212 | +++ mojo-how-to/manifests/test-autodeploy 2015-10-12 10:20:25 +0000 | |||
213 | @@ -0,0 +1,36 @@ | |||
214 | 1 | ## After invoking check-autodeploy-testable, this manifest should deploy an | ||
215 | 2 | ## environment to match the existing production environment and then upgrade to | ||
216 | 3 | ## the DESIRED BUILD LABEL, most preferably by invoking | ||
217 | 4 | ## perform-autodeploy-unchecked. Following the upgrade this manifest | ||
218 | 5 | ## should perform any verification needed, and then publish suitable objects to | ||
219 | 6 | ## the swift container recording the result. | ||
220 | 7 | |||
221 | 8 | # Get what revnos we're interested in for this deployment | ||
222 | 9 | include config=manifests/prepare-autodeploy | ||
223 | 10 | |||
224 | 11 | # Having confirmed there's a deployment to test, we first need to bring the | ||
225 | 12 | # environment up in it's current state on production | ||
226 | 13 | |||
227 | 14 | # We need the markdown package to be able to generate the docs for Mojo | ||
228 | 15 | builddeps packages=make,markdown,bzr | ||
229 | 16 | # Run the collect step | ||
230 | 17 | collect | ||
231 | 18 | # Run the build step | ||
232 | 19 | build config=build-production-revno | ||
233 | 20 | # Deploy services only | ||
234 | 21 | deploy config=services local=services-secret delay=0 | ||
235 | 22 | # Copy our built resources to the instances | ||
236 | 23 | script config=upload-built-content | ||
237 | 24 | # And now deploy relations as well | ||
238 | 25 | deploy config=relations | ||
239 | 26 | # Run verify steps | ||
240 | 27 | include config=manifest-verify | ||
241 | 28 | |||
242 | 29 | # Now perform the autodeploy | ||
243 | 30 | include config=manifests/perform-autodeploy-unchecked | ||
244 | 31 | |||
245 | 32 | # And verify our environment again | ||
246 | 33 | include config=manifest-verify | ||
247 | 34 | |||
248 | 35 | # Now publish the revno we've successfully rolled out | ||
249 | 36 | script config=publish_revno | ||
250 | 0 | 37 | ||
251 | === added symlink 'mojo-how-to/production/build-desired-revno' | |||
252 | === target is u'../devel/build-desired-revno' | |||
253 | === added symlink 'mojo-how-to/production/build-production-revno' | |||
254 | === target is u'../devel/build-production-revno' | |||
255 | === added symlink 'mojo-how-to/production/check_for_diff_production_desired_revno' | |||
256 | === target is u'../devel/check_for_diff_production_desired_revno' | |||
257 | === added symlink 'mojo-how-to/production/get_common_variables' | |||
258 | === target is u'../devel/get_common_variables' | |||
259 | === added file 'mojo-how-to/production/publish_revno' | |||
260 | --- mojo-how-to/production/publish_revno 1970-01-01 00:00:00 +0000 | |||
261 | +++ mojo-how-to/production/publish_revno 2015-10-12 10:20:25 +0000 | |||
262 | @@ -0,0 +1,10 @@ | |||
263 | 1 | #!/bin/bash | ||
264 | 2 | |||
265 | 3 | source ${MOJO_SPEC_DIR}/${MOJO_STAGE}/get_common_variables | ||
266 | 4 | |||
267 | 5 | echo $DESIRED_REVNO > ${MOJO_LOCAL_DIR}/production_revno | ||
268 | 6 | |||
269 | 7 | echo "Publishing $DESIRED_REVNO as production_revno" | ||
270 | 8 | |||
271 | 9 | cd ${MOJO_LOCAL_DIR} | ||
272 | 10 | swift upload mojo-how-to-autodeploy production_revno | ||
273 | 0 | 11 | ||
274 | === added file 'mojo-how-to/production/store_desired_revno' | |||
275 | --- mojo-how-to/production/store_desired_revno 1970-01-01 00:00:00 +0000 | |||
276 | +++ mojo-how-to/production/store_desired_revno 2015-10-12 10:20:25 +0000 | |||
277 | @@ -0,0 +1,9 @@ | |||
278 | 1 | #!/bin/bash | ||
279 | 2 | |||
280 | 3 | # Store the desired revno we want to upgrade to. In our case this is going to | ||
281 | 4 | # be the revno that's been tested on CI. | ||
282 | 5 | |||
283 | 6 | . ${MOJO_LOCAL_DIR}/autodeploy-secrets | ||
284 | 7 | DESIRED_REVNO=$(wget -q -O- ${CI_SWIFT_CONTAINER}/tested_revno) | ||
285 | 8 | |||
286 | 9 | echo $DESIRED_REVNO > ${MOJO_LOCAL_DIR}/desired_revno | ||
287 | 0 | 10 | ||
288 | === added file 'mojo-how-to/production/store_production_revno' | |||
289 | --- mojo-how-to/production/store_production_revno 1970-01-01 00:00:00 +0000 | |||
290 | +++ mojo-how-to/production/store_production_revno 2015-10-12 10:20:25 +0000 | |||
291 | @@ -0,0 +1,10 @@ | |||
292 | 1 | #!/bin/bash | ||
293 | 2 | |||
294 | 3 | # Store the current revno used on production (grab from production swift | ||
295 | 4 | # container). Even though this is being run in the production stage, this is | ||
296 | 5 | # still the most reliable way of getting this. | ||
297 | 6 | |||
298 | 7 | . ${MOJO_LOCAL_DIR}/autodeploy-secrets | ||
299 | 8 | PRODUCTION_REVNO=$(wget -q -O- ${PROD_SWIFT_CONTAINER}/production_revno) | ||
300 | 9 | |||
301 | 10 | echo $PRODUCTION_REVNO > ${MOJO_LOCAL_DIR}/production_revno |
Ok, this has been tested on https:/ /ci.admin. canonical. com/job/ autodeploy- is-mojo- dot-canonical- dot-com/ - not yet tested the actually rollout portions on production though