Merge ~hloeung/content-cache-charm:cleanup into content-cache-charm:master

Proposed by Haw Loeung
Status: Merged
Approved by: Haw Loeung
Approved revision: 6d00a1587198c8dedf4ca472ed9fba5bc6dcee8c
Merged at revision: 7a7df738a914cf3e5b2cfcc744febd01a60c4e3c
Proposed branch: ~hloeung/content-cache-charm:cleanup
Merge into: content-cache-charm:master
Diff against target: 112 lines (+12/-12)
2 files modified
reactive/content_cache.py (+6/-6)
tests/unit/test_content_cache.py (+6/-6)
Reviewer Review Type Date Requested Status
Joel Sing (community) +1 Approve
Canonical IS Reviewers Pending
Review via email: mp+381425@code.launchpad.net

Commit message

Fixed flag names to reflect changes to reload in 507191d96dbfdfa5e01b8a2e6135975cce830f4f

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
Joel Sing (jsing) wrote :

LGTM

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

Change successfully merged at revision 7a7df738a914cf3e5b2cfcc744febd01a60c4e3c

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/reactive/content_cache.py b/reactive/content_cache.py
index 08f9bbc..a20cdbb 100644
--- a/reactive/content_cache.py
+++ b/reactive/content_cache.py
@@ -66,7 +66,7 @@ def set_active():
66 reactive.set_flag('content_cache.active')66 reactive.set_flag('content_cache.active')
6767
6868
69@reactive.when_any('content_cache.haproxy.restart-required', 'content_cache.nginx.restart-required')69@reactive.when_any('content_cache.haproxy.reload-required', 'content_cache.nginx.reload-required')
70def service_start_or_reload():70def service_start_or_reload():
71 services = ['haproxy', 'nginx']71 services = ['haproxy', 'nginx']
7272
@@ -75,7 +75,7 @@ def service_start_or_reload():
75 if not host.service_running(name):75 if not host.service_running(name):
76 status.maintenance('Starting {}...'.format(name))76 status.maintenance('Starting {}...'.format(name))
77 host.service_start(name)77 host.service_start(name)
78 reactive.clear_flag('content_cache.{}.restart-required'.format(name))78 reactive.clear_flag('content_cache.{}.reload-required'.format(name))
7979
80 random.seed()80 random.seed()
81 rnd = (random.random() * 100) % 2081 rnd = (random.random() * 100) % 20
@@ -84,11 +84,11 @@ def service_start_or_reload():
8484
85 for name in services:85 for name in services:
86 if reactive.is_flag_set('content_cache.{}.configured'.format(name)) and reactive.is_flag_set(86 if reactive.is_flag_set('content_cache.{}.configured'.format(name)) and reactive.is_flag_set(
87 'content_cache.{}.restart-required'.format(name)87 'content_cache.{}.reload-required'.format(name)
88 ):88 ):
89 status.maintenance('Reloading {}...'.format(name))89 status.maintenance('Reloading {}...'.format(name))
90 host.service_reload(name)90 host.service_reload(name)
91 reactive.clear_flag('content_cache.{}.restart-required'.format(name))91 reactive.clear_flag('content_cache.{}.reload-required'.format(name))
9292
9393
94def configure_nginx_metrics(ngx_conf, enable_prometheus_metrics):94def configure_nginx_metrics(ngx_conf, enable_prometheus_metrics):
@@ -186,7 +186,7 @@ def configure_nginx(conf_path=None):
186 changed = True186 changed = True
187187
188 if changed:188 if changed:
189 reactive.set_flag('content_cache.nginx.restart-required')189 reactive.set_flag('content_cache.nginx.reload-required')
190190
191 update_logrotate('nginx', retention=config.get('log_retention'))191 update_logrotate('nginx', retention=config.get('log_retention'))
192 reactive.set_flag('content_cache.nginx.configured')192 reactive.set_flag('content_cache.nginx.configured')
@@ -315,7 +315,7 @@ def configure_haproxy(): # NOQA: C901 LP#1825084
315 )315 )
316316
317 if haproxy.write(rendered_config):317 if haproxy.write(rendered_config):
318 reactive.set_flag('content_cache.haproxy.restart-required')318 reactive.set_flag('content_cache.haproxy.reload-required')
319319
320 update_logrotate('haproxy', retention=config.get('log_retention'))320 update_logrotate('haproxy', retention=config.get('log_retention'))
321 reactive.set_flag('content_cache.haproxy.configured')321 reactive.set_flag('content_cache.haproxy.configured')
diff --git a/tests/unit/test_content_cache.py b/tests/unit/test_content_cache.py
index 1abaff0..4cfe7e9 100644
--- a/tests/unit/test_content_cache.py
+++ b/tests/unit/test_content_cache.py
@@ -196,7 +196,7 @@ class TestCharm(unittest.TestCase):
196196
197 opened_ports.return_value = ['80/tcp', '{0}/tcp'.format(nginx.METRICS_PORT)]197 opened_ports.return_value = ['80/tcp', '{0}/tcp'.format(nginx.METRICS_PORT)]
198 content_cache.configure_nginx(self.tmpdir)198 content_cache.configure_nginx(self.tmpdir)
199 set_flag.assert_has_calls([mock.call('content_cache.nginx.restart-required')])199 set_flag.assert_has_calls([mock.call('content_cache.nginx.reload-required')])
200 close_port.assert_called_once_with(nginx.METRICS_PORT, 'TCP')200 close_port.assert_called_once_with(nginx.METRICS_PORT, 'TCP')
201201
202 # Re-run with same set of sites, no change so shouldn't need to restart Nginx202 # Re-run with same set of sites, no change so shouldn't need to restart Nginx
@@ -204,7 +204,7 @@ class TestCharm(unittest.TestCase):
204 close_port.reset_mock()204 close_port.reset_mock()
205 opened_ports.return_value = ['80/tcp']205 opened_ports.return_value = ['80/tcp']
206 content_cache.configure_nginx(self.tmpdir)206 content_cache.configure_nginx(self.tmpdir)
207 self.assertFalse(mock.call('content_cache.nginx.restart-required') in set_flag.call_args_list)207 self.assertFalse(mock.call('content_cache.nginx.reload-required') in set_flag.call_args_list)
208 close_port.assert_not_called()208 close_port.assert_not_called()
209209
210 sites = [210 sites = [
@@ -386,7 +386,7 @@ site1.local:
386 'charmhelpers.core.hookenv.opened_ports', return_value=["443/tcp"]386 'charmhelpers.core.hookenv.opened_ports', return_value=["443/tcp"]
387 ), mock.patch('charmhelpers.core.hookenv.open_port'), mock.patch('charmhelpers.core.hookenv.close_port'):387 ), mock.patch('charmhelpers.core.hookenv.open_port'), mock.patch('charmhelpers.core.hookenv.close_port'):
388 content_cache.configure_haproxy()388 content_cache.configure_haproxy()
389 set_flag.assert_has_calls([mock.call('content_cache.haproxy.restart-required')])389 set_flag.assert_has_calls([mock.call('content_cache.haproxy.reload-required')])
390390
391 # Again, this time should be no change so no need to restart HAProxy391 # Again, this time should be no change so no need to restart HAProxy
392 set_flag.reset_mock()392 set_flag.reset_mock()
@@ -394,7 +394,7 @@ site1.local:
394 'charmhelpers.core.hookenv.open_port'394 'charmhelpers.core.hookenv.open_port'
395 ), mock.patch('charmhelpers.core.hookenv.close_port'):395 ), mock.patch('charmhelpers.core.hookenv.close_port'):
396 content_cache.configure_haproxy()396 content_cache.configure_haproxy()
397 self.assertFalse(mock.call('content_cache.haproxy.restart-required') in set_flag.call_args_list)397 self.assertFalse(mock.call('content_cache.haproxy.reload-required') in set_flag.call_args_list)
398398
399 with open('tests/unit/files/content_cache_rendered_haproxy_test_output.txt', 'r', encoding='utf-8') as f:399 with open('tests/unit/files/content_cache_rendered_haproxy_test_output.txt', 'r', encoding='utf-8') as f:
400 want = f.read()400 want = f.read()
@@ -1125,7 +1125,7 @@ site1.local:
11251125
1126 opened_ports.return_value = ['80/tcp', '443/tcp']1126 opened_ports.return_value = ['80/tcp', '443/tcp']
1127 content_cache.configure_nginx(self.tmpdir)1127 content_cache.configure_nginx(self.tmpdir)
1128 set_flag.assert_has_calls([mock.call('content_cache.nginx.restart-required')])1128 set_flag.assert_has_calls([mock.call('content_cache.nginx.reload-required')])
1129 open_port.assert_called_once_with(nginx.METRICS_PORT, 'TCP')1129 open_port.assert_called_once_with(nginx.METRICS_PORT, 'TCP')
11301130
1131 # Re-run with same set of sites, no change so shouldn't need to restart Nginx1131 # Re-run with same set of sites, no change so shouldn't need to restart Nginx
@@ -1133,7 +1133,7 @@ site1.local:
1133 open_port.reset_mock()1133 open_port.reset_mock()
1134 opened_ports.return_value = ['80/tcp', '443/tcp', '{0}/tcp'.format(nginx.METRICS_PORT)]1134 opened_ports.return_value = ['80/tcp', '443/tcp', '{0}/tcp'.format(nginx.METRICS_PORT)]
1135 content_cache.configure_nginx(self.tmpdir)1135 content_cache.configure_nginx(self.tmpdir)
1136 self.assertFalse(mock.call('content_cache.nginx.restart-required') in set_flag.call_args_list)1136 self.assertFalse(mock.call('content_cache.nginx.reload-required') in set_flag.call_args_list)
1137 open_port.assert_not_called()1137 open_port.assert_not_called()
11381138
1139 # Test the site with cache HIT logging1139 # Test the site with cache HIT logging

Subscribers

People subscribed via source and target branches