Merge lp:~jacekn/charms/trusty/prometheus/storage-fixes into lp:~canonical-is-sa/charms/trusty/prometheus/layer-prometheus

Proposed by Jacek Nykis
Status: Merged
Approved by: Chris Stratford
Approved revision: 17
Merged at revision: 17
Proposed branch: lp:~jacekn/charms/trusty/prometheus/storage-fixes
Merge into: lp:~canonical-is-sa/charms/trusty/prometheus/layer-prometheus
Diff against target: 81 lines (+15/-20)
3 files modified
README.md (+4/-0)
metadata.yaml (+1/-6)
reactive/prometheus.py (+10/-14)
To merge this branch: bzr merge lp:~jacekn/charms/trusty/prometheus/storage-fixes
Reviewer Review Type Date Requested Status
Chris Stratford (community) Approve
Review via email: mp+297474@code.launchpad.net

Description of the change

Remove redundant metrics-block storge from metadata.yaml and rename metrics-filesystem to metrics. Fix and storage support

To post a comment you must log in.
Revision history for this message
Chris Stratford (chris-gondolin) wrote :

Failures in subprocess.check_call() aren't caught, but I guess a stacktrace may be enough, so +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'README.md'
--- README.md 2016-02-17 11:51:35 +0000
+++ README.md 2016-06-15 15:23:18 +0000
@@ -5,6 +5,10 @@
55
6## How to deploy the charm6## How to deploy the charm
77
8To deploy with storage support and use 13GB volume for metrics:
9
10juju deploy --storage metrics=13G local:xenial/prometheus prometheus
11
8## Development12## Development
913
10Explicitly set `JUJU_REPOSITORY`:14Explicitly set `JUJU_REPOSITORY`:
1115
=== modified file 'metadata.yaml'
--- metadata.yaml 2016-04-13 16:13:22 +0000
+++ metadata.yaml 2016-06-15 15:23:18 +0000
@@ -23,14 +23,9 @@
23 alertmanager-service:23 alertmanager-service:
24 interface: http24 interface: http
25storage:25storage:
26 metrics-filesystem:26 metrics:
27 type: filesystem27 type: filesystem
28 description: Storage for prometheus data28 description: Storage for prometheus data
29 location: /srv/prometheus29 location: /srv/prometheus
30 multiple:30 multiple:
31 range: 0-131 range: 0-1
32 metrics-block:
33 type: block
34 description: Storage for prometheus data
35 multiple:
36 range: 0-1
3732
=== modified file 'reactive/prometheus.py'
--- reactive/prometheus.py 2016-04-13 15:58:16 +0000
+++ reactive/prometheus.py 2016-06-15 15:23:18 +0000
@@ -32,25 +32,22 @@
3232
3333
34# TODO: once there's reactive support for storage hooks, convert off @hook()34# TODO: once there's reactive support for storage hooks, convert off @hook()
35@hook('metrics-{filesystem,block}-storage-attached')35@hook('metrics-storage-attached')
36def configure_storage():36def configure_storage():
37 # Storage hooks always run before install so we don't have to worry
38 # about states here
37 storage_path = subprocess.check_output(39 storage_path = subprocess.check_output(
38 ['storage-get', 'location']).decode().strip()40 ['storage-get', 'location']).decode().strip()
39 kv = unitdata.kv()41 kv = unitdata.kv()
40 kv.set('storage-path', storage_path)42 kv.set('storage-path', storage_path)
41 runtime_args('-storage.local.path', storage_path)43 runtime_args('-storage.local.path', storage_path)
42 set_state('storage.configured')44
43 set_state('prometheus.do-check-reconfig')45 subprocess.check_call(['addgroup', '--system', 'prometheus'])
4446 subprocess.check_call(['adduser', '--system', '--home', storage_path, '--ingroup', 'prometheus',
4547 '--shell', '/bin/false', '--no-create-home',
46def set_datadir_perms():48 '--gecos', 'Prometheus daemon', 'prometheus'])
47 datadir = unitdata.kv().get('storage-path', False)49 users = [i for i in pwd.getpwall() if i.pw_name == 'prometheus']
48 if not datadir:50 os.lchown(storage_path, users[0].pw_uid, users[0].pw_gid)
49 # No juju storage attached, use defaults from package
50 return
51 users = [i for i in pwd.getpwall() if i.pw_name == 'nobody']
52 if len(users) == 1:
53 os.lchown(datadir, users[0].pw_uid, users[0].pw_gid)
5451
5552
56@when('prometheus.do-install')53@when('prometheus.do-install')
@@ -154,7 +151,6 @@
154 hookenv.status_set('maintenance', 'Waiting for basenode to run')151 hookenv.status_set('maintenance', 'Waiting for basenode to run')
155 return152 return
156 hookenv.status_set('maintenance', 'Configuring software')153 hookenv.status_set('maintenance', 'Configuring software')
157 set_datadir_perms()
158 install_packages()154 install_packages()
159 set_state('prometheus.do-check-reconfig')155 set_state('prometheus.do-check-reconfig')
160156

Subscribers

People subscribed via source and target branches

to all changes: