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
=== modified file 'reactive/ubuntu-repository-cache.py'
--- reactive/ubuntu-repository-cache.py 2020-10-06 10:04:18 +0000
+++ reactive/ubuntu-repository-cache.py 2020-12-03 04:57:58 +0000
@@ -44,6 +44,7 @@
44@reactive.when_not('ubuntu-repository-cache.configured')44@reactive.when_not('ubuntu-repository-cache.configured')
45def configure_services():45def configure_services():
46 service.render_configs()46 service.render_configs()
47 update_website_relation_data()
4748
48 # We should always do this anyway, but currently,49 # We should always do this anyway, but currently,
49 # due to LP#1626318, following a reboot, the ephemeral50 # due to LP#1626318, following a reboot, the ephemeral
@@ -56,6 +57,20 @@
56 reactive.set_flag('ubuntu-repository-cache.configured')57 reactive.set_flag('ubuntu-repository-cache.configured')
5758
5859
60def update_website_relation_data():
61 relation_id = None
62 for relid in hookenv.relation_ids('website'):
63 relation_id = relid
64 if not relation_id:
65 return
66
67 # LP:1876029: Work around Juju not updating 'private-address'
68 primary_address = hookenv.network_get_primary_address('website')
69 LOG('Updating relation with primary IP address: {}'.format(primary_address))
70 settings = {'private-address': primary_address, 'hostname': primary_address, 'port': 80}
71 hookenv.relation_set(relation_id=relation_id, relation_settings=settings)
72
73
59@reactive.hook('upgrade-charm')74@reactive.hook('upgrade-charm')
60def upgrade_charm():75def upgrade_charm():
61 '''Handle charm updates'''76 '''Handle charm updates'''
@@ -141,6 +156,7 @@
141 _fix_ssh_ownership(user='www-sync')156 _fix_ssh_ownership(user='www-sync')
142 mirror.peer_update_metadata()157 mirror.peer_update_metadata()
143 service.render_configs()158 service.render_configs()
159 update_website_relation_data()
144160
145161
146@reactive.hook('cluster-relation-departed')162@reactive.hook('cluster-relation-departed')
@@ -213,6 +229,7 @@
213 LOG('leader-settings-changed fired. New leader_id: {}'.format(leader_id))229 LOG('leader-settings-changed fired. New leader_id: {}'.format(leader_id))
214 mirror.peer_update_metadata()230 mirror.peer_update_metadata()
215 service.render_configs()231 service.render_configs()
232 update_website_relation_data()
216233
217234
218# LP:1770071: Work around charm-helper's unison ownership235# LP:1770071: Work around charm-helper's unison ownership

Subscribers

People subscribed via source and target branches