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

Proposed by Jacek Nykis
Status: Merged
Merged at revision: 3
Proposed branch: lp:~jacekn/charms/trusty/prometheus-alertmanager/port-fixes
Merge into: lp:~canonical-is-sa/charms/trusty/prometheus-alertmanager/layer-prometheus-alertmanager
Diff against target: 50 lines (+15/-5)
2 files modified
metadata.yaml (+1/-1)
reactive/alertmanager.py (+14/-4)
To merge this branch: bzr merge lp:~jacekn/charms/trusty/prometheus-alertmanager/port-fixes
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Review via email: mp+298140@code.launchpad.net

Description of the change

Rename the charm to prometheus-alertmanger to match other prometheus charms. Ensure network port is opened

To post a comment you must log in.
Revision history for this message
Stuart Bishop (stub) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'metadata.yaml'
2--- metadata.yaml 2016-03-14 00:54:44 +0000
3+++ metadata.yaml 2016-06-22 16:33:54 +0000
4@@ -1,4 +1,4 @@
5-name: alertmanager
6+name: prometheus-alertmanager
7 summary: Alertmanager for Prometheus
8 maintainer: JuanJo Ciarlante <JuanJo.Ciarlante@localhost>
9 description: |
10
11=== modified file 'reactive/alertmanager.py'
12--- reactive/alertmanager.py 2016-03-16 18:16:52 +0000
13+++ reactive/alertmanager.py 2016-06-22 16:33:54 +0000
14@@ -40,6 +40,15 @@
15 return sorted(args_list)
16
17
18+def check_ports(new_port):
19+ kv = unitdata.kv()
20+ if kv.get('alertmanager.port') != new_port:
21+ hookenv.open_port(new_port)
22+ if kv.get('alertmanager.port'): # Dont try to close non existing ports
23+ hookenv.close_port(kv.get('alertmanager.port'))
24+ kv.set('alertmanager.port', new_port)
25+
26+
27 def validate_config():
28 return yaml.safe_load(open(ALERTMANAGER_YML))
29
30@@ -59,15 +68,16 @@
31 @when('alertmanager.do-reconfig-def')
32 def write_alertmanager_config_def():
33 config = hookenv.config()
34- if config.get('port', False):
35- runtime_args('-web.listen-address',
36- ':{}'.format(config['port']))
37+ port = config.get('port', '9093')
38+ check_ports(port)
39+ runtime_args('-web.listen-address',
40+ ':{}'.format(port))
41 if config.get('external_url', False):
42 vars = {
43 'private_address': hookenv.unit_get('private-address'),
44 'public_address': hookenv.unit_get('public-address'),
45 # alertmanager default:
46- 'port': config.get('port', '9093'),
47+ 'port': port,
48 }
49 runtime_args('-web.external-url',
50 config['external_url'].format(**vars))

Subscribers

People subscribed via source and target branches

to all changes: