keystone charm makes wrong assumptions about charm directory, fails to deploy with juju-core

Bug #1172722 reported by Andreas Hasenack
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
keystone (Juju Charms Collection)
Fix Released
Undecided
Andreas Hasenack

Bug Description

When deployed with juju-core, this error happens:
2013/04/25 13:53:14 INFO worker/uniter: HOOK Traceback (most recent call last):
2013/04/25 13:53:14 INFO worker/uniter: HOOK File "/var/lib/juju/agents/unit-keystone-0/charm/hooks/config-changed", line 535, in <module>
2013/04/25 13:53:14 INFO worker/uniter: HOOK utils.do_hooks(hooks)
2013/04/25 13:53:14 INFO worker/uniter: HOOK File "/var/lib/juju/agents/unit-keystone-0/charm/hooks/lib/utils.py", line 28, in do_hooks
2013/04/25 13:53:14 INFO worker/uniter: HOOK hook_func()
2013/04/25 13:53:14 INFO worker/uniter: HOOK File "/var/lib/juju/agents/unit-keystone-0/charm/hooks/config-changed", line 386, in config_changed
2013/04/25 13:53:14 INFO worker/uniter: HOOK save_script_rc(**env_vars)
2013/04/25 13:53:14 INFO worker/uniter: HOOK File "/var/lib/juju/agents/unit-keystone-0/charm/hooks/lib/openstack_common.py", line 226, in save_script_rc
2013/04/25 13:53:14 INFO worker/uniter: HOOK with open(juju_rc_path, 'wb') as rc_script:
2013/04/25 13:53:14 INFO worker/uniter: HOOK IOError: [Errno 2] No such file or directory: '/var/lib/juju/units/keystone-0/charm/scripts/scriptrc'

Note the charm directory layout changed between pyjuju and gojuju. In gojuju (juju-core) we have:
root@ip-10-191-189-143:/var/lib/juju# tree -d
.
├── agents
│   ├── machine-1
│   └── unit-keystone-0
│   ├── charm
│   │   ├── hooks
│   │   │   └── lib
│   │   ├── scripts
│   │   └── templates
│   └── state
│   ├── bundles
│   │   └── downloads
│   ├── deployer
│   │   ├── current -> /var/lib/juju/agents/unit-keystone-0/state/deployer/update-%Y%m%d-%H%M%S-0
│   │   └── update-%Y%m%d-%H%M%S-0
│   │   ├── hooks
│   │   │   └── lib
│   │   ├── scripts
│   │   └── templates
│   └── relations
└── tools
    ├── 1.10.0-precise-amd64
    ├── machine-1 -> 1.10.0-precise-amd64
    └── unit-keystone-0 -> 1.10.0-precise-amd64

(I hope the above renders correctly. If not: http://pastebin.ubuntu.com/5601103/)

It was suggested to use $CHARM_DIR instead, if the charm really needs to write that file somewhere inside the charm directory. It's exported by both pyjuju and gojuju.

Tags: landscape

Related branches

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

This fixed it for gojuju, but is untested for pyjuju:

=== modified file 'hooks/lib/openstack_common.py'
--- hooks/lib/openstack_common.py 2013-03-21 18:25:39 +0000
+++ hooks/lib/openstack_common.py 2013-04-25 14:14:55 +0000
@@ -221,8 +221,8 @@
     updated config information necessary to perform health checks or
     service changes.
     """
- unit_name = os.getenv('JUJU_UNIT_NAME').replace('/', '-')
- juju_rc_path = "/var/lib/juju/units/%s/charm/%s" % (unit_name, script_path)
+ charm_dir = os.getenv('CHARM_DIR')
+ juju_rc_path = "%s/%s" % (charm_dir, script_path)
     with open(juju_rc_path, 'wb') as rc_script:
         rc_script.write(
             "#!/bin/bash\n")

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Hmm, this affects a bunch of other openstack charms too.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Just verified and CHARM_DIR is also defined in pyjuju as expected, so the patch works for deployments with both pyjuju and gojuju.

Changed in keystone (Juju Charms Collection):
status: New → In Progress
assignee: nobody → Andreas Hasenack (ahasenack)
Changed in keystone (Juju Charms Collection):
status: In Progress → Fix Released
tags: added: landscape
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.