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

Proposed by Jacek Nykis
Status: Merged
Approved by: Tom Haddon
Approved revision: 4
Merged at revision: 4
Proposed branch: lp:~jacekn/charms/trusty/prometheus-pushgateway/open-port
Merge into: lp:~canonical-is-sa/charms/trusty/prometheus-pushgateway/layer-prometheus-pushgateway
Diff against target: 29 lines (+13/-3)
1 file modified
reactive/pushgateway.py (+13/-3)
To merge this branch: bzr merge lp:~jacekn/charms/trusty/prometheus-pushgateway/open-port
Reviewer Review Type Date Requested Status
JuanJo Ciarlante (community) lgtm Approve
Tom Haddon Approve
Review via email: mp+297498@code.launchpad.net

Description of the change

Ensure pushgateway opens its port

To post a comment you must log in.
Revision history for this message
Tom Haddon (mthaddon) wrote :

Looks good.

review: Approve
Revision history for this message
JuanJo Ciarlante (jjo) :
review: Approve (lgtm)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'reactive/pushgateway.py'
2--- reactive/pushgateway.py 2016-03-17 18:45:31 +0000
3+++ reactive/pushgateway.py 2016-06-15 16:42:30 +0000
4@@ -36,12 +36,22 @@
5 return sorted(args_list)
6
7
8+def check_ports(new_port):
9+ kv = unitdata.kv()
10+ if kv.get('pushgateway.port') != new_port:
11+ hookenv.open_port(new_port)
12+ if kv.get('pushgateway.port'): # Dont try to close non existing ports
13+ hookenv.close_port(kv.get('pushgateway.port'))
14+ kv.set('pushgateway.port', new_port)
15+
16+
17 @when('pushgateway.do-reconfig-def')
18 def write_pushgateway_config_def():
19 config = hookenv.config()
20- if config.get('port', False):
21- runtime_args('-web.listen-address',
22- ':{}'.format(config['port']))
23+ port = config.get('port', '9091')
24+ check_ports(port)
25+ runtime_args('-web.listen-address',
26+ ':{}'.format(port))
27 if config.get('persistence_file'):
28 runtime_args('-persistence.file', config['persistence_file'])
29 args = runtime_args()

Subscribers

People subscribed via source and target branches

to all changes: