Merge ~hloeung/content-cache-charm:nginx-config into content-cache-charm:master

Proposed by Haw Loeung
Status: Merged
Approved by: John Losito
Approved revision: 1ce5dbff8939343f15fbb6de24cc2b4835a4efdb
Merged at revision: 85c6c683af73c31c16c75dfcabe41acc07e538b3
Proposed branch: ~hloeung/content-cache-charm:nginx-config
Merge into: content-cache-charm:master
Diff against target: 50 lines (+20/-1)
2 files modified
reactive/content_cache.py (+13/-1)
tests/unit/test_content_cache.py (+7/-0)
Reviewer Review Type Date Requested Status
John Losito (community) Approve
Canonical IS Reviewers Pending
Review via email: mp+380329@code.launchpad.net

Commit message

Fixed where initial install hook fails because Nginx listens to TCP/80 by default

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
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Unable to determine commit message from repository - please click "Set commit message" and enter the commit message manually.

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

Change successfully merged at revision 85c6c683af73c31c16c75dfcabe41acc07e538b3

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 b778711..558275f 100644
--- a/reactive/content_cache.py
+++ b/reactive/content_cache.py
@@ -83,7 +83,9 @@ def service_start_or_reload():
83 time.sleep(rnd)83 time.sleep(rnd)
8484
85 for name in services:85 for name in services:
86 if reactive.is_flag_set('content_cache.{}.restart-required'.format(name)):86 if reactive.is_flag_set('content_cache.{}.configured'.format(name)) and reactive.is_flag_set(
87 'content_cache.{}.restart-required'.format(name)
88 ):
87 status.maintenance('Reloading {}...'.format(name))89 status.maintenance('Reloading {}...'.format(name))
88 host.service_reload(name)90 host.service_reload(name)
89 reactive.clear_flag('content_cache.{}.restart-required'.format(name))91 reactive.clear_flag('content_cache.{}.restart-required'.format(name))
@@ -115,6 +117,16 @@ def configure_nginx_metrics(ngx_conf, enable_prometheus_metrics):
115 return changed117 return changed
116118
117119
120@reactive.when_not('content_cache.nginx.installed')
121def stop_nginx():
122 # Just by installing the Nginx package, it has a default site configured
123 # and listens on TCP/80. This causes HAProxy to fail until such time as
124 # Nginx is configured and reloaded. We'll just stop it here.
125 host.service_stop('nginx')
126 reactive.set_flag('content_cache.nginx.installed')
127
128
129@reactive.when('content_cache.nginx.installed')
118@reactive.when_not('content_cache.nginx.configured')130@reactive.when_not('content_cache.nginx.configured')
119def configure_nginx(conf_path=None):131def configure_nginx(conf_path=None):
120 status.maintenance('setting up Nginx as caching layer')132 status.maintenance('setting up Nginx as caching layer')
diff --git a/tests/unit/test_content_cache.py b/tests/unit/test_content_cache.py
index 623b091..9e1de72 100644
--- a/tests/unit/test_content_cache.py
+++ b/tests/unit/test_content_cache.py
@@ -141,6 +141,13 @@ class TestCharm(unittest.TestCase):
141 service_start.assert_called_with('nginx')141 service_start.assert_called_with('nginx')
142 service_reload.assert_not_called()142 service_reload.assert_not_called()
143143
144 @mock.patch('charms.reactive.set_flag')
145 @mock.patch('charmhelpers.core.host.service_stop')
146 def test_stop_nginx(self, service_stop, set_flag):
147 content_cache.stop_nginx()
148 service_stop.assert_called_with('nginx')
149 set_flag.assert_called_once_with('content_cache.nginx.installed')
150
144 @mock.patch('charms.reactive.clear_flag')151 @mock.patch('charms.reactive.clear_flag')
145 @mock.patch('reactive.content_cache.update_logrotate')152 @mock.patch('reactive.content_cache.update_logrotate')
146 def test_configure_nginx_no_sites(self, logrotation, clear_flag):153 def test_configure_nginx_no_sites(self, logrotation, clear_flag):

Subscribers

People subscribed via source and target branches