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
=== modified file 'Makefile'
--- Makefile 2015-04-01 18:50:44 +0000
+++ Makefile 2015-09-24 15:27:04 +0000
@@ -1,18 +1,23 @@
1#!/usr/bin/make1#!/usr/bin/make
22
3build: virtualenv lint3
44build: tox lint test
5virtualenv: .venv/bin/python5
6.venv/bin/python:6virtualenv:
7 virtualenv .venv7 virtualenv .venv
8 .venv/bin/pip install nose flake8 mock pyyaml charmhelpers ansible-lint ansible8
99tox:
10lint:.venv/bin/python10/usr/bin/tox:
11 @echo Linting Charm11 sudo apt-get install -y python-tox python-dev python-virtualenv
12 @charm proof12
13 @echo Linting Ansible Routines13lint: /usr/bin/tox
14 @.venv/bin/ansible-lint playbooks/*14 tox -e lint
15
16
17unit_test: /usr/bin/tox
18 @# tox
19 @echo "Unit tests pending"
1520
16clean:21clean:
17 rm -rf .venv22 rm -rf .venv .tox
18 find -name *.pyc -delete23 find -name *.pyc -delete
1924
=== modified file 'README.md'
--- README.md 2015-04-01 19:53:51 +0000
+++ README.md 2015-09-24 15:27:04 +0000
@@ -1,5 +1,7 @@
1# Flannel (Docker Flavored)1# Flannel (Docker Flavored)
22
3[![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)
4
3### About Flannel5### About Flannel
4[Flannel](https://github.com/coreos/flannel) (originally rudder) is an overlay6[Flannel](https://github.com/coreos/flannel) (originally rudder) is an overlay
5network that gives a subnet to each machine for use with containers.7network that gives a subnet to each machine for use with containers.
68
=== modified file 'files/flannel.amd64.tar.gz'
7Binary 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 differ9Binary 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
=== modified file 'hooks/setup.py'
--- hooks/setup.py 2015-01-16 23:34:13 +0000
+++ hooks/setup.py 2015-09-24 15:27:04 +0000
@@ -6,7 +6,7 @@
6 Do any setup required before the install hook.6 Do any setup required before the install hook.
7 """7 """
8 install_charmhelpers()8 install_charmhelpers()
9 #subprocess.check_call(['pip', 'install', 'path.py'])9 # subprocess.check_call(['pip', 'install', 'path.py'])
1010
1111
12def install_charmhelpers():12def install_charmhelpers():
1313
=== modified file 'playbooks/flannel-configuration.yaml'
--- playbooks/flannel-configuration.yaml 2015-01-16 23:34:13 +0000
+++ playbooks/flannel-configuration.yaml 2015-09-24 15:27:04 +0000
@@ -22,7 +22,7 @@
22 when: etcd_joined == "True"22 when: etcd_joined == "True"
2323
24- name: Install Upstart Template for flannel24- name: Install Upstart Template for flannel
25 template: src={{ charm_dir }}/templates/flannel.conf25 template: src={{ charm_dir }}/templates/upstart.template
26 dest=/etc/init/flannel.conf26 dest=/etc/init/flannel.conf
27 mode=064427 mode=0644
28 when: etcd_joined == "True"28 when: etcd_joined == "True"
2929
=== modified file 'playbooks/install-or-upgrade.yaml'
--- playbooks/install-or-upgrade.yaml 2015-01-16 23:34:13 +0000
+++ playbooks/install-or-upgrade.yaml 2015-09-24 15:27:04 +0000
@@ -9,4 +9,4 @@
9 - name: Unpack the flannel binary9 - name: Unpack the flannel binary
10 unarchive: src={{ charm_dir }}/files/flannel.amd64.tar.gz10 unarchive: src={{ charm_dir }}/files/flannel.amd64.tar.gz
11 dest=/usr/local/bin11 dest=/usr/local/bin
12 creates=/usr/local/bin/flannel mode= 075512 creates=/usr/local/bin/flannel mode='u=rx,g=rx,o=rx'
1313
=== modified file 'playbooks/network-relation-changed.yaml'
--- playbooks/network-relation-changed.yaml 2015-05-21 15:00:11 +0000
+++ playbooks/network-relation-changed.yaml 2015-09-24 15:27:04 +0000
@@ -12,10 +12,14 @@
12 shell: cat /run/flannel/subnet.env | grep FLANNEL_MTU | cut -f2 -d"="12 shell: cat /run/flannel/subnet.env | grep FLANNEL_MTU | cut -f2 -d"="
13 register: flannel_mtu13 register: flannel_mtu
1414
15- name: Read network relation
16 shell: "{{ charm_dir }}/scripts/parse_relation.py"
17 register: network_id
18
15- set_fact:19- set_fact:
16 flannel_mtu: "{{ flannel_mtu.stdout }}"20 flannel_mtu: "{{ flannel_mtu.stdout }}"
17 flannel_subnet: "{{ flannel_subnet.stdout }}"21 flannel_subnet: "{{ flannel_subnet.stdout }}"
18 scoped_network: "{{ relations.network[0].__relid__ | default('') }}"22 scoped_network: "{{ network_id.stdout | default('') }}"
1923
20- name: Send Data to Docker Host for bridge configuration24- name: Send Data to Docker Host for bridge configuration
21 shell: relation-set -r {{ scoped_network }} flannel-subnet={{ flannel_subnet }} flannel-mtu={{ flannel_mtu }} overlay_type=udp25 shell: relation-set -r {{ scoped_network }} flannel-subnet={{ flannel_subnet }} flannel-mtu={{ flannel_mtu }} overlay_type=udp
2226
=== added file 'pytest.ini'
--- pytest.ini 1970-01-01 00:00:00 +0000
+++ pytest.ini 2015-09-24 15:27:04 +0000
@@ -0,0 +1,2 @@
1[pytest]
2addopts = --tb=short -s --cov=hooks --cov=modules --cov-report=term-missing
03
=== modified file 'scripts/etcd_rest.py'
--- scripts/etcd_rest.py 2015-01-16 23:34:13 +0000
+++ scripts/etcd_rest.py 2015-09-24 15:27:04 +0000
@@ -5,31 +5,37 @@
5import json5import json
6import httplib6import httplib
7import argparse7import argparse
8import subprocess
8import sys9import sys
910
1011
11def initialize_etcd(endpoint,12def initialize_etcd(endpoint,
12 flannel_prefix="/coreos.com/network",13 flannel_prefix="/coreos.com/network",
13 flannel_network="10.10.0.0/16"):14 flannel_network="10.10.0.0/16"):
1415 try:
15 parsed = urlparse.urlparse(endpoint)16 parsed = urlparse.urlparse(endpoint)
16 params = urllib.urlencode(17 params = urllib.urlencode(
17 {"value": json.dumps({'Network': flannel_network})})18 {"value": json.dumps({'Network': flannel_network})})
18 headers = {'content-type': 'application/x-www-form-urlencoded'}19 headers = {'content-type': 'application/x-www-form-urlencoded'}
19 path = "/v2/keys%s/config" % flannel_prefix20 path = "/v2/keys%s/config" % flannel_prefix
20 conn = httplib.HTTPConnection(parsed.hostname, parsed.port)21 conn = httplib.HTTPConnection(parsed.hostname, parsed.port)
21 conn.request("PUT", path, params, headers)22 conn.request("PUT", path, params, headers)
22 response = conn.getresponse()23 response = conn.getresponse()
23 data = json.loads(response.read())24 data = json.loads(response.read())
24 print("Initialize Etcd Network %s %s" % (response.status, response.reason))25 print("Initialize Etcd Network %s %s" % (response.status,
25 print(data)26 response.reason))
27 print(data)
28 except:
29 msg = "Unable to register with ETCD. Flannel not configured"
30 cmd = ['status-set', 'blocked', msg]
31 subprocess.call(cmd)
32 return 0
2633
2734
28def main(args=sys.argv[1:]):35def main(args=sys.argv[1:]):
29 parser = argparse.ArgumentParser(description="stuff")36 parser = argparse.ArgumentParser(description="stuff")
30 parser.add_argument("endpoint")37 parser.add_argument("endpoint")
3138 args = parser.parse_args(args)
32 args= parser.parse_args(args)
33 initialize_etcd(args.endpoint)39 initialize_etcd(args.endpoint)
3440
3541
3642
=== added file 'scripts/parse_relation.py'
--- scripts/parse_relation.py 1970-01-01 00:00:00 +0000
+++ scripts/parse_relation.py 2015-09-24 15:27:04 +0000
@@ -0,0 +1,13 @@
1#!/usr/bin/python
2
3import yaml
4
5path='/etc/ansible/host_vars/localhost'
6
7with open(path, 'r') as f:
8 data = yaml.safe_load(f)
9
10try:
11 print data['relations']['network'][0]['__relid__']
12except:
13 pass
014
=== modified file 'templates/upstart.template'
--- templates/upstart.template 2015-01-16 23:34:13 +0000
+++ templates/upstart.template 2015-09-24 15:27:04 +0000
@@ -1,8 +1,8 @@
1description "Flannel Overlay Network"1description "Flannel Overlay Network"
2maintainer "Charles Butler <charles.butler@ubuntu.com>"2#maintainer "Charles Butler <charles.butler@ubuntu.com>"
33
4start on runlevel [2345]4start on runlevel [2345]
5stop on runlevel [!2345]5stop on runlevel [!2345]
66
7exec /usr/local/bin/flannel -v=1 -ip-masq=true -etcd-endpoint=http://{{ etcd_ip}}:{{ etcd_ip }} -logtostderr=true7exec /usr/local/bin/flannel -v=1 -ip-masq=true -etcd-endpoints=http://{{ etcd_ip}}:{{ etcd_port }} -logtostderr=true
88
99
=== modified file 'tests/10-deploy.py'
--- tests/10-deploy.py 2015-04-02 14:04:59 +0000
+++ tests/10-deploy.py 2015-09-24 15:27:04 +0000
@@ -21,7 +21,7 @@
2121
22 cls.deployment.add('docker', 'cs:trusty/docker')22 cls.deployment.add('docker', 'cs:trusty/docker')
23 cls.deployment.add('flannel-docker')23 cls.deployment.add('flannel-docker')
24 cls.deployment.add('etcd', 'cs:~kubernetes/trusty/etcd')24 cls.deployment.add('etcd', 'cs:trusty/etcd')
2525
26 cls.deployment.configure('docker', {})26 cls.deployment.configure('docker', {})
27 cls.deployment.configure('etcd', {})27 cls.deployment.configure('etcd', {})
2828
=== modified file 'tests/tests.yaml'
--- tests/tests.yaml 2015-04-02 14:04:59 +0000
+++ tests/tests.yaml 2015-09-24 15:27:04 +0000
@@ -1,1 +1,4 @@
1virtualenv: False1virtualenv: False
2makefile:
3 - clean
4 - lint
25
=== added file 'tox.ini'
--- tox.ini 1970-01-01 00:00:00 +0000
+++ tox.ini 2015-09-24 15:27:04 +0000
@@ -0,0 +1,35 @@
1[tox]
2envlist = py27
3skipsdist = True
4
5[testenv]
6install_command = pip install {opts} --pre --use-wheel {packages}
7deps =
8 pytest
9 pytest-cov
10 pytest-capturelog
11 mock
12 charmhelpers
13 pyyaml
14 ansible
15 path.py
16 funcsigs
17
18setenv =
19 PYTHONPATH = {toxinidir}/hooks
20
21commands =
22 py.test {posargs}
23
24[testenv:lint]
25install_command = pip install {opts} --pre --use-wheel {packages}
26deps =
27 flake8
28 charm-tools
29 ansible-lint
30
31commands =
32 flake8 {toxinidir}/hooks
33 charm proof
34 ansible-lint {toxinidir}/playbooks/site.yaml
35

Subscribers

People subscribed via source and target branches

to all changes: