Merge lp:~canonical-is-sa/charms/trusty/kibana/kibana4 into lp:charms/trusty/kibana

Proposed by Michael Nelson
Status: Merged
Merged at revision: 20
Proposed branch: lp:~canonical-is-sa/charms/trusty/kibana/kibana4
Merge into: lp:charms/trusty/kibana
Diff against target: 212 lines (+33/-40)
9 files modified
README.md (+1/-1)
config.yaml (+2/-6)
files/charm/config.yml (+2/-1)
files/charm/kibana.init (+1/-1)
files/charm/kibana_lb.conf (+4/-1)
hooks/config-changed (+0/-2)
hooks/install (+10/-6)
hooks/web-relation-joined (+0/-9)
tests/11-scale-elastic.py (+13/-13)
To merge this branch: bzr merge lp:~canonical-is-sa/charms/trusty/kibana/kibana4
Reviewer Review Type Date Requested Status
Kevin W Monroe Approve
Konstantinos Tsakalozos (community) Approve
Chris MacNaughton (community) Approve
Review Queue (community) automated testing Approve
Review via email: mp+276944@code.launchpad.net

Commit message

Fixes nginx proxy so only local requests to :9200 are forwarded to elasticsearch units.
Updates to latest kibana4 as default.
Specifies missing kibana config file and uses explicit logging option.
Adds support for exec.d pre-install hook.

Description of the change

Note: I wasn't planning on merging these changes to upstream kibana, because I thought you might see fallout if the kibana charm now defaults to kibana4, but other related charms (elatsicsearch, logstash) don't default to the required newer versions. But since the kibana4 changes have already been landed, here are some small changes :)

I'll comment below inline on each change, but I've tested the 11-scale-elastec locally:

dev-trusty# ~/charms/kibana/trusty/kibana
$ ./tests/11-scale-elastic.py
2015-11-09 03:09:35 Starting deployment of local
2015-11-09 03:09:35 Deploying services...
2015-11-09 03:09:35 Deploying service elasticsearch using cs:trusty/elasticsearch-12
2015-11-09 03:09:43 Deploying service kibana using /home/michael/charms/kibana/trusty/kibana
2015-11-09 03:09:48 Deploying service logstash-indexer using cs:precise/logstash-indexer-4
2015-11-09 03:13:08 Adding relations...
2015-11-09 03:13:08 Adding relation logstash-indexer:cluster <-> elasticsearch:client
2015-11-09 03:13:09 Adding relation kibana:rest <-> elasticsearch:client
2015-11-09 03:14:09 Exposing service 'kibana'
2015-11-09 03:14:09 Deployment complete in 275.00 seconds
dev-trusty# ~/charms/kibana/trusty/kibana
$

To post a comment you must log in.
Revision history for this message
Michael Nelson (michael.nelson) wrote :

Adding inline comments.

Revision history for this message
Michael Nelson (michael.nelson) :
Revision history for this message
Review Queue (review-queue) wrote :

This item has failed automated testing! Results available here http://juju-ci.vapour.ws:8080/job/charm-bundle-test-lxc/1423/

review: Needs Fixing (automated testing)
Revision history for this message
Review Queue (review-queue) wrote :

The results (PASS) are in and available here: http://juju-ci.vapour.ws:8080/job/charm-bundle-test-aws/1420/

review: Approve (automated testing)
Revision history for this message
Chris MacNaughton (chris.macnaughton) wrote :

Hi Michael,

Great work on these changes, making things more secure for everybody!

Looks good to me, according to http://reports.vapour.ws/all-bundle-and-charm-results/https%3A%252F%252Fcode.launchpad.net%252F~canonical-is-sa%252Fcharms%252Ftrusty%252Fkibana%252Fkibana4%252F%2Bmerge%252F276944 tests are in fact all passing.

Approve.

review: Approve
Revision history for this message
Konstantinos Tsakalozos (kos.tsakalozos) wrote :

LGTM. Thank you for doing this!

review: Approve
Revision history for this message
Kevin W Monroe (kwmonroe) wrote :

Thanks for these changes and the reviews! I made a small tweak to the README.md, which was still referencing the removed unpack dir:

-checksum verification, but respecting the 'kibana_source_unpack_directory'.
+checksum verification, and unpacked to /srv/kibana4.

This merge has been committed to lp:charms/trusty/kibana. An updated charm should be available in the store shortly. Thanks again!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README.md'
2--- README.md 2015-09-30 15:40:43 +0000
3+++ README.md 2015-11-09 03:21:53 +0000
4@@ -31,7 +31,7 @@
5 configured values in 'kibana_source' and 'kibana_source_checksum', which
6 default to::
7
8- https://download.elastic.co/kibana/kibana/kibana-4.1.2-linux-x64.tar.gz
9+ https://download.elastic.co/kibana/kibana/kibana-4.2.0-linux-x64.tar.gz
10
11 It will, obviously, require internet access on deployed nodes.
12
13
14=== modified file 'config.yaml'
15--- config.yaml 2015-09-30 15:40:43 +0000
16+++ config.yaml 2015-11-09 03:21:53 +0000
17@@ -1,15 +1,11 @@
18 options:
19 kibana_source:
20 type: string
21- default: 'https://download.elastic.co/kibana/kibana/kibana-4.1.2-linux-x64.tar.gz'
22+ default: 'https://download.elastic.co/kibana/kibana/kibana-4.2.0-linux-x64.tar.gz'
23 description: URL to download the source for kibana
24- kibana_source_unpack_directory:
25- type: string
26- default: 'kibana-4.1.2-linux-x64'
27- description: the name of the directory the tar.gz will unpack to
28 kibana_source_checksum:
29 type: string
30- default: '45e67114f7dac4ccac8118bf98ee8f6362c7a6a1'
31+ default: '094e197c687012211ae0e291faf3111d47e714d9'
32 description: the sha1sum of the kibana_source
33 port:
34 type: int
35
36=== modified file 'files/charm/config.yml'
37--- files/charm/config.yml 2015-10-02 17:04:38 +0000
38+++ files/charm/config.yml 2015-11-09 03:21:53 +0000
39@@ -5,7 +5,8 @@
40 host: "0.0.0.0"
41
42 # The Elasticsearch instance to use for all your queries.
43-elasticsearch_url: "http://localhost:9200"
44+# This is proxied via /etc/nginx/sites-enabled/kibana_load_balancer
45+elasticsearch_url: http://localhost:9200
46
47 # preserve_elasticsearch_host true will send the hostname specified in `elasticsearch`. If you set it to false,
48 # then the host you use to connect to *this* Kibana instance will be sent.
49
50=== modified file 'files/charm/kibana.init'
51--- files/charm/kibana.init 2015-10-02 17:04:38 +0000
52+++ files/charm/kibana.init 2015-11-09 03:21:53 +0000
53@@ -28,5 +28,5 @@
54 export PATH HOME
55 test -n "${JAVACMD}" && export JAVACMD
56
57- exec nice -n ${KB_NICE} ${KB_HOME}/bin/kibana 2>&1 ${KB_LOG_FILE}
58+ exec nice -n ${KB_NICE} ${KB_HOME}/bin/kibana --config /etc/kibana/config.yml --log-file ${KB_LOG_FILE}
59 end script
60
61=== modified file 'files/charm/kibana_lb.conf'
62--- files/charm/kibana_lb.conf 2015-10-09 20:54:45 +0000
63+++ files/charm/kibana_lb.conf 2015-11-09 03:21:53 +0000
64@@ -6,7 +6,10 @@
65 listen *:9200;
66
67 location / {
68+ # Only proxy local requests for ES.
69+ allow 127.0.0.1;
70+ deny all;
71 proxy_pass http://es_cluster;
72 proxy_read_timeout 90;
73 }
74-}
75\ No newline at end of file
76+}
77
78=== modified file 'hooks/config-changed'
79--- hooks/config-changed 2015-10-09 20:54:45 +0000
80+++ hooks/config-changed 2015-11-09 03:21:53 +0000
81@@ -6,8 +6,6 @@
82
83 sed -i "s/listen.*/listen *:$PORT;/" /etc/nginx/sites-available/kibana
84
85-# sed -i "s@elasticsearch: .*@elasticsearch: '//'+window.location.hostname+'$KIBANA_PATH',@" /srv/kibana4/config.js
86-
87 service nginx reload
88 service kibana restart
89
90
91=== modified file 'hooks/install'
92--- hooks/install 2015-10-02 17:04:38 +0000
93+++ hooks/install 2015-11-09 03:21:53 +0000
94@@ -1,9 +1,12 @@
95 #!/bin/bash
96 set -eux
97+
98+juju-log 'Invoking charm-pre-install hooks'
99+[ -d exec.d ] && ( for f in exec.d/*/charm-pre-install; do [ -x $f ] && /bin/sh -c "$f"; done )
100+
101 HOME=$PWD
102 KIBANA_TARBALL=files/kibana.tgz
103 KIBANA_SOURCE=$(config-get kibana_source)
104-KIBANA_SOURCE_UNPACK_DIRECTORY=$(config-get kibana_source_unpack_directory)
105 KIBANA_SOURCE_CHECKSUM=$(config-get kibana_source_checksum)
106 HOST=$(unit-get private-address)
107
108@@ -30,20 +33,21 @@
109 install -o root -g root -m 0644 files/charm/nginx_lb.conf /etc/nginx/sites-available/es_cluster
110 install -o root -g root -m 0644 files/charm/kibana_lb.conf /etc/nginx/sites-available/kibana_load_balancer
111 install -o root -g root -m 0644 files/charm/kibana.init /etc/init/kibana.conf
112+mkdir -p /etc/kibana/
113+install -o root -g root -m 0644 files/charm/config.yml /etc/kibana/config.yml
114 pushd /srv
115
116 if [[ ! -d kibana4 ]]; then
117 tar xzvf /tmp/kibana.tgz
118- mv ${KIBANA_SOURCE_UNPACK_DIRECTORY} kibana4
119+ # Note: charm does not currently support changing kibana source.
120+ mv kibana-4.* kibana4
121+ chown -R kibana:kibana kibana4
122 fi
123
124 rm -f /etc/nginx/sites-enabled/default
125
126 popd
127
128-# rm -f /srv/kibana4/config.js
129-# install -o root -g root -m 0644 files/charm/config.js /srv/kibana4/config.js
130-
131 hooks/config-changed
132
133 ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/kibana
134@@ -51,4 +55,4 @@
135 ln -s /etc/nginx/sites-available/kibana_load_balancer /etc/nginx/sites-enabled/kibana_load_balancer
136
137 service nginx restart
138-service kibana restart
139\ No newline at end of file
140+service kibana restart
141
142=== added file 'hooks/web-relation-joined'
143--- hooks/web-relation-joined 1970-01-01 00:00:00 +0000
144+++ hooks/web-relation-joined 2015-11-09 03:21:53 +0000
145@@ -0,0 +1,9 @@
146+#!/bin/bash
147+set -eux
148+juju-log $JUJU_REMOTE_UNIT joined
149+
150+PORT=$(config-get port)
151+
152+# Set ip/port for web relation
153+relation-set port="$PORT"
154+relation-set host=`unit-get private-address`
155
156=== removed file 'hooks/web-relation-joined'
157--- hooks/web-relation-joined 2015-04-01 20:07:40 +0000
158+++ hooks/web-relation-joined 1970-01-01 00:00:00 +0000
159@@ -1,9 +0,0 @@
160-#!/bin/bash
161-set -eux
162-juju-log $JUJU_REMOTE_UNIT joined
163-
164-PORT=$(config-get port)
165-
166-# Set ip/port for web relation
167-relation-set port="$PORT"
168-relation-set host=`unit-get private-address`
169
170=== modified file 'tests/11-scale-elastic.py'
171--- tests/11-scale-elastic.py 2015-11-04 21:49:41 +0000
172+++ tests/11-scale-elastic.py 2015-11-09 03:21:53 +0000
173@@ -50,26 +50,26 @@
174
175 time.sleep(3)
176
177- url = 'http://%s:9200/_all/_search' % kibana_unit.info['public-address']
178- test_dir = os.path.dirname(__file__)
179- test_data_file = os.path.join(test_dir, '11-scale-elastic-query.json')
180- with open(test_data_file) as fp:
181- test_data = json.load(fp)
182- r = requests.get(url, params=test_data)
183- if not r.ok:
184- amulet.raise_status(amulet.FAIL,
185- msg="Error performing search.")
186+ # Ensure the kibana unit can query ES via localhost (it proxies local 9200
187+ # queries to ES)
188+ url = 'http://127.0.0.1:9200/_all/_search'
189+ result = kibana_unit.run(
190+ "curl -XGET {url} -d '@11-scale-elastic-query.json'".format(url=url))
191+ if not result[1] == 0:
192+ amulet.raise_status(
193+ amulet.FAIL, msg="Error performing search. Error code: {}. "
194+ "Result:\n{}".format(result[1], result[0]))
195 try:
196- result = r.json()
197+ result = json.loads(result[0])
198 if result['hits']['total'] != 1:
199 amulet.raise_status(amulet.FAIL,
200 msg="Error inserting value in elasticsearch.")
201 except ValueError:
202 exc_type, value, traceback = sys.exc_info()
203 exc_text = "Exception: (%s) %s. %s" % (value, exc_type, traceback)
204- amulet.raise_status(amulet.FAIL,
205- msg="Value returned not a valid json." + r.text +
206- exc_text)
207+ amulet.raise_status(
208+ amulet.FAIL, msg="Value returned not a valid json.\n{}\n{}".format(
209+ result[0], exc_text))
210
211
212 test_web_interface()

Subscribers

People subscribed via source and target branches