Merge lp:~makyo/juju-deployer/new-bundle-format into lp:juju-deployer

Proposed by Madison Scott-Clary
Status: Merged
Merged at revision: 137
Proposed branch: lp:~makyo/juju-deployer/new-bundle-format
Merge into: lp:juju-deployer
Diff against target: 124 lines (+63/-2)
4 files modified
.bzrignore (+2/-0)
deployer/config.py (+11/-2)
deployer/tests/test_config.py (+14/-0)
deployer/tests/test_data/blog_v4.yaml (+36/-0)
To merge this branch: bzr merge lp:~makyo/juju-deployer/new-bundle-format
Reviewer Review Type Date Requested Status
David Britton (community) Approve
Richard Harding (community) Approve
j.c.sackett (community) Approve
Francesco Banconi Pending
Review via email: mp+250500@code.launchpad.net

Description of the change

Support the new v4 bundle format, first iteration. This supports bundles without the top-level yaml tag - next iteration will support machine placement directives.

To QA:

- tests should pass
- run `PYTHONPATH=. python deployer/cli.py -c deployer/tests/test_data/blog_v4.yaml` to deploy a sample v4 bundle to a bootstrapped environment.

To post a comment you must log in.
Revision history for this message
j.c.sackett (jcsackett) wrote :

Code looks good. QAing now.

Revision history for this message
j.c.sackett (jcsackett) wrote :

QA OK. Thanks for this, Madison.

review: Approve
138. By Madison Scott-Clary

Simplify gets

Revision history for this message
Kapil Thangavelu (hazmat) :
Revision history for this message
Kapil Thangavelu (hazmat) wrote :

more inline comments

139. By Madison Scott-Clary

Simplify version checking; test that _resolve_inherited is not called

Revision history for this message
Richard Harding (rharding) wrote :

+1 with the comments from kapil on the missing test and more pythonic detection.

Kapil, I'd prefer to get your ok on the fingerprinting vs a version defined in the file itself as we're only talking the first 'versioning' going on here and it's a pretty light diff by just not allowing multiple bundles to be defined in the single file (thus the raising of services to the root vs under a name).

Is there another big reason for the explicit versioning in the yaml?

review: Approve
Revision history for this message
Kapil Thangavelu (hazmat) wrote :
Download full text (5.2 KiB)

On Mon, Feb 23, 2015 at 3:29 PM, Richard Harding <<email address hidden>
> wrote:

> Review: Approve
>
> +1 with the comments from kapil on the missing test and more pythonic
> detection.
>
> Kapil, I'd prefer to get your ok on the fingerprinting vs a version
> defined in the file itself as we're only talking the first 'versioning'
> going on here and it's a pretty light diff by just not allowing multiple
> bundles to be defined in the single file (thus the raising of services to
> the root vs under a name).
>
> Is there another big reason for the explicit versioning in the yaml?
>

because there are other format changes inbound, say we add 'machines' or
other variants, .. i'd rather not have a morass of implicit checks vs an
explicit version.

>
> Diff comments:
>
> > === modified file '.bzrignore'
> > --- .bzrignore 2013-12-18 09:52:33 +0000
> > +++ .bzrignore 2015-02-20 19:52:56 +0000
> > @@ -10,3 +10,5 @@
> > juju-deployer
> > juju-deployer.sublime-workspace
> > tmp
> > +report/
> > +.coverage
> >
> > === modified file 'deployer/config.py'
> > --- deployer/config.py 2014-08-28 20:14:01 +0000
> > +++ deployer/config.py 2015-02-20 19:52:56 +0000
> > @@ -19,6 +19,7 @@
> > def __init__(self, config_files, cli_series=None):
> > self.config_files = config_files
> > self.cli_series = cli_series
> > + self.version = 3
> > self.data = {}
> > self.yaml = {}
> > self.include_dirs = []
> > @@ -42,13 +43,21 @@
> >
> > with open(config_file) as fh:
> > try:
> > - self.yaml[config_file] = yaml_load(fh.read())
> > + yaml_result = yaml_load(fh.read())
> > except Exception, e:
> > self.log.warning(
> > "Couldn't load config file @ %r, error: %s:%s",
> > config_file, type(e), e)
> > raise
> >
> > + # Check if this is a v4 bundle.
>
> Since bundles are often hand written relying on a field in them to
> determine the version seems like it'll lead to a less than ideal process,
> we'd want to guess in the case the version isn't present anyway.
>
> > + if yaml_result.get('services') is not None \
>
> +1 just check
>
> if 'services' in yaml_result:
>
> > + and yaml_result['services'].get('services') is None:
> > + self.version = 4
> > + yaml_result = {config_file: yaml_result}
> > +
> > + self.yaml[config_file] = yaml_result
> > +
> > return self.yaml[config_file]
> >
> > def keys(self):
> > @@ -60,7 +69,8 @@
> > key, ", ".join(self.keys()))
> > raise ErrorExit()
> > deploy_data = self.data[key]
> > - deploy_data = self._resolve_inherited(deploy_data)
> > + if self.version != 4:
> > + deploy_data = self._resolve_inherited(deploy_data)
> > if self.cli_series:
> > deploy_data['series'] = self.cli_series
> > return Deployment(
> >
> > === modified file 'deployer/tests/test_config.py'
> > --- deployer/tests/test_config.py 2014-01-23 15:02:57 +0000
> > ...

Read more...

Revision history for this message
Richard Harding (rharding) wrote :

> > Is there another big reason for the explicit versioning in the yaml?
> >
>
> because there are other format changes inbound, say we add 'machines' or
> other variants, .. i'd rather not have a morass of implicit checks vs an
> explicit version.

But adding a key like machines isn't a backwards incompatible change. I'd not think to increment the revision of the file based on a change like that.

140. By Madison Scott-Clary

Remove extra services check.

Revision history for this message
David Britton (dpb) wrote :

Merged with a couple extra test checks (that version was being set for old and new bundles)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2013-12-18 09:52:33 +0000
3+++ .bzrignore 2015-02-24 15:49:41 +0000
4@@ -10,3 +10,5 @@
5 juju-deployer
6 juju-deployer.sublime-workspace
7 tmp
8+report/
9+.coverage
10
11=== modified file 'deployer/config.py'
12--- deployer/config.py 2014-08-28 20:14:01 +0000
13+++ deployer/config.py 2015-02-24 15:49:41 +0000
14@@ -19,6 +19,7 @@
15 def __init__(self, config_files, cli_series=None):
16 self.config_files = config_files
17 self.cli_series = cli_series
18+ self.version = 3
19 self.data = {}
20 self.yaml = {}
21 self.include_dirs = []
22@@ -42,13 +43,20 @@
23
24 with open(config_file) as fh:
25 try:
26- self.yaml[config_file] = yaml_load(fh.read())
27+ yaml_result = yaml_load(fh.read())
28 except Exception, e:
29 self.log.warning(
30 "Couldn't load config file @ %r, error: %s:%s",
31 config_file, type(e), e)
32 raise
33
34+ # Check if this is a v4 bundle.
35+ if 'services' in yaml_result:
36+ self.version = 4
37+ yaml_result = {config_file: yaml_result}
38+
39+ self.yaml[config_file] = yaml_result
40+
41 return self.yaml[config_file]
42
43 def keys(self):
44@@ -60,7 +68,8 @@
45 key, ", ".join(self.keys()))
46 raise ErrorExit()
47 deploy_data = self.data[key]
48- deploy_data = self._resolve_inherited(deploy_data)
49+ if self.version != 4:
50+ deploy_data = self._resolve_inherited(deploy_data)
51 if self.cli_series:
52 deploy_data['series'] = self.cli_series
53 return Deployment(
54
55=== modified file 'deployer/tests/test_config.py'
56--- deployer/tests/test_config.py 2014-01-23 15:02:57 +0000
57+++ deployer/tests/test_config.py 2015-02-24 15:49:41 +0000
58@@ -1,4 +1,5 @@
59 import logging
60+import mock
61 import os
62 import tempfile
63 import yaml
64@@ -39,6 +40,19 @@
65 deployment = config.get("wordpress")
66 self.assertTrue(deployment)
67
68+ def test_config_v4(self):
69+ config = ConfigStack([
70+ os.path.join(self.test_data_dir, 'blog_v4.yaml')])
71+ config.load()
72+ self.assertEqual(
73+ config.keys(),
74+ [os.path.join(self.test_data_dir, 'blog_v4.yaml')])
75+ with mock.patch('deployer.config.ConfigStack._resolve_inherited') \
76+ as mock_resolve:
77+ deployment = config.get(config.keys()[0])
78+ self.assertTrue(deployment)
79+ self.assertFalse(mock_resolve.called)
80+
81 def test_config_include_file(self):
82 config = ConfigStack([
83 os.path.join(self.test_data_dir, "stack-includes.cfg")])
84
85=== added file 'deployer/tests/test_data/blog_v4.yaml'
86--- deployer/tests/test_data/blog_v4.yaml 1970-01-01 00:00:00 +0000
87+++ deployer/tests/test_data/blog_v4.yaml 2015-02-24 15:49:41 +0000
88@@ -0,0 +1,36 @@
89+services:
90+ mediawiki:
91+ charm: cs:precise/mediawiki-10
92+ num_units: 1
93+ options:
94+ debug: false
95+ name: Please set name of wiki
96+ skin: vector
97+ annotations:
98+ gui-x: "609"
99+ gui-y: "-15"
100+ mysql:
101+ charm: cs:precise/mysql-28
102+ num_units: 1
103+ options:
104+ binlog-format: MIXED
105+ block-size: 5
106+ dataset-size: 80%
107+ flavor: distro
108+ ha-bindiface: eth0
109+ ha-mcastport: 5411
110+ max-connections: -1
111+ preferred-storage-engine: InnoDB
112+ query-cache-size: -1
113+ query-cache-type: "OFF"
114+ rbd-name: mysql1
115+ tuning-level: safest
116+ vip_cidr: 24
117+ vip_iface: eth0
118+ annotations:
119+ gui-x: "610"
120+ gui-y: "255"
121+series: precise
122+relations:
123+- - mediawiki:db
124+ - mysql:db

Subscribers

People subscribed via source and target branches