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

Bug #1247636 reported by Erik B. Andersen on 2013-11-03
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
etherpad-lite (Juju Charms Collection)
High
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:

hooks/$JUJU_HOOK_NAME
gpg: keyring `/tmp/tmpQiOWa6/secring.gpg' created
gpg: keyring `/tmp/tmpQiOWa6/pubring.gpg' created
gpg: requesting key CA763386 from hkp server keyserver.ubuntu.com
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)
OK
Get:1 http://archive.ubuntu.com precise Release.gpg [198 B]
Get:2 http://ubuntu-cloud.archive.canonical.com precise-updates/cloud-tools Release.gpg [543 B]
Get:3 http://security.ubuntu.com precise-security Release.gpg [198 B]
Get:4 http://archive.ubuntu.com precise-updates Release.gpg [198 B]
Get:5 http://ubuntu-cloud.archive.canonical.com precise-updates/cloud-tools Release [5,486 B]
Get:6 http://security.ubuntu.com precise-security Release [49.6 kB]
Get:7 http://ppa.launchpad.net precise Release.gpg [316 B]
Get:8 http://archive.ubuntu.com precise Release [49.6 kB]
Get:9 http://archive.ubuntu.com precise-updates Release [49.6 kB]
Get:10 http://ubuntu-cloud.archive.canonical.com precise-updates/cloud-tools/main amd64 Packages [21.2 kB]
Get:11 http://security.ubuntu.com precise-security/main Sources [92.1 kB]
Get:12 http://ppa.launchpad.net precise Release [11.9 kB]
Get:13 http://archive.ubuntu.com precise/main Sources [934 kB]
Get:14 http://archive.ubuntu.com precise/universe Sources [5,019 kB]
Get:15 http://ubuntu-cloud.archive.canonical.com precise-updates/cloud-tools/main i386 Packages [21.2 kB]
Get:16 http://security.ubuntu.com precise-security/universe Sources [29.3 kB]
Get:17 http://archive.ubuntu.com precise/main amd64 Packages [1,273 kB]
Get:18 http://ppa.launchpad.net precise/main Sources [1,278 B]
Get:19 http://security.ubuntu.com precise-security/main amd64 Packages [334 kB]
Get:20 http://archive.ubuntu.com precise/universe amd64 Packages [4,786 kB]
Get:21 http://ppa.launchpad.net precise/main amd64 Packages [1,691 B]
Get:22 http://security.ubuntu.com precise-security/universe amd64 Packages [84.0 kB]
Ign http://ubuntu-cloud.archive.canonical.com precise-updates/cloud-tools/main TranslationIndex
Get:23 http://archive.ubuntu.com precise/main i386 Packages [1,274 kB]
Get:24 http://security.ubuntu.com precise-security/main i386 Packages [353 kB]
Get:25 http://ppa.launchpad.net precise/main i386 Packages [1,696 B]
Get:26 http://archive.ubuntu.com precise/universe i386 Packages [4,796 kB]
Get:27 http://security.ubuntu.com precise-security/universe i386 Packages [87.9 kB]
Get:28 http://archive.ubuntu.com precise/main TranslationIndex [3,706 B]
Get:29 http://archive.ubuntu.com precise/universe TranslationIndex [2,922 B]
Get:30 http://security.ubuntu.com precise-security/main TranslationIndex [74 B]
Get:31 http://archive.ubuntu.com precise-updates/main Sources [423 kB]
Ign http://ppa.launchpad.net precise/main TranslationIndex
Get:32 http://archive.ubuntu.com precise-updates/universe Sources [98.8 kB]
Get:33 http://security.ubuntu.com precise-security/universe TranslationIndex [73 B]
Get:34 http://archive.ubuntu.com precise-updates/main amd64 Packages [702 kB]
Get:35 http://security.ubuntu.com precise-security/main Translation-en [158 kB]
Get:36 http://archive.ubuntu.com precise-updates/universe amd64 Packages [221 kB]
Get:37 http://archive.ubuntu.com precise-updates/main i386 Packages [722 kB]
Get:38 http://security.ubuntu.com precise-security/universe Translation-en [53.4 kB]
Get:39 http://archive.ubuntu.com precise-updates/universe i386 Packages [225 kB]
Get:40 http://archive.ubuntu.com precise-updates/main TranslationIndex [3,564 B]
Get:41 http://archive.ubuntu.com precise-updates/universe TranslationIndex [2,850 B]
Get:42 http://archive.ubuntu.com precise/main Translation-en [726 kB]
Get:43 http://archive.ubuntu.com precise/universe Translation-en [3,341 kB]
Get:44 http://archive.ubuntu.com precise-updates/main Translation-en [317 kB]
Get:45 http://archive.ubuntu.com precise-updates/universe Translation-en [129 kB]
Ign http://ubuntu-cloud.archive.canonical.com precise-updates/cloud-tools/main Translation-en_US
Ign http://ubuntu-cloud.archive.canonical.com precise-updates/cloud-tools/main Translation-en
Ign http://ppa.launchpad.net precise/main Translation-en_US
Ign http://ppa.launchpad.net 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>
    hooks.execute(sys.argv)
  File "/var/lib/juju/agents/unit-etherpad-lite-1/charm/hooks/charmhelpers/core/hookenv.py", line 256, in execute
    self._hooks[hook_name]()
  File "hooks/install", line 124, in install
    symlink(installdir, APP_DIR)
  File "/var/lib/juju/agents/unit-etherpad-lite-1/charm/hooks/charmhelpers/core/host.py", line 81, in symlink
    context = execution_environment()
  File "/var/lib/juju/agents/unit-etherpad-lite-1/charm/hooks/charmhelpers/core/hookenv.py", line 69, in execution_environment
    context['rel'] = relation_get()
  File "/var/lib/juju/agents/unit-etherpad-lite-1/charm/hooks/charmhelpers/core/hookenv.py", line 122, in relation_get
    return json.loads(subprocess.check_output(_args))
  File "/usr/lib/python2.7/subprocess.py", line 544, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['relation-get', '--format=json', '-']' returned non-zero exit status 2
e

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/hookenv.py '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('-r')
        _args.append(rid)
    _args.append(attribute or '-')
    if unit:
        _args.append(unit)
    try:
        return json.loads(subprocess.check_output(_args))
    except ValueError:
        return None
    except subprocess.CalledProcessError as e:
        print(repr(e))
        if e.returncode is 2:
            return None
        else:
            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:

http://bazaar.launchpad.net/~charm-helpers/charm-helpers/devel/revision/87

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