confusing error message and backtrace in unit agent on non-existant unit passed to relation-get

Bug #1020635 reported by Clint Byrum
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pyjuju
Triaged
Low
Unassigned

Bug Description

Test case:

1. create a charm with a relation hook which stores this yaml using relation-set, like this:

--- begin monitors.yaml ---
version: '0.1'
monitors:
    nrpe:
        mysqld:
            name: MySQL Running
            args:
                command: check_procs
                args: '-c 1: /usr/sbin/mysqld'
    mysql:
        basic:
--- end monitors.yaml ---

#!/bin/sh
relation-set something=$(cat monitors.yaml)

This appears to corrupt the topology node since it is not escaped properly:

2012-07-03 15:17:48,451: twisted@ERROR: Unhandled Error
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1181, in unwindGenerator
    return _inlineCallbacks(None, gen, Deferred())
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1039, in _inlineCallbacks
    result = g.send(result)
  File "/usr/lib/python2.7/dist-packages/juju/state/hook.py", line 258, in _setup_relation_state
    unit_id = yield self._resolve_name(unit_name)
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1181, in unwindGenerator
    return _inlineCallbacks(None, gen, Deferred())
--- <exception caught here> ---
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1039, in _inlineCallbacks
    result = g.send(result)
  File "/usr/lib/python2.7/dist-packages/juju/state/hook.py", line 63, in _resolve_name
    unit_id = self._topology.get_service_unit_id_from_name(unit_name)
  File "/usr/lib/python2.7/dist-packages/juju/state/topology.py", line 262, in get_service_unit_id_from_name
    service_name, unit_sequence_id = unit_name.split("/")
exceptions.ValueError: need more than 1 value to unpack

Revision history for this message
Kapil Thangavelu (hazmat) wrote : Re: [Bug 1020635] [NEW] cannot store yaml in relation settings

do you have a sample charm for this? there is no rel data in the topology,
so it would be interesting to test out.

On Tue, Jul 3, 2012 at 12:04 PM, Clint Byrum <email address hidden> wrote:

> Public bug reported:
>
> Test case:
>
> 1. create a charm with a relation hook which stores this yaml using
> relation-set, like this:
>
> --- begin monitors.yaml ---
> version: '0.1'
> monitors:
> nrpe:
> mysqld:
> name: MySQL Running
> args:
> command: check_procs
> args: '-c 1: /usr/sbin/mysqld'
> mysql:
> basic:
> --- end monitors.yaml ---
>
> #!/bin/sh
> relation-set something=$(cat monitors.yaml)
>
> This appears to corrupt the topology node since it is not escaped
> properly:
>
> 2012-07-03 15:17:48,451: twisted@ERROR: Unhandled Error
> Traceback (most recent call last):
> File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line
> 1181, in unwindGenerator
> return _inlineCallbacks(None, gen, Deferred())
> File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line
> 1039, in _inlineCallbacks
> result = g.send(result)
> File "/usr/lib/python2.7/dist-packages/juju/state/hook.py", line 258, in
> _setup_relation_state
> unit_id = yield self._resolve_name(unit_name)
> File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line
> 1181, in unwindGenerator
> return _inlineCallbacks(None, gen, Deferred())
> --- <exception caught here> ---
> File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line
> 1039, in _inlineCallbacks
> result = g.send(result)
> File "/usr/lib/python2.7/dist-packages/juju/state/hook.py", line 63, in
> _resolve_name
> unit_id = self._topology.get_service_unit_id_from_name(unit_name)
> File "/usr/lib/python2.7/dist-packages/juju/state/topology.py", line
> 262, in get_service_unit_id_from_name
> service_name, unit_sequence_id = unit_name.split("/")
> exceptions.ValueError: need more than 1 value to unpack
>
> ** Affects: juju
> Importance: High
> Status: New
>
> --
> You received this bug notification because you are subscribed to juju.
> https://bugs.launchpad.net/bugs/1020635
>
> Title:
> cannot store yaml in relation settings
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/juju/+bug/1020635/+subscriptions
>

Revision history for this message
Clint Byrum (clint-fewbar) wrote : Re: cannot store yaml in relation settings

[zk: localhost:2181(CONNECTED) 38] get /relations/relation-0000000005/settings/unit-0000000001
monitors:
  monitors:
    mysql: {basic: null}
    nrpe:
      mysqld:is
        args: {args: '-c 1: /usr/sbin/mysqld', command: check_procs}
        name: MySQL Running
  version: '0.1'
private-address: ip-10-248-6-102.us-west-2.compute.internal

cZxid = 0x613

This seems wrong. We have interpreted the yaml as just an extension of the yaml, where users will expect it to just be another string of bytes.

I suspect that somewhere along the way this confuses other pieces of the code which assume only unstructured strings will come out of the relation settings.

If you deploy these:

lp:~clint-fewbar/charms/precise/mysql/add-monitors
lp:~clint-fewbar/charms/precise/nagios/add-monitors

And relate them with the add-monitors relation, the backtrace happens in nagios's unit agent.

Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

Fully agreed.

Revision history for this message
Clint Byrum (clint-fewbar) wrote :

The yaml storage, while important, is actually not the culprit here.

A bug in a hook script was running this:

relation-get monitors m

So the real bug is that this is a backtrace where it should be a simple error "unit m not found"

summary: - cannot store yaml in relation settings
+ confusing error message and backtrace in unit agent on non-existant unit
+ passed to relation-get
Changed in juju:
importance: High → Medium
status: New → Confirmed
Changed in juju:
milestone: none → 0.8
Curtis Hovey (sinzui)
Changed in juju:
status: Confirmed → Triaged
Curtis Hovey (sinzui)
Changed in juju:
importance: Medium → Low
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.