etherpad-lite fails to deploy, install hook running get-relation

Bug #1247636 reported by Erik B. Andersen on 2013-11-03
This bug affects 1 person
Affects Status Importance Assigned to Milestone
etherpad-lite (Juju Charms Collection)
Erik B. Andersen

Bug Description

This is using the local (LXC) environment, on a Saucy (13.10) machine.

The install hook fails.

Here is the output when running the hook again with debug hooks:

gpg: keyring `/tmp/tmpQiOWa6/secring.gpg' created
gpg: keyring `/tmp/tmpQiOWa6/pubring.gpg' created
gpg: requesting key CA763386 from hkp server
gpg: /tmp/tmpQiOWa6/trustdb.gpg: trustdb created
gpg: key CA763386: public key "Launchpad PPA for Onestone" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
Get:1 precise Release.gpg [198 B]
Get:2 precise-updates/cloud-tools Release.gpg [543 B]
Get:3 precise-security Release.gpg [198 B]
Get:4 precise-updates Release.gpg [198 B]
Get:5 precise-updates/cloud-tools Release [5,486 B]
Get:6 precise-security Release [49.6 kB]
Get:7 precise Release.gpg [316 B]
Get:8 precise Release [49.6 kB]
Get:9 precise-updates Release [49.6 kB]
Get:10 precise-updates/cloud-tools/main amd64 Packages [21.2 kB]
Get:11 precise-security/main Sources [92.1 kB]
Get:12 precise Release [11.9 kB]
Get:13 precise/main Sources [934 kB]
Get:14 precise/universe Sources [5,019 kB]
Get:15 precise-updates/cloud-tools/main i386 Packages [21.2 kB]
Get:16 precise-security/universe Sources [29.3 kB]
Get:17 precise/main amd64 Packages [1,273 kB]
Get:18 precise/main Sources [1,278 B]
Get:19 precise-security/main amd64 Packages [334 kB]
Get:20 precise/universe amd64 Packages [4,786 kB]
Get:21 precise/main amd64 Packages [1,691 B]
Get:22 precise-security/universe amd64 Packages [84.0 kB]
Ign precise-updates/cloud-tools/main TranslationIndex
Get:23 precise/main i386 Packages [1,274 kB]
Get:24 precise-security/main i386 Packages [353 kB]
Get:25 precise/main i386 Packages [1,696 B]
Get:26 precise/universe i386 Packages [4,796 kB]
Get:27 precise-security/universe i386 Packages [87.9 kB]
Get:28 precise/main TranslationIndex [3,706 B]
Get:29 precise/universe TranslationIndex [2,922 B]
Get:30 precise-security/main TranslationIndex [74 B]
Get:31 precise-updates/main Sources [423 kB]
Ign precise/main TranslationIndex
Get:32 precise-updates/universe Sources [98.8 kB]
Get:33 precise-security/universe TranslationIndex [73 B]
Get:34 precise-updates/main amd64 Packages [702 kB]
Get:35 precise-security/main Translation-en [158 kB]
Get:36 precise-updates/universe amd64 Packages [221 kB]
Get:37 precise-updates/main i386 Packages [722 kB]
Get:38 precise-security/universe Translation-en [53.4 kB]
Get:39 precise-updates/universe i386 Packages [225 kB]
Get:40 precise-updates/main TranslationIndex [3,564 B]
Get:41 precise-updates/universe TranslationIndex [2,850 B]
Get:42 precise/main Translation-en [726 kB]
Get:43 precise/universe Translation-en [3,341 kB]
Get:44 precise-updates/main Translation-en [317 kB]
Get:45 precise-updates/universe Translation-en [129 kB]
Ign precise-updates/cloud-tools/main Translation-en_US
Ign precise-updates/cloud-tools/main Translation-en
Ign precise/main Translation-en_US
Ign precise/main Translation-en
Fetched 26.4 MB in 6s (4,358 kB/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
abiword is already the newest version.
daemon is already the newest version.
bzr is already the newest version.
curl is already the newest version.
nodejs is already the newest version.
npm is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
You have not informed bzr of your Launchpad ID, and you must do this to
write to Launchpad or access private data. See "bzr help launchpad-login".
Branched 4 revisions.
error: no relation id specified
Traceback (most recent call last):
  File "hooks/install", line 177, in <module>
  File "/var/lib/juju/agents/unit-etherpad-lite-1/charm/hooks/charmhelpers/core/", line 256, in execute
  File "hooks/install", line 124, in install
    symlink(installdir, APP_DIR)
  File "/var/lib/juju/agents/unit-etherpad-lite-1/charm/hooks/charmhelpers/core/", line 81, in symlink
    context = execution_environment()
  File "/var/lib/juju/agents/unit-etherpad-lite-1/charm/hooks/charmhelpers/core/", line 69, in execution_environment
    context['rel'] = relation_get()
  File "/var/lib/juju/agents/unit-etherpad-lite-1/charm/hooks/charmhelpers/core/", line 122, in relation_get
    return json.loads(subprocess.check_output(_args))
  File "/usr/lib/python2.7/", line 544, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['relation-get', '--format=json', '-']' returned non-zero exit status 2

It appears this happens because relation get is called and returns an error (which I think would be normal if you call it in an install hook?)

Related branches

Erik B. Andersen (azendale) wrote :

I changed the file charmhelpers/core/ 's definition of relation_get to this and it worked (deployed and the service was working after the deploy):

def relation_get(attribute=None, unit=None, rid=None):
    _args = ['relation-get', '--format=json']
    if rid:
    _args.append(attribute or '-')
    if unit:
        return json.loads(subprocess.check_output(_args))
    except ValueError:
        return None
    except subprocess.CalledProcessError as e:
        if e.returncode is 2:
            return None
            raise e

Erik B. Andersen (azendale) wrote :

(I don't know if the above fix is a proper one, I would appreciate feedback).

Erik B. Andersen (azendale) wrote :

marcoceppi gave some feedback on IRC:

(02:55:31 PM) Azendale: marcoceppi: The change I made on the bug I filed was just to get it to work. But I'm really new to charm stuff (but used to python), so I don't know exactly what is the bug.
(02:55:53 PM) marcoceppi: Azendale: well, you can't (and shouldn't) be able to call relation-get from install hook
(02:56:01 PM) Azendale: marcoceppi: I'm not sure if that function should not be called in the first place in an install hook, or if the function should just return None
(02:56:04 PM) marcoceppi: so it seems the charm is doing something wrong
(02:57:13 PM) marcoceppi: Azendale: but there's nothing wrong with building in guards. So charmhelpers is a set of scripts designed to solve common problems that charm authors have. One problem is making writing charms in python easier. So that's why you have decorators and methods in python that streamline communication to juju commands
(02:57:58 PM) Azendale: marcoceppi: So, you're saying maybe fix the bug in two places, and then it's less likely to come up again in some other charm
(02:59:03 PM) marcoceppi: Azendale: the real problem is in the install hook, it shouldn't be calling that, and if it is, it needs to guard when results aren't available
(02:59:20 PM) marcoceppi: Azendale: the change to charmhelpers is a nice addition, not really a bug fix per se
(02:59:23 PM) marcoceppi: Azendale: but still
(03:01:06 PM) marcoceppi: Azendale: actually, having it fail like this when a relation_id isn't found is probably a good thing. Silently continuing when the method is called out of place could lead to weird results

summary: - etherpad lite fails to deploy, install hook running get relation
+ etherpad lite fails to deploy, install hook running get-relation
summary: - etherpad lite fails to deploy, install hook running get-relation
+ etherpad-lite fails to deploy, install hook running get-relation
Marco Ceppi (marcoceppi) on 2013-11-04
affects: charms → etherpad-lite (Juju Charms Collection)
Erik B. Andersen (azendale) wrote :

Long story short, it appears that the error is fixed in the following commit of charm helpers:

I just need to get etherpad-lite using the latest and this should be fixed.

Erik B. Andersen (azendale) wrote :

I just attached the first attempt at fixing this, which works. I think it may have more charm helper dependencies that it needs though, so, I'm going to try another attempt at fixing it.

Erik B. Andersen (azendale) wrote :

I stripped down the charm helpers dependencies and did a sync and it still works and the bug is fixed. I push this to the two branches linked to this bug that have "fix2" in the name. (Sorry, I'm still getting used to putting branches on LP, so sorry for the multiple versions).

Please note that you should merge one (and only) one branch (otherwise there will probably be merge conflicts.)

I would suggest lp:~azendale/charms/precise/etherpad-lite/lp1247636-fix-try2.

Changed in etherpad-lite (Juju Charms Collection):
status: New → In Progress
Changed in etherpad-lite (Juju Charms Collection):
assignee: nobody → Erik B. Andersen (azendale)
Changed in etherpad-lite (Juju Charms Collection):
status: In Progress → Fix Committed
Marco Ceppi (marcoceppi) on 2013-11-07
Changed in etherpad-lite (Juju Charms Collection):
importance: Undecided → High
Marco Ceppi (marcoceppi) on 2013-11-10
Changed in etherpad-lite (Juju Charms Collection):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers