Merge lp:~kubernetes/charms/trusty/flannel-docker/trunk into lp:charms/trusty/flannel-docker

Proposed by Charles Butler
Status: Merged
Merged at revision: 12
Proposed branch: lp:~kubernetes/charms/trusty/flannel-docker/trunk
Merge into: lp:charms/trusty/flannel-docker
Diff against target: 267 lines (+103/-33)
13 files modified
Makefile (+17/-12)
README.md (+2/-0)
hooks/setup.py (+1/-1)
playbooks/flannel-configuration.yaml (+1/-1)
playbooks/install-or-upgrade.yaml (+1/-1)
playbooks/network-relation-changed.yaml (+5/-1)
pytest.ini (+2/-0)
scripts/etcd_rest.py (+20/-14)
scripts/parse_relation.py (+13/-0)
templates/upstart.template (+2/-2)
tests/10-deploy.py (+1/-1)
tests/tests.yaml (+3/-0)
tox.ini (+35/-0)
To merge this branch: bzr merge lp:~kubernetes/charms/trusty/flannel-docker/trunk
Reviewer Review Type Date Requested Status
Matt Bruzek (community) Approve
Review via email: mp+272232@code.launchpad.net

Description of the change

Includes a work-around python script to handle ansible raising an error when attempting to parse a non-existant array in the host_vars file.

Prior to this patch, the behavior of the charm was to enter error state if the network relation was not established before relating to etcd. This was problematic and made joining of relations very order-dependent.

This removes that requirement.

To post a comment you must log in.
9. By Charles Butler

Update testplan w/ implicit make targets clean and lint

Revision history for this message
Matt Bruzek (mbruzek) wrote :

The tests are successfull: PASS: 5 Total: 5 (778.300656 sec)

I do have one comment, that was not involved in this change. Please change the tests to use the recommended etcd charm rather than the namespaced one.

review: Approve
10. By Charles Butler

repoint etcd to charm-store resource

Revision history for this message
Matt Bruzek (mbruzek) wrote :

+1 LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2015-04-01 18:50:44 +0000
3+++ Makefile 2015-09-24 15:27:04 +0000
4@@ -1,18 +1,23 @@
5 #!/usr/bin/make
6
7-build: virtualenv lint
8-
9-virtualenv: .venv/bin/python
10-.venv/bin/python:
11+
12+build: tox lint test
13+
14+virtualenv:
15 virtualenv .venv
16- .venv/bin/pip install nose flake8 mock pyyaml charmhelpers ansible-lint ansible
17-
18-lint:.venv/bin/python
19- @echo Linting Charm
20- @charm proof
21- @echo Linting Ansible Routines
22- @.venv/bin/ansible-lint playbooks/*
23+
24+tox:
25+/usr/bin/tox:
26+ sudo apt-get install -y python-tox python-dev python-virtualenv
27+
28+lint: /usr/bin/tox
29+ tox -e lint
30+
31+
32+unit_test: /usr/bin/tox
33+ @# tox
34+ @echo "Unit tests pending"
35
36 clean:
37- rm -rf .venv
38+ rm -rf .venv .tox
39 find -name *.pyc -delete
40
41=== modified file 'README.md'
42--- README.md 2015-04-01 19:53:51 +0000
43+++ README.md 2015-09-24 15:27:04 +0000
44@@ -1,5 +1,7 @@
45 # Flannel (Docker Flavored)
46
47+[![Build Status](http://drone.systemzoo.org/api/badge/github.com/chuckbutler/flannel-docker-charm/status.svg?branch=master)](http://drone.systemzoo.org/github.com/chuckbutler/flannel-docker-charm)
48+
49 ### About Flannel
50 [Flannel](https://github.com/coreos/flannel) (originally rudder) is an overlay
51 network that gives a subnet to each machine for use with containers.
52
53=== modified file 'files/flannel.amd64.tar.gz'
54Binary files files/flannel.amd64.tar.gz 2015-01-16 23:34:13 +0000 and files/flannel.amd64.tar.gz 2015-09-24 15:27:04 +0000 differ
55=== modified file 'hooks/setup.py'
56--- hooks/setup.py 2015-01-16 23:34:13 +0000
57+++ hooks/setup.py 2015-09-24 15:27:04 +0000
58@@ -6,7 +6,7 @@
59 Do any setup required before the install hook.
60 """
61 install_charmhelpers()
62- #subprocess.check_call(['pip', 'install', 'path.py'])
63+ # subprocess.check_call(['pip', 'install', 'path.py'])
64
65
66 def install_charmhelpers():
67
68=== modified file 'playbooks/flannel-configuration.yaml'
69--- playbooks/flannel-configuration.yaml 2015-01-16 23:34:13 +0000
70+++ playbooks/flannel-configuration.yaml 2015-09-24 15:27:04 +0000
71@@ -22,7 +22,7 @@
72 when: etcd_joined == "True"
73
74 - name: Install Upstart Template for flannel
75- template: src={{ charm_dir }}/templates/flannel.conf
76+ template: src={{ charm_dir }}/templates/upstart.template
77 dest=/etc/init/flannel.conf
78 mode=0644
79 when: etcd_joined == "True"
80
81=== modified file 'playbooks/install-or-upgrade.yaml'
82--- playbooks/install-or-upgrade.yaml 2015-01-16 23:34:13 +0000
83+++ playbooks/install-or-upgrade.yaml 2015-09-24 15:27:04 +0000
84@@ -9,4 +9,4 @@
85 - name: Unpack the flannel binary
86 unarchive: src={{ charm_dir }}/files/flannel.amd64.tar.gz
87 dest=/usr/local/bin
88- creates=/usr/local/bin/flannel mode= 0755
89+ creates=/usr/local/bin/flannel mode='u=rx,g=rx,o=rx'
90
91=== modified file 'playbooks/network-relation-changed.yaml'
92--- playbooks/network-relation-changed.yaml 2015-05-21 15:00:11 +0000
93+++ playbooks/network-relation-changed.yaml 2015-09-24 15:27:04 +0000
94@@ -12,10 +12,14 @@
95 shell: cat /run/flannel/subnet.env | grep FLANNEL_MTU | cut -f2 -d"="
96 register: flannel_mtu
97
98+- name: Read network relation
99+ shell: "{{ charm_dir }}/scripts/parse_relation.py"
100+ register: network_id
101+
102 - set_fact:
103 flannel_mtu: "{{ flannel_mtu.stdout }}"
104 flannel_subnet: "{{ flannel_subnet.stdout }}"
105- scoped_network: "{{ relations.network[0].__relid__ | default('') }}"
106+ scoped_network: "{{ network_id.stdout | default('') }}"
107
108 - name: Send Data to Docker Host for bridge configuration
109 shell: relation-set -r {{ scoped_network }} flannel-subnet={{ flannel_subnet }} flannel-mtu={{ flannel_mtu }} overlay_type=udp
110
111=== added file 'pytest.ini'
112--- pytest.ini 1970-01-01 00:00:00 +0000
113+++ pytest.ini 2015-09-24 15:27:04 +0000
114@@ -0,0 +1,2 @@
115+[pytest]
116+addopts = --tb=short -s --cov=hooks --cov=modules --cov-report=term-missing
117
118=== modified file 'scripts/etcd_rest.py'
119--- scripts/etcd_rest.py 2015-01-16 23:34:13 +0000
120+++ scripts/etcd_rest.py 2015-09-24 15:27:04 +0000
121@@ -5,31 +5,37 @@
122 import json
123 import httplib
124 import argparse
125+import subprocess
126 import sys
127
128
129 def initialize_etcd(endpoint,
130 flannel_prefix="/coreos.com/network",
131 flannel_network="10.10.0.0/16"):
132-
133- parsed = urlparse.urlparse(endpoint)
134- params = urllib.urlencode(
135- {"value": json.dumps({'Network': flannel_network})})
136- headers = {'content-type': 'application/x-www-form-urlencoded'}
137- path = "/v2/keys%s/config" % flannel_prefix
138- conn = httplib.HTTPConnection(parsed.hostname, parsed.port)
139- conn.request("PUT", path, params, headers)
140- response = conn.getresponse()
141- data = json.loads(response.read())
142- print("Initialize Etcd Network %s %s" % (response.status, response.reason))
143- print(data)
144+ try:
145+ parsed = urlparse.urlparse(endpoint)
146+ params = urllib.urlencode(
147+ {"value": json.dumps({'Network': flannel_network})})
148+ headers = {'content-type': 'application/x-www-form-urlencoded'}
149+ path = "/v2/keys%s/config" % flannel_prefix
150+ conn = httplib.HTTPConnection(parsed.hostname, parsed.port)
151+ conn.request("PUT", path, params, headers)
152+ response = conn.getresponse()
153+ data = json.loads(response.read())
154+ print("Initialize Etcd Network %s %s" % (response.status,
155+ response.reason))
156+ print(data)
157+ except:
158+ msg = "Unable to register with ETCD. Flannel not configured"
159+ cmd = ['status-set', 'blocked', msg]
160+ subprocess.call(cmd)
161+ return 0
162
163
164 def main(args=sys.argv[1:]):
165 parser = argparse.ArgumentParser(description="stuff")
166 parser.add_argument("endpoint")
167-
168- args= parser.parse_args(args)
169+ args = parser.parse_args(args)
170 initialize_etcd(args.endpoint)
171
172
173
174=== added file 'scripts/parse_relation.py'
175--- scripts/parse_relation.py 1970-01-01 00:00:00 +0000
176+++ scripts/parse_relation.py 2015-09-24 15:27:04 +0000
177@@ -0,0 +1,13 @@
178+#!/usr/bin/python
179+
180+import yaml
181+
182+path='/etc/ansible/host_vars/localhost'
183+
184+with open(path, 'r') as f:
185+ data = yaml.safe_load(f)
186+
187+try:
188+ print data['relations']['network'][0]['__relid__']
189+except:
190+ pass
191
192=== modified file 'templates/upstart.template'
193--- templates/upstart.template 2015-01-16 23:34:13 +0000
194+++ templates/upstart.template 2015-09-24 15:27:04 +0000
195@@ -1,8 +1,8 @@
196 description "Flannel Overlay Network"
197-maintainer "Charles Butler <charles.butler@ubuntu.com>"
198+#maintainer "Charles Butler <charles.butler@ubuntu.com>"
199
200 start on runlevel [2345]
201 stop on runlevel [!2345]
202
203-exec /usr/local/bin/flannel -v=1 -ip-masq=true -etcd-endpoint=http://{{ etcd_ip}}:{{ etcd_ip }} -logtostderr=true
204+exec /usr/local/bin/flannel -v=1 -ip-masq=true -etcd-endpoints=http://{{ etcd_ip}}:{{ etcd_port }} -logtostderr=true
205
206
207=== modified file 'tests/10-deploy.py'
208--- tests/10-deploy.py 2015-04-02 14:04:59 +0000
209+++ tests/10-deploy.py 2015-09-24 15:27:04 +0000
210@@ -21,7 +21,7 @@
211
212 cls.deployment.add('docker', 'cs:trusty/docker')
213 cls.deployment.add('flannel-docker')
214- cls.deployment.add('etcd', 'cs:~kubernetes/trusty/etcd')
215+ cls.deployment.add('etcd', 'cs:trusty/etcd')
216
217 cls.deployment.configure('docker', {})
218 cls.deployment.configure('etcd', {})
219
220=== modified file 'tests/tests.yaml'
221--- tests/tests.yaml 2015-04-02 14:04:59 +0000
222+++ tests/tests.yaml 2015-09-24 15:27:04 +0000
223@@ -1,1 +1,4 @@
224 virtualenv: False
225+makefile:
226+ - clean
227+ - lint
228
229=== added file 'tox.ini'
230--- tox.ini 1970-01-01 00:00:00 +0000
231+++ tox.ini 2015-09-24 15:27:04 +0000
232@@ -0,0 +1,35 @@
233+[tox]
234+envlist = py27
235+skipsdist = True
236+
237+[testenv]
238+install_command = pip install {opts} --pre --use-wheel {packages}
239+deps =
240+ pytest
241+ pytest-cov
242+ pytest-capturelog
243+ mock
244+ charmhelpers
245+ pyyaml
246+ ansible
247+ path.py
248+ funcsigs
249+
250+setenv =
251+ PYTHONPATH = {toxinidir}/hooks
252+
253+commands =
254+ py.test {posargs}
255+
256+[testenv:lint]
257+install_command = pip install {opts} --pre --use-wheel {packages}
258+deps =
259+ flake8
260+ charm-tools
261+ ansible-lint
262+
263+commands =
264+ flake8 {toxinidir}/hooks
265+ charm proof
266+ ansible-lint {toxinidir}/playbooks/site.yaml
267+

Subscribers

People subscribed via source and target branches

to all changes: