Merge lp:~hloeung/ubuntu-repository-cache/use-correct-updated-unit-ip-address into lp:ubuntu-repository-cache

Proposed by Haw Loeung
Status: Merged
Approved by: Haw Loeung
Approved revision: 292
Merged at revision: 290
Proposed branch: lp:~hloeung/ubuntu-repository-cache/use-correct-updated-unit-ip-address
Merge into: lp:ubuntu-repository-cache
Diff against target: 48 lines (+17/-0)
1 file modified
reactive/ubuntu-repository-cache.py (+17/-0)
To merge this branch: bzr merge lp:~hloeung/ubuntu-repository-cache/use-correct-updated-unit-ip-address
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Barry Price Approve
Review via email: mp+394789@code.launchpad.net

Commit message

Use correct/updated IP address of unit - LP:1876029

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Barry Price (barryprice) wrote :

LGTM +1

review: Approve
291. By Haw Loeung

Update relation data on both config-changed and leader-settings-changed hooks to ensure it's run on start/restart

292. By Haw Loeung

Also run on cluster-relation-changed

Revision history for this message
Barry Price (barryprice) wrote :

Yup

review: Approve
Revision history for this message
Stuart Bishop (stub) wrote :

Sure.

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 290

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'reactive/ubuntu-repository-cache.py'
2--- reactive/ubuntu-repository-cache.py 2020-10-06 10:04:18 +0000
3+++ reactive/ubuntu-repository-cache.py 2020-12-03 04:57:58 +0000
4@@ -44,6 +44,7 @@
5 @reactive.when_not('ubuntu-repository-cache.configured')
6 def configure_services():
7 service.render_configs()
8+ update_website_relation_data()
9
10 # We should always do this anyway, but currently,
11 # due to LP#1626318, following a reboot, the ephemeral
12@@ -56,6 +57,20 @@
13 reactive.set_flag('ubuntu-repository-cache.configured')
14
15
16+def update_website_relation_data():
17+ relation_id = None
18+ for relid in hookenv.relation_ids('website'):
19+ relation_id = relid
20+ if not relation_id:
21+ return
22+
23+ # LP:1876029: Work around Juju not updating 'private-address'
24+ primary_address = hookenv.network_get_primary_address('website')
25+ LOG('Updating relation with primary IP address: {}'.format(primary_address))
26+ settings = {'private-address': primary_address, 'hostname': primary_address, 'port': 80}
27+ hookenv.relation_set(relation_id=relation_id, relation_settings=settings)
28+
29+
30 @reactive.hook('upgrade-charm')
31 def upgrade_charm():
32 '''Handle charm updates'''
33@@ -141,6 +156,7 @@
34 _fix_ssh_ownership(user='www-sync')
35 mirror.peer_update_metadata()
36 service.render_configs()
37+ update_website_relation_data()
38
39
40 @reactive.hook('cluster-relation-departed')
41@@ -213,6 +229,7 @@
42 LOG('leader-settings-changed fired. New leader_id: {}'.format(leader_id))
43 mirror.peer_update_metadata()
44 service.render_configs()
45+ update_website_relation_data()
46
47
48 # LP:1770071: Work around charm-helper's unison ownership

Subscribers

People subscribed via source and target branches