Merge lp:~thedac/charms/precise/gunicorn/fix-config-changed into lp:~charmers/charms/precise/gunicorn/trunk

Proposed by David Ames
Status: Rejected
Rejected by: Matt Bruzek
Proposed branch: lp:~thedac/charms/precise/gunicorn/fix-config-changed
Merge into: lp:~charmers/charms/precise/gunicorn/trunk
Diff against target: 67 lines (+12/-10)
2 files modified
README.md (+8/-6)
hooks/hooks.py (+4/-4)
To merge this branch: bzr merge lp:~thedac/charms/precise/gunicorn/fix-config-changed
Reviewer Review Type Date Requested Status
Matt Bruzek (community) Needs Fixing
Review via email: mp+211638@code.launchpad.net

Description of the change

The config-changed hook does not have JUJU_REMOTE_UNIT set in the environment. This uses the relation data to get the remote unit name.

To post a comment you must log in.
Revision history for this message
Matt Bruzek (mbruzek) wrote :

I took a look at this merge proposal and found the gunicorn README is not correct. I added to the existing bug here: https://bugs.launchpad.net/charms/+source/gunicorn/+bug/1193026

Got the new code with:
bzr branch lp:~bloodearnest/charms/precise/gunicorn/upgrade-path precise/gunicorn

I was able to get the code in this charm to deploy successfully with the following commands (from the python-django README):

juju bootstrap -e local
juju deploy python-django
juju deploy postgresql
add-relation python-django postgresql:db
juju deploy local:precise/gunicorn
juju expose python-django
juju add-relation python-django gunicorn

I was then able to verify that both the new and old format works by looking in the /etc/init/gunicorn.conf for changes when I ran the following commands:
juju run --unit python-django/0 "relation-ids wsgi" (the output me to use wgsi:2)
juju run --unit python-django/0 "relation-set -r wsgi:2 env_extra='A=5'" (the new format)
juju run --unit python-django/0 'relation-set -r wsgi:2 env_extra="\"A\":2"' (the old format)

+1 LGTM

31. By David Ames

Update README with working deploy directions

Revision history for this message
Simon Davy (bloodearnest) wrote :
Revision history for this message
Simon Davy (bloodearnest) wrote :
Revision history for this message
Matt Bruzek (mbruzek) wrote :
review: Needs Fixing
Revision history for this message
Matt Bruzek (mbruzek) wrote :

Hello David,

Thank you for your submission, this problem was address by Simon Davy (bloodearnest) in a different merge propsoal that was merged today. I rejected this merge proposal because the problem was already addressed by the merge. Please contact me or reopen the merge proposal if you have anything else to add.

Thank you,

  - Matt Bruzek

Unmerged revisions

31. By David Ames

Update README with working deploy directions

30. By David Ames

Fix broken config-changed hook. Config-changed does not have JUJU_REMOTE_UNIT set in the environment

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README.md'
2--- README.md 2013-08-02 19:14:04 +0000
3+++ README.md 2014-04-18 20:22:57 +0000
4@@ -20,16 +20,18 @@
5 1. Deployment with python-moinmoin for example::
6
7 juju bootstrap
8- juju deploy --config mywiki_with_wsgi_settings.yaml python-moinmoin
9+ juju deploy python-django
10+ juju deploy postgresql
11+ juju add-relation python-django postgresql:db
12 juju deploy gunicorn
13- juju add-relation gunicorn python-moinmoin
14- juju expose python-moinmoin
15+ juju expose python-django
16+ juju add-relation python-django gunicorn
17
18- 1. Accessing your new wiki should be ready at::
19+ 1. Accessing your new django site should be ready at::
20
21 http://<machine-addr>:8080/
22
23- To find out the public address of gunicorn/python-moinmoin, look for it in
24+ To find out the public address of gunicorn/python-django, look for it in
25 the output of the `juju status` command.
26 I recommend using a reverse proxy like Nginx in front of Gunicorn.
27
28@@ -49,4 +51,4 @@
29 - no start/stop hook anymore use related charms instead.
30 - no configuration change directly on the charm anymore, use related charms instead.
31 - no access logging by default
32-- exposing a port must now be done in the linked charm instead of this one
33\ No newline at end of file
34+- exposing a port must now be done in the linked charm instead of this one
35
36=== modified file 'hooks/hooks.py'
37--- hooks/hooks.py 2014-02-27 14:54:18 +0000
38+++ hooks/hooks.py 2014-04-18 20:22:57 +0000
39@@ -29,8 +29,8 @@
40 return s
41
42
43-def sanitized_service_name():
44- return sanitize(hookenv.remote_unit().split('/')[0])
45+def sanitized_service_name(service_name):
46+ return sanitize(service_name.split('/')[0])
47
48
49 def upstart_conf_path(name):
50@@ -76,7 +76,7 @@
51
52 relation_data = relations[0]
53
54- service_name = sanitized_service_name()
55+ service_name = sanitized_service_name(relation_data['__unit__'])
56 wsgi_config['unit_name'] = service_name
57
58 project_conf = upstart_conf_path(service_name)
59@@ -117,7 +117,7 @@
60
61 @hooks.hook("wsgi_file_relation_broken")
62 def wsgi_file_relation_broken():
63- service_name = sanitized_service_name()
64+ service_name = sanitized_service_name(hookenv.remote_unit())
65 host.service_stop(service_name)
66 try:
67 os.remove(upstart_conf_path(service_name))

Subscribers

People subscribed via source and target branches

to all changes: