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
1diff --git a/reactive/content_cache.py b/reactive/content_cache.py
2index 08f9bbc..a20cdbb 100644
3--- a/reactive/content_cache.py
4+++ b/reactive/content_cache.py
5@@ -66,7 +66,7 @@ def set_active():
6 reactive.set_flag('content_cache.active')
7
8
9-@reactive.when_any('content_cache.haproxy.restart-required', 'content_cache.nginx.restart-required')
10+@reactive.when_any('content_cache.haproxy.reload-required', 'content_cache.nginx.reload-required')
11 def service_start_or_reload():
12 services = ['haproxy', 'nginx']
13
14@@ -75,7 +75,7 @@ def service_start_or_reload():
15 if not host.service_running(name):
16 status.maintenance('Starting {}...'.format(name))
17 host.service_start(name)
18- reactive.clear_flag('content_cache.{}.restart-required'.format(name))
19+ reactive.clear_flag('content_cache.{}.reload-required'.format(name))
20
21 random.seed()
22 rnd = (random.random() * 100) % 20
23@@ -84,11 +84,11 @@ def service_start_or_reload():
24
25 for name in services:
26 if reactive.is_flag_set('content_cache.{}.configured'.format(name)) and reactive.is_flag_set(
27- 'content_cache.{}.restart-required'.format(name)
28+ 'content_cache.{}.reload-required'.format(name)
29 ):
30 status.maintenance('Reloading {}...'.format(name))
31 host.service_reload(name)
32- reactive.clear_flag('content_cache.{}.restart-required'.format(name))
33+ reactive.clear_flag('content_cache.{}.reload-required'.format(name))
34
35
36 def configure_nginx_metrics(ngx_conf, enable_prometheus_metrics):
37@@ -186,7 +186,7 @@ def configure_nginx(conf_path=None):
38 changed = True
39
40 if changed:
41- reactive.set_flag('content_cache.nginx.restart-required')
42+ reactive.set_flag('content_cache.nginx.reload-required')
43
44 update_logrotate('nginx', retention=config.get('log_retention'))
45 reactive.set_flag('content_cache.nginx.configured')
46@@ -315,7 +315,7 @@ def configure_haproxy(): # NOQA: C901 LP#1825084
47 )
48
49 if haproxy.write(rendered_config):
50- reactive.set_flag('content_cache.haproxy.restart-required')
51+ reactive.set_flag('content_cache.haproxy.reload-required')
52
53 update_logrotate('haproxy', retention=config.get('log_retention'))
54 reactive.set_flag('content_cache.haproxy.configured')
55diff --git a/tests/unit/test_content_cache.py b/tests/unit/test_content_cache.py
56index 1abaff0..4cfe7e9 100644
57--- a/tests/unit/test_content_cache.py
58+++ b/tests/unit/test_content_cache.py
59@@ -196,7 +196,7 @@ class TestCharm(unittest.TestCase):
60
61 opened_ports.return_value = ['80/tcp', '{0}/tcp'.format(nginx.METRICS_PORT)]
62 content_cache.configure_nginx(self.tmpdir)
63- set_flag.assert_has_calls([mock.call('content_cache.nginx.restart-required')])
64+ set_flag.assert_has_calls([mock.call('content_cache.nginx.reload-required')])
65 close_port.assert_called_once_with(nginx.METRICS_PORT, 'TCP')
66
67 # Re-run with same set of sites, no change so shouldn't need to restart Nginx
68@@ -204,7 +204,7 @@ class TestCharm(unittest.TestCase):
69 close_port.reset_mock()
70 opened_ports.return_value = ['80/tcp']
71 content_cache.configure_nginx(self.tmpdir)
72- self.assertFalse(mock.call('content_cache.nginx.restart-required') in set_flag.call_args_list)
73+ self.assertFalse(mock.call('content_cache.nginx.reload-required') in set_flag.call_args_list)
74 close_port.assert_not_called()
75
76 sites = [
77@@ -386,7 +386,7 @@ site1.local:
78 'charmhelpers.core.hookenv.opened_ports', return_value=["443/tcp"]
79 ), mock.patch('charmhelpers.core.hookenv.open_port'), mock.patch('charmhelpers.core.hookenv.close_port'):
80 content_cache.configure_haproxy()
81- set_flag.assert_has_calls([mock.call('content_cache.haproxy.restart-required')])
82+ set_flag.assert_has_calls([mock.call('content_cache.haproxy.reload-required')])
83
84 # Again, this time should be no change so no need to restart HAProxy
85 set_flag.reset_mock()
86@@ -394,7 +394,7 @@ site1.local:
87 'charmhelpers.core.hookenv.open_port'
88 ), mock.patch('charmhelpers.core.hookenv.close_port'):
89 content_cache.configure_haproxy()
90- self.assertFalse(mock.call('content_cache.haproxy.restart-required') in set_flag.call_args_list)
91+ self.assertFalse(mock.call('content_cache.haproxy.reload-required') in set_flag.call_args_list)
92
93 with open('tests/unit/files/content_cache_rendered_haproxy_test_output.txt', 'r', encoding='utf-8') as f:
94 want = f.read()
95@@ -1125,7 +1125,7 @@ site1.local:
96
97 opened_ports.return_value = ['80/tcp', '443/tcp']
98 content_cache.configure_nginx(self.tmpdir)
99- set_flag.assert_has_calls([mock.call('content_cache.nginx.restart-required')])
100+ set_flag.assert_has_calls([mock.call('content_cache.nginx.reload-required')])
101 open_port.assert_called_once_with(nginx.METRICS_PORT, 'TCP')
102
103 # Re-run with same set of sites, no change so shouldn't need to restart Nginx
104@@ -1133,7 +1133,7 @@ site1.local:
105 open_port.reset_mock()
106 opened_ports.return_value = ['80/tcp', '443/tcp', '{0}/tcp'.format(nginx.METRICS_PORT)]
107 content_cache.configure_nginx(self.tmpdir)
108- self.assertFalse(mock.call('content_cache.nginx.restart-required') in set_flag.call_args_list)
109+ self.assertFalse(mock.call('content_cache.nginx.reload-required') in set_flag.call_args_list)
110 open_port.assert_not_called()
111
112 # Test the site with cache HIT logging

Subscribers

People subscribed via source and target branches