Merge lp:~lazypower/charms/trusty/kibana/add-dashboard-loader-action into lp:charms/trusty/kibana

Proposed by Charles Butler
Status: Merged
Merged at revision: 23
Proposed branch: lp:~lazypower/charms/trusty/kibana/add-dashboard-loader-action
Merge into: lp:charms/trusty/kibana
Diff against target: 231 lines (+102/-27)
9 files modified
actions/load-dashboard (+14/-2)
config.yaml (+6/-0)
hooks/config-changed (+7/-0)
hooks/install (+9/-4)
tests/00-setup (+0/-16)
tests/10-bundles-test.py (+44/-0)
tests/11-scale-elastic.py (+16/-5)
tests/bundles.yaml (+3/-0)
tests/tests.yaml (+3/-0)
To merge this branch: bzr merge lp:~lazypower/charms/trusty/kibana/add-dashboard-loader-action
Reviewer Review Type Date Requested Status
Review Queue (community) automated testing Needs Fixing
Cory Johns (community) Needs Fixing
Review via email: mp+295359@code.launchpad.net

Description of the change

Fixes for user already existing contributed by @manjo
Fixes against the amulet test suite contributed by @kjackal
Adds a path to deploy dashboards from configuration (useful for bundles)

To post a comment you must log in.
Revision history for this message
Cory Johns (johnsca) wrote :

The load-dashboards action param and dashboard config option descriptions should mention what dashboards are supported out of the box (i.e., "beats").

If the dashboard config option is left at its default value, the elasticsearch <-> kiabana relation is added, and then any other config option is changed, the config-changed hook fails because the config value is empty and it tries to call action-get from outside of an action. See inline comment below.

If the dashboard config is set before the elasticsearch relation is joined (likely in a bundle), the rest-relation- hooks will not trigger the dashboard load, and it may not be triggered until a manual config change.

If the elasticsearch relation is required for the dashboard to be loaded, why isn't the action enforcing that? Also, shouldn't the dashboard be using the relation values (e.g., $ES_HOST) instead of localhost?

review: Needs Fixing
Revision history for this message
Charles Butler (lazypower) wrote :

cory, thanks for the detailed review.

I can address the final comment with a follow up comment - no. There's a virtual host setup to proxy connections over to the elastic search host (this is important, otherwise you have to juju expose elastic search. Kibana works client-side, and directly queries elastic search over a javascript based client side lib.

So good catch, but not a concern in this context.

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-aws/4318/

review: Needs Fixing (automated testing)
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/4300/

review: Needs Fixing (automated testing)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'actions/load-dashboard'
--- actions/load-dashboard 2016-03-21 17:39:10 +0000
+++ actions/load-dashboard 2016-05-20 20:00:24 +0000
@@ -2,10 +2,22 @@
22
3set -ex3set -ex
44
5DASH=$(action-get dashboard)5# Support being called directly, or via action context
6if [ ! -z $1 ]; then
7 DASH=$1
8else
9 DASH=$(action-get dashboard)
10fi
611
12# Determine if we have a dashboard available
7if [[ -d ${CHARM_DIR}/dashboards/${DASH} ]]; then13if [[ -d ${CHARM_DIR}/dashboards/${DASH} ]]; then
8 cd $CHARM_DIR/dashboards/$DASH14 cd $CHARM_DIR/dashboards/$DASH
9 $CHARM_DIR/dashboards/$DASH/load.sh15 $CHARM_DIR/dashboards/$DASH/load.sh
10 exit 016 cd $CHARM_DIR
17 else
18 juju-log "Missing Dashboard $DASH"
19 # fail the action if we are in an action context
20 if [ ! -z $JUJU_ACTION_UUID ]; then
21 action-fail "Missing Dashboard $DASH"
22 fi
11fi23fi
1224
=== modified file 'config.yaml'
--- config.yaml 2015-11-03 23:06:35 +0000
+++ config.yaml 2016-05-20 20:00:24 +0000
@@ -16,3 +16,9 @@
16 default: ''16 default: ''
17 description: 'The url path of kibana. This is required if kibana is17 description: 'The url path of kibana. This is required if kibana is
18 proxied at a non root path. e.g. http://example.com/kibana/'18 proxied at a non root path. e.g. http://example.com/kibana/'
19 dashboard:
20 type: string
21 default: ''
22 description: |
23 Dashboard to load on deployment. Must exist in 'dashboards' directory
24 and contain a load.sh script to populate into elasticsearch.
1925
=== modified file 'hooks/config-changed'
--- hooks/config-changed 2015-11-03 23:06:35 +0000
+++ hooks/config-changed 2016-05-20 20:00:24 +0000
@@ -15,3 +15,10 @@
15open-port $PORT/tcp15open-port $PORT/tcp
16echo $PORT > .PREVOPENPORT16echo $PORT > .PREVOPENPORT
1717
18# Determine if we have the relation required to execute dashboard loading
19WE_HAVE_SIGNAL=$(relation-ids rest)
20if [ ! -z $WE_HAVE_SIGNAL ]; then
21 DASHBOARD=$(config-get dashboard)
22 juju-log "Loading Dashboard $DASHBOARD"
23 actions/load-dashboard $DASHBOARD
24fi
1825
=== modified file 'hooks/install'
--- hooks/install 2015-11-04 00:47:13 +0000
+++ hooks/install 2016-05-20 20:00:24 +0000
@@ -24,10 +24,15 @@
24 cp $KIBANA_TARBALL /tmp/kibana.tgz24 cp $KIBANA_TARBALL /tmp/kibana.tgz
25fi25fi
2626
27groupadd kibana27if ! grep -q kibana /etc/group ; then
28useradd -s /bin/false -g kibana kibana28 groupadd kibana
29mkdir -p /var/log/kibana29fi
30chown kibana:kibana /var/log/kibana30
31if ! /usr/bin/id -u kibana &>/dev/null ; then
32 useradd -s /bin/false -g kibana kibana
33fi
34
35[ -d /var/log/kibana ] || { mkdir -p /var/log/kibana ; chown kibana:kibana /var/log/kibana ; }
3136
32install -o root -g root -m 0644 files/charm/nginx.conf /etc/nginx/sites-available/kibana37install -o root -g root -m 0644 files/charm/nginx.conf /etc/nginx/sites-available/kibana
33install -o root -g root -m 0644 files/charm/nginx_lb.conf /etc/nginx/sites-available/es_cluster38install -o root -g root -m 0644 files/charm/nginx_lb.conf /etc/nginx/sites-available/es_cluster
3439
=== removed file 'tests/00-setup'
--- tests/00-setup 2014-10-29 15:52:18 +0000
+++ tests/00-setup 1970-01-01 00:00:00 +0000
@@ -1,16 +0,0 @@
1#!/bin/bash
2
3# This script sets up the requirements for amulet tests.
4
5set -x
6
7# Check if amulet is installed before adding the stable repository and updating apt-get.
8dpkg -s amulet
9if [ $? -ne 0 ]; then
10 sudo add-apt-repository -y ppa:juju/stable
11 sudo apt-get update -qq
12 sudo apt-get install -y amulet
13fi
14
15# Install any additional python packages and other required software.
16sudo apt-get install -y python3-requests
170
=== modified file 'tests/10-bundles-test.py'
--- tests/10-bundles-test.py 2014-12-04 18:31:05 +0000
+++ tests/10-bundles-test.py 2016-05-20 20:00:24 +0000
@@ -6,6 +6,7 @@
6import unittest6import unittest
7import yaml7import yaml
8import amulet8import amulet
9import requests
910
10seconds_to_wait = 96011seconds_to_wait = 960
1112
@@ -28,6 +29,49 @@
28 """ Test to see if the bundle deployed successfully. """29 """ Test to see if the bundle deployed successfully. """
29 self.assertTrue(self.d.deployed)30 self.assertTrue(self.d.deployed)
3031
32 def test_port_change(self):
33 """ Change kibana port and validate the change happened """
34 self.d.configure('kibana', {'port': 81})
35 self.d.sentry.wait()
36
37 url = 'http://%s:81/' % kibana_unit.info['public-address']
38 r = requests.get(url)
39 assert r.ok
40
41 def test_web_interface():
42
43 elasticsearch_unit.run("""
44 curl -X POST 'http://127.0.0.1:9200/person/1' -d '{
45 "info" : {
46 "height" : 2,
47 "width" : 20
48 }
49 }'
50 """)
51
52 time.sleep(3)
53
54 # Ensure the kibana unit can query ES via localhost (it proxies local 9200
55 # queries to ES)
56 url = 'http://127.0.0.1:9200/_all/_search'
57 result = kibana_unit.run(
58 "curl -XGET {url} -d '@11-scale-elastic-query.json'".format(url=url))
59 if not result[1] == 0:
60 amulet.raise_status(
61 amulet.FAIL, msg="Error performing search. Error code: {}. "
62 "Result:\n{}".format(result[1], result[0]))
63 try:
64 result = json.loads(result[0])
65 if result['hits']['total'] != 1:
66 amulet.raise_status(amulet.FAIL,
67 msg="Error inserting value in elasticsearch.")
68 except ValueError:
69 exc_type, value, traceback = sys.exc_info()
70 exc_text = "Exception: (%s) %s. %s" % (value, exc_type, traceback)
71 amulet.raise_status(
72 amulet.FAIL, msg="Value returned not a valid json.\n{}\n{}".format(
73 result[0], exc_text))
74
3175
32if __name__ == '__main__':76if __name__ == '__main__':
33 unittest.main()77 unittest.main()
3478
=== modified file 'tests/11-scale-elastic.py'
--- tests/11-scale-elastic.py 2015-11-09 03:08:32 +0000
+++ tests/11-scale-elastic.py 2016-05-20 20:00:24 +0000
@@ -38,6 +38,7 @@
3838
3939
40def test_web_interface():40def test_web_interface():
41 hits = get_total_hits()
4142
42 elasticsearch_unit.run("""43 elasticsearch_unit.run("""
43 curl -X POST 'http://127.0.0.1:9200/person/1' -d '{44 curl -X POST 'http://127.0.0.1:9200/person/1' -d '{
@@ -48,8 +49,19 @@
48 }'49 }'
49 """)50 """)
5051
51 time.sleep(3)52 iteration = 0
5253 newhits = get_total_hits()
54 while iteration < 10 and newhits-hits != 1:
55 time.sleep(3)
56 newhits = get_total_hits()
57 iteration += 1
58
59 if newhits-hits != 1:
60 amulet.raise_status(amulet.FAIL,
61 msg="Error inserting value in elasticsearch.")
62
63
64def get_total_hits():
53 # Ensure the kibana unit can query ES via localhost (it proxies local 920065 # Ensure the kibana unit can query ES via localhost (it proxies local 9200
54 # queries to ES)66 # queries to ES)
55 url = 'http://127.0.0.1:9200/_all/_search'67 url = 'http://127.0.0.1:9200/_all/_search'
@@ -59,11 +71,10 @@
59 amulet.raise_status(71 amulet.raise_status(
60 amulet.FAIL, msg="Error performing search. Error code: {}. "72 amulet.FAIL, msg="Error performing search. Error code: {}. "
61 "Result:\n{}".format(result[1], result[0]))73 "Result:\n{}".format(result[1], result[0]))
74
62 try:75 try:
63 result = json.loads(result[0])76 result = json.loads(result[0])
64 if result['hits']['total'] != 1:77 return result['hits']['total']
65 amulet.raise_status(amulet.FAIL,
66 msg="Error inserting value in elasticsearch.")
67 except ValueError:78 except ValueError:
68 exc_type, value, traceback = sys.exc_info()79 exc_type, value, traceback = sys.exc_info()
69 exc_text = "Exception: (%s) %s. %s" % (value, exc_type, traceback)80 exc_text = "Exception: (%s) %s. %s" % (value, exc_type, traceback)
7081
=== modified file 'tests/bundles.yaml'
--- tests/bundles.yaml 2014-10-29 15:52:18 +0000
+++ tests/bundles.yaml 2016-05-20 20:00:24 +0000
@@ -5,3 +5,6 @@
5 kibana:5 kibana:
6 charm: kibana6 charm: kibana
7 num_units: 17 num_units: 1
8 elasticsearch:
9 charm: cs:trusty/elasticsearch
10 num_units: 1
811
=== added file 'tests/tests.yaml'
--- tests/tests.yaml 1970-01-01 00:00:00 +0000
+++ tests/tests.yaml 2016-05-20 20:00:24 +0000
@@ -0,0 +1,3 @@
1packages:
2 - python3-amulet
3 - python3-requests

Subscribers

People subscribed via source and target branches