Merge lp:~ahasenack/landscape-charm/new-bundle-render into lp:~landscape/landscape-charm/bundles-stable

Proposed by Andreas Hasenack
Status: Merged
Approved by: Andreas Hasenack
Approved revision: 25
Merged at revision: 17
Proposed branch: lp:~ahasenack/landscape-charm/new-bundle-render
Merge into: lp:~landscape/landscape-charm/bundles-stable
Diff against target: 466 lines (+182/-207)
9 files modified
.bzrignore (+1/-0)
Makefile (+21/-10)
charm-store (+68/-21)
landscape-dense-maas.yaml (+0/-59)
landscape-dense.yaml (+0/-59)
landscape-scalable.yaml (+0/-49)
render-bundles (+25/-4)
ubuntu-deps (+62/-0)
update-charm-revisions (+5/-5)
To merge this branch: bzr merge lp:~ahasenack/landscape-charm/new-bundle-render
Reviewer Review Type Date Requested Status
Francis Ginther (community) Approve
🤖 Landscape Builder test results Approve
Ursula Junque (community) Approve
Review via email: mp+300891@code.launchpad.net

Commit message

Sync bundle generation with what we have in bundles-trunk so that both produce the same set of files and directories. The content is still the same as it was before this branch.

Description of the change

Sync bundle generation with what we have in bundles-trunk so that both produce the same set of files and directories. The bundle content is still the same as it was before this branch.

I also added a small fix to the diff script so that it ignores the bundles.yaml (note the plural) file which is not used and is just an artifact of the charm store.

The diff is a bit big, here is what I did:
- merged with bundles-trunk
- removed the individual non-template yaml files representing each bundle: there are now generated and not part of the branch
- added --exclude bundles.yaml to the diff action in the charm-store diff

Everything else is a result of the merge from bundles-trunk.

To test:
charm login
charm whoami (to verify login). You may have to login on jujucharms.com with a browser before for all this to work (known bug in the charm store)

export CHARM_STORE_USER=landscape
make diff-charm-store

Should show no diff, because the rendered bundles match what is in the charm store currently. The rendered bundles are in the build/ directory.

Another test you can do:
make update-charm-revisions
bzr diff landscape-template.jinja2

Should show charm revision updates, still for the trusty series.

Bump to xenial:
bzr revert (if you ran the test above)
export EXTRA_UPDATE_ARGUMENTS="--series xenial"
make update-charm-revisions
bzr diff landscape-template.jinja2

That should bump all bundles to xenial and latest charm revisions

I just didn't test the actual push and publish commands (makefile targets).

To post a comment you must log in.
19. By Andreas Hasenack

Keep trusty as the default

20. By Andreas Hasenack

Added the charm package to the ubuntu dependencies to install.

Revision history for this message
🤖 Landscape Builder (landscape-builder) :
review: Abstain (executing tests)
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

Command: make render
Result: Success
Revno: 20
Branch: lp:~ahasenack/landscape-charm/new-bundle-render
Jenkins: https://ci.lscape.net/job/latch-test/5506/

review: Approve (test results)
21. By Andreas Hasenack

 - add the juju stable ppa if on trusty, because the charm tool isn't available
   on trusty proper.
 - run apt-get update if we decided we need to install something.

Revision history for this message
🤖 Landscape Builder (landscape-builder) :
review: Abstain (executing tests)
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

Command: make render
Result: Success
Revno: 21
Branch: lp:~ahasenack/landscape-charm/new-bundle-render
Jenkins: https://ci.lscape.net/job/latch-test/5507/

review: Approve (test results)
22. By Andreas Hasenack

Added python3-yaml to ubuntu-deps.

23. By Andreas Hasenack

Depend on deps in update-charm-revisions makefile target.

24. By Andreas Hasenack

We don't have apache2, juju-gui or nfs in our bundle anymore, so remove them from the update list.

Revision history for this message
Francis Ginther (fginther) wrote :

Please remove the push-charm-store and publish-charm-store makefile targets as the don't appear to be needed hear and removes the risk of someone accidentally using them to publish a test version of our bundles.

Otherwise looks good.

review: Approve
Revision history for this message
Francis Ginther (fginther) wrote :

Ooops, wrong state.

review: Needs Fixing
Revision history for this message
🤖 Landscape Builder (landscape-builder) :
review: Abstain (executing tests)
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

Command: make render
Result: Success
Revno: 24
Branch: lp:~ahasenack/landscape-charm/new-bundle-render
Jenkins: https://ci.lscape.net/job/latch-test/5509/

review: Approve (test results)
Revision history for this message
Ursula Junque (ursinha) wrote :

After all dependencies were fixed it's working fine. It's just odd that when I bump to xenial it changes haproxy charm to a precise one: https://pastebin.canonical.com/161523/. If that's expected and you address fginther's comments then +1.

review: Approve
25. By Andreas Hasenack

Fallback to trusty charms, not precise.

Revision history for this message
🤖 Landscape Builder (landscape-builder) :
review: Abstain (executing tests)
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

Command: make render
Result: Success
Revno: 25
Branch: lp:~ahasenack/landscape-charm/new-bundle-render
Jenkins: https://ci.lscape.net/job/latch-test/5510/

review: Approve (test results)
Revision history for this message
Francis Ginther (fginther) wrote :

Disregard my comment. Approve.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '.bzrignore'
2--- .bzrignore 1970-01-01 00:00:00 +0000
3+++ .bzrignore 2016-07-22 15:12:19 +0000
4@@ -0,0 +1,1 @@
5+build
6
7=== modified file 'Makefile'
8--- Makefile 2016-02-09 18:14:40 +0000
9+++ Makefile 2016-07-22 15:12:19 +0000
10@@ -1,18 +1,29 @@
11-compare-charm-store:
12- ./charm-store
13-
14-commit-charm-store:
15- CHARM_STORE_COMMIT=1 ./charm-store
16+diff-charm-store: check-env render
17+ ./charm-store diff $${CHARM_STORE_USER}
18+
19+push-charm-store: check-env render
20+ ./charm-store push $${CHARM_STORE_USER}
21+
22+publish-charm-store: check-env render
23+ ./charm-store publish-latest $${CHARM_STORE_USER}
24+
25+check-env:
26+ifndef CHARM_STORE_USER
27+ $(error CHARM_STORE_USER is undefined, hint: launchpad id.)
28+endif
29
30 clean:
31 @rm -rf build
32
33-render:
34+render: deps clean
35 @./render-bundles
36
37-update-charm-revisions:
38+update-charm-revisions: deps
39 @./update-charm-revisions \
40 $(EXTRA_UPDATE_ARGUMENTS) \
41- apache2 postgresql juju-gui haproxy rabbitmq-server nfs
42-
43-.PHONY: clean render commit-charm-store update-charm-revisions compare-charm-store
44+ postgresql haproxy rabbitmq-server
45+
46+deps:
47+ @./ubuntu-deps
48+
49+.PHONY: clean render commit-charm-store update-charm-revisions compare-charm-store deps
50
51=== modified file 'charm-store'
52--- charm-store 2016-04-07 21:39:46 +0000
53+++ charm-store 2016-07-22 15:12:19 +0000
54@@ -1,23 +1,70 @@
55 #!/bin/bash -e
56-
57-COMMIT=${CHARM_STORE_COMMIT:-}
58-
59-for i in *.yaml; do
60- revno=$(bzr revno)
61- target=$(basename $i .yaml)
62- if [ -e build/$target ]; then
63- echo "build/$target exists, please remove before continuing (make clean)"
64- exit 1
65- fi
66- mkdir -p build
67- bzr co lp:~landscape/charms/bundles/$target/bundle build/$target
68- cp $target.yaml build/$target/bundle.yaml
69- cp README.md build/$target/README.md
70- if [ "$COMMIT" == "" ]; then
71- echo "Diff from Charm Store: $target"
72- (cd build/$target && bzr diff) || /bin/true
73- else
74- echo "Committing to Charm Store: $target"
75- (cd build/$target && bzr commit -m "$COMMIT (stable: r$revno)")
76- fi
77+#
78+# Mostly intended to be called with make targets
79+# Needs make clean, make render called first.
80+#
81+
82+ACTION=$1
83+STORE_USER=${2:-landscape}
84+
85+if [ -z "$ACTION" ]; then
86+ cat <<EOF
87+Usage: $0 ACTION [user]
88+ actions:
89+ push - push to 'unpublished' channel
90+ publish-latest - publish the latest copy
91+ diff - diff your branch to the latest stable channel copy
92+ user:
93+ charm store user name
94+EOF
95+ exit 1
96+fi
97+
98+if [ "$ACTION" == "push" ]; then
99+ echo "# Will be pushing new [unpublished] versions to the charm store"
100+ echo "# as user: $STORE_USER"
101+fi
102+
103+for target in landscape-dense-maas landscape-dense landscape-scalable; do
104+
105+ if [ "$ACTION" == "diff" ]; then
106+ echo "# [$target] Pulling fresh copy from stable channel"
107+ charm pull --channel stable "cs:~${STORE_USER}/bundle/${target}" build/${target}-stable
108+
109+ echo "# [$target] Diff from latest stable"
110+ diff -Naur --exclude bundles.yaml build/${target}-stable build/${target} || /bin/true
111+ fi
112+
113+ if [ "$ACTION" == "push" ]; then
114+ echo "# [$target] Pushing to namespace ~${STORE_USER}, unpublished channel"
115+ url=$(charm push build/${target} cs:~${STORE_USER}/bundle/${target} | grep ^url | awk '{ print $2 }')
116+
117+ echo "# [$target] Publishing to development channel"
118+ charm publish --channel development $url
119+ fi
120+
121+ if [ "$ACTION" == "publish-latest" ]; then
122+ latest=$(charm show --channel unpublished --format=json cs:~${STORE_USER}/bundle/${target} | jq -r '.["revision-info"].Revisions[0]')
123+ echo "# [$target] Publishing latest unpublished revision, stable channel"
124+ charm publish $latest
125+ fi
126+
127 done
128+
129+cat <<EOF
130+#
131+# You can manually examine things if you wish:"
132+# ll build/*"
133+# ll build/*-stable"
134+#
135+# Show details in the store:
136+# charm show [--channel unpublished] cs:~${STORE_USER}/bundle/landscape-dense-maas
137+#
138+# Make sure everyone can use your charm if you want:
139+# charm grant cs:~${STORE_USER}/bundle/BUNDLE_NAME-VERSION everyone
140+#
141+# Publish like this (controls what clients see by default, you can
142+# even set it to a previous known good version):
143+# charm publish cs:~${STORE_USER}/bundle/BUNDLE_NAME-VERSION
144+#
145+EOF
146
147=== removed file 'landscape-dense-maas.yaml'
148--- landscape-dense-maas.yaml 2016-07-21 19:53:48 +0000
149+++ landscape-dense-maas.yaml 1970-01-01 00:00:00 +0000
150@@ -1,59 +0,0 @@
151-series: trusty
152-services:
153- rabbitmq-server:
154- charm: cs:trusty/rabbitmq-server-43
155- to:
156- - lxc:0
157- num_units: 1
158- annotations:
159- "gui-x": "600"
160- "gui-y": "370"
161- postgresql:
162- charm: cs:trusty/postgresql-40
163- constraints: mem=2048
164- to:
165- - lxc:0
166- num_units: 1
167- options:
168- extra_packages: python-apt postgresql-contrib postgresql-.*-debversion postgresql-plpython-.*
169- max_connections: 500
170- max_prepared_transactions: 500
171- annotations:
172- "gui-x": "600"
173- "gui-y": "120"
174- haproxy:
175- charm: cs:trusty/haproxy-16
176- to:
177- - lxc:0
178- expose: True
179- num_units: 1
180- options:
181- enable_monitoring: True
182- monitoring_allowed_cidr: "0.0.0.0/0"
183- monitoring_password: "haproxy"
184- default_timeouts: "queue 60000, connect 5000, client 120000, server 120000"
185- # Don't deploy default haproxy service on port 80
186- services: ""
187- source: backports
188- ssl_cert: SELFSIGNED
189- annotations:
190- "gui-x": "1200"
191- "gui-y": "120"
192- landscape-server:
193- charm: cs:trusty/landscape-server
194- constraints: mem=2048
195- to:
196- - lxc:0
197- num_units: 1
198- options:
199- source: deb http://ppa.launchpad.net/landscape/16.06/ubuntu trusty main
200- key: 4652B4E6
201- annotations:
202- "gui-x": "950"
203- "gui-y": "120"
204-machines:
205- "0": {}
206-relations:
207- - [landscape-server, rabbitmq-server]
208- - [landscape-server, haproxy]
209- - ["landscape-server:db", "postgresql:db-admin"]
210
211=== removed file 'landscape-dense.yaml'
212--- landscape-dense.yaml 2016-07-21 19:53:48 +0000
213+++ landscape-dense.yaml 1970-01-01 00:00:00 +0000
214@@ -1,59 +0,0 @@
215-series: trusty
216-services:
217- rabbitmq-server:
218- charm: cs:trusty/rabbitmq-server-43
219- to:
220- - lxc:0
221- num_units: 1
222- annotations:
223- "gui-x": "600"
224- "gui-y": "370"
225- postgresql:
226- charm: cs:trusty/postgresql-40
227- constraints: mem=2048
228- to:
229- - lxc:0
230- num_units: 1
231- options:
232- extra_packages: python-apt postgresql-contrib postgresql-.*-debversion postgresql-plpython-.*
233- max_connections: 500
234- max_prepared_transactions: 500
235- annotations:
236- "gui-x": "600"
237- "gui-y": "120"
238- haproxy:
239- charm: cs:trusty/haproxy-16
240- to:
241- - 0
242- expose: True
243- num_units: 1
244- options:
245- enable_monitoring: True
246- monitoring_allowed_cidr: "0.0.0.0/0"
247- monitoring_password: "haproxy"
248- default_timeouts: "queue 60000, connect 5000, client 120000, server 120000"
249- # Don't deploy default haproxy service on port 80
250- services: ""
251- source: backports
252- ssl_cert: SELFSIGNED
253- annotations:
254- "gui-x": "1200"
255- "gui-y": "120"
256- landscape-server:
257- charm: cs:trusty/landscape-server
258- constraints: mem=2048
259- to:
260- - lxc:0
261- num_units: 1
262- options:
263- source: deb http://ppa.launchpad.net/landscape/16.06/ubuntu trusty main
264- key: 4652B4E6
265- annotations:
266- "gui-x": "950"
267- "gui-y": "120"
268-machines:
269- "0": {}
270-relations:
271- - [landscape-server, rabbitmq-server]
272- - [landscape-server, haproxy]
273- - ["landscape-server:db", "postgresql:db-admin"]
274
275=== removed file 'landscape-scalable.yaml'
276--- landscape-scalable.yaml 2016-07-21 19:53:48 +0000
277+++ landscape-scalable.yaml 1970-01-01 00:00:00 +0000
278@@ -1,49 +0,0 @@
279-series: trusty
280-services:
281- rabbitmq-server:
282- charm: cs:trusty/rabbitmq-server-43
283- num_units: 1
284- annotations:
285- "gui-x": "600"
286- "gui-y": "370"
287- postgresql:
288- charm: cs:trusty/postgresql-40
289- constraints: mem=2048
290- num_units: 1
291- options:
292- extra_packages: python-apt postgresql-contrib postgresql-.*-debversion postgresql-plpython-.*
293- max_connections: 500
294- max_prepared_transactions: 500
295- annotations:
296- "gui-x": "600"
297- "gui-y": "120"
298- haproxy:
299- charm: cs:trusty/haproxy-16
300- expose: True
301- num_units: 1
302- options:
303- enable_monitoring: True
304- monitoring_allowed_cidr: "0.0.0.0/0"
305- monitoring_password: "haproxy"
306- default_timeouts: "queue 60000, connect 5000, client 120000, server 120000"
307- # Don't deploy default haproxy service on port 80
308- services: ""
309- source: backports
310- ssl_cert: SELFSIGNED
311- annotations:
312- "gui-x": "1200"
313- "gui-y": "120"
314- landscape-server:
315- charm: cs:trusty/landscape-server
316- constraints: mem=2048
317- num_units: 1
318- options:
319- source: deb http://ppa.launchpad.net/landscape/16.06/ubuntu trusty main
320- key: 4652B4E6
321- annotations:
322- "gui-x": "950"
323- "gui-y": "120"
324-relations:
325- - [landscape-server, rabbitmq-server]
326- - [landscape-server, haproxy]
327- - ["landscape-server:db", "postgresql:db-admin"]
328
329=== modified file 'render-bundles'
330--- render-bundles 2016-07-21 19:53:48 +0000
331+++ render-bundles 2016-07-22 15:12:19 +0000
332@@ -1,6 +1,10 @@
333 #!/usr/bin/python3
334
335+"""Render the landscape-server bundles."""
336+
337+import argparse
338 import os
339+import shutil
340
341 from jinja2 import FileSystemLoader, Environment
342
343@@ -45,14 +49,31 @@
344 ]
345
346 if __name__ == "__main__":
347+ current_dir = os.path.dirname(__file__)
348+ parser = argparse.ArgumentParser(description=__doc__)
349+ parser.add_argument("--landscape-branch", type=str, required=False)
350+ parser.add_argument("--landscape-charm", type=str, required=False)
351+ args = parser.parse_args()
352 environment = Environment(
353- loader=FileSystemLoader("."), trim_blocks=True, lstrip_blocks=True,
354+ loader=FileSystemLoader(current_dir),
355+ trim_blocks=True, lstrip_blocks=True,
356 keep_trailing_newline=True)
357 template = environment.get_template("landscape-template.jinja2")
358 for flavor in FLAVORS:
359- with open("landscape-%s.yaml" % flavor["name"], "w") as fd:
360+ build_dir = os.path.join(current_dir, "build")
361+ path_parts = [build_dir, "landscape-%s" % flavor["name"]]
362+ os.makedirs(os.path.join(*path_parts))
363+ shutil.copy("README.md", os.path.join(*path_parts))
364+
365+ path_parts.append("bundle.yaml")
366+ with open(os.path.join(*path_parts), "w") as fd:
367 context = DEFAULTS.copy()
368+ for key in context:
369+ context[key].update(flavor.get(key, {}))
370 context["name"] = flavor["name"]
371- for key in DEFAULTS.keys():
372- context[key].update(flavor.get(key, {}))
373+ if args.landscape_charm:
374+ context["landscape"]["charm"] = args.landscape_charm
375+ if args.landscape_branch:
376+ context["landscape"]["branch"] = args.landscape_branch
377 fd.write(template.render(context))
378+ print("Generated bundles in {}/...".format(build_dir))
379
380=== added file 'ubuntu-deps'
381--- ubuntu-deps 1970-01-01 00:00:00 +0000
382+++ ubuntu-deps 2016-07-22 15:12:19 +0000
383@@ -0,0 +1,62 @@
384+#!/bin/bash -u
385+
386+set -u
387+
388+INTERACTIVE=0
389+tty -s && INTERACTIVE=1
390+
391+function apt_get() {
392+ local skip=0
393+
394+ # first check if this is necessary - we don't want to ask for sudo
395+ # unless we need it, since this is run from make build-devel
396+ output=$(apt-get -s $*)
397+ if [ $? -ne 0 ]; then
398+ echo "Error: Dependency simulation failed: $*"
399+ exit 1
400+ fi
401+
402+ # Check for any lines that start with Inst, which signifies
403+ # a package will be installed or upgraded
404+ echo "$output" | grep '^Inst ' > /dev/null || skip=1
405+
406+ if [ $skip -eq 1 ]; then
407+ echo " * Skipping: $*"
408+ return
409+ fi
410+
411+ release=$(lsb_release -cs)
412+ # needed for the "charm" tool
413+ if [ "$release" == "trusty" ]; then
414+ sudo add-apt-repository -y ppa:juju/stable
415+ fi
416+ sudo apt-get update
417+
418+ if [ $INTERACTIVE -eq 0 ]; then
419+ DEBIAN_FRONTEND=noninteractive sudo apt-get \
420+ -y --force-yes -o Dpkg::Options::='--force-confold' $*
421+ else
422+ sudo apt-get $*
423+ fi
424+
425+ if [ $? -ne 0 ]; then
426+ echo "Error: Package installation failed: $*"
427+ exit 1
428+ fi
429+}
430+
431+
432+function install_deps {
433+ apt_get install \
434+ python3-jinja2 \
435+ python3-yaml \
436+ jq \
437+ charm
438+}
439+
440+
441+# If running non-interactively, go ahead and apt-get update
442+# before we start, keeps jenkins slaves and the like updated
443+[ $INTERACTIVE -eq 0 ] && sudo apt-get update
444+
445+install_deps
446
447=== modified file 'update-charm-revisions'
448--- update-charm-revisions 2016-02-09 18:13:49 +0000
449+++ update-charm-revisions 2016-07-22 15:12:19 +0000
450@@ -36,13 +36,13 @@
451 try:
452 return Charm(charm_name, series)
453 except IOError as e:
454- if series != "precise":
455+ if series != "trusty":
456 try:
457- return Charm(charm_name, series="precise")
458- except IOError as precise_e:
459+ return Charm(charm_name, series="trusty")
460+ except IOError as trusty_e:
461 raise IOError(
462- "%s: not found? (even tried precise): {}, {}".format(
463- charm_name, e, precise_e))
464+ "%s: not found? (even tried trusty): {}, {}".format(
465+ charm_name, e, trusty_e))
466 raise
467
468

Subscribers

People subscribed via source and target branches

to all changes: