cannot set multi-line relation data values via juju-run
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Canonical Juju |
Fix Released
|
High
|
Harry Pidcock |
Bug Description
I am trying to override monitors relation data to remove a nrpe check.
The value of this key is multi-line yaml:
$ juju run -u nrpe/2 -- relation-get -r77 - keystone/2
egress-subnets: 10.0.8.36/32
ingress-address: 10.0.8.36
monitors: |
monitors:
remote:
nrpe:
apache2: {command: check_apache2}
haproxy: {command: check_haproxy}
memcached: {command: check_memcached}
primary: "True"
private-address: 10.0.8.36
I have saved the value of the 'monitors' key in a local file, and removed the check I don't want:
$ cat /tmp/monitors.yaml
monitors:
remote:
nrpe:
apache2: {command: check_apache2}
haproxy: {command: check_haproxy}
haproxy_
haproxy_
I now want to inject this updated data via relation set. The odd thing is this:
== Works perfectly:
$ juju run -u keystone/2 -- relation-set -r77 monitors="$(cat /tmp/monitors.
== Fails:
$ juju scp /tmp/monitors.yaml keystone/2:/tmp
$ juju ssh keystone/2 -- sudo -i
$ juju-run -r77 keystone/2 relation-set monitors="$(cat /tmp/monitors.
ERROR unrecognized args: ["monitors=
$ juju-run -r77 keystone/2 relation-set monitors=$(cat /tmp/monitors.yaml)
ERROR unrecognized args: ["monitors=
I would expect relation-set to work in the same way both when invoked from within the unit (via juju-run) and from outside of the unit (via juju run). Am I doing something wrong?
In case it matters, this happend on both juju 2.7.3 and 2.7.5.
description: | updated |
Changed in juju: | |
milestone: | none → 2.8-rc1 |
importance: | Undecided → High |
status: | New → Triaged |
Changed in juju: | |
assignee: | nobody → Harry Pidcock (hpidcock) |
Changed in juju: | |
status: | Triaged → In Progress |
Changed in juju: | |
status: | In Progress → Fix Committed |
Changed in juju: | |
status: | Fix Committed → Fix Released |
'juju-run' as currently written takes a single argument to run, so the
entire thing needs to be quoted.eg:
$ juju-run -r77 keystone/2 'relation-set monitors=CONTENT'
From code:
return fmt.Errorf("missing commands") args)
if len(args) < 1 {
}
c.commands, args = args[0], args[1:]
return cmd.CheckEmpty(
^ that last is saying 'the command to run is a single argument to
'juju-run' and there must be no further arguments.
In 'juju run' we do: ring(args. ..)
if len(args) == 1 {
// If just one argument is specified, we don't pass it through
// utils.CommandString in case it contains multiple arguments
// (e.g. juju run --all "sudo whatever"). Passing it through
// utils.CommandString would quote the string, which the backend
// does not expect.
c.commands = args[0]
} else {
c.commands = utils.CommandSt
}
We should probably do the same for 'juju-run'.
On Fri, Apr 3, 2020 at 6:20 PM Andrea Ieri <email address hidden>
wrote:
> ** Description changed: queue} servers} queue} servers} queue} servers} queue} servers} yaml)" yaml)" yaml)"
>
> I am trying to override monitors relation data to remove a nrpe check.
>
> The value of this key is multi-line yaml:
>
> $ juju run -u nrpe/2 -- relation-get -r77 - keystone/2
> egress-subnets: 10.0.8.36/32
> ingress-address: 10.0.8.36
> monitors: |
> - monitors:
> - remote:
> - nrpe:
> - apache2: {command: check_apache2}
> - haproxy: {command: check_haproxy}
> - haproxy_queue: {command: check_haproxy_
> - haproxy_servers: {command: check_haproxy_
> - memcached: {command: check_memcached}
> + monitors:
> + remote:
> + nrpe:
> + apache2: {command: check_apache2}
> + haproxy: {command: check_haproxy}
> + haproxy_queue: {command: check_haproxy_
> + haproxy_servers: {command: check_haproxy_
> + memcached: {command: check_memcached}
> primary: "True"
> private-address: 10.0.8.36
>
> I have saved the value of the 'monitors' key in a local file, and
> removed the check I don't want:
>
> - $ cat /tmp/monitors.yaml
> + $ cat /tmp/monitors.yaml
> monitors:
> - remote:
> - nrpe:
> - apache2: {command: check_apache2}
> - haproxy: {command: check_haproxy}
> - haproxy_queue: {command: check_haproxy_
> - haproxy_servers: {command: check_haproxy_
> + remote:
> + nrpe:
> + apache2: {command: check_apache2}
> + haproxy: {command: check_haproxy}
> + haproxy_queue: {command: check_haproxy_
> + haproxy_servers: {command: check_haproxy_
>
> I now want to inject this updated data via relation set. The odd thing
> is this:
>
> - # Works perfectly:
> - $ juju run -u keystone/2 -- relation-set -r77 monitors="$(cat
> /tmp/monitors.
> + == Works perfectly:
>
> - # Fails:
> + $ juju run -u keystone/2 -- relation-set -r77 monitors="$(cat
> + /tmp/monitors.
> +
> + == Fails:
> +
> $ juju scp /tmp/monitors.yaml keystone/2:/tmp
> $ juju ssh keystone/2 -- sudo -i
> - # juju-run -r77 keystone/2 relation-set monitors="$(cat
> /tmp/monitors.
> +
> + $ juju-run -r77 keystone/2 relation-set monitors="$(cat
>...