juju interprets model config values passed on the cli as yaml

Bug #1833110 reported by Jason Hobbs
22
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Canonical Juju
Triaged
Low
Unassigned

Bug Description

juju is parsing config values of cli parameters as yaml. This is not documented behavior:

This is fine, it doesn't see it as a dictionary, just a string:
jason@inire:~/anbox_project$ juju model-defaults
cloudinit-userdata='ca_cert blah'

If I add a colon it sees it as a dictionary and breaks:
jason@inire:~/anbox_project$ juju model-defaults
cloudinit-userdata='ca_cert: blah'
ERROR json: unsupported type: map[interface {}]interface {}

If I add an extra set of single quotes it works fine again:
jason@inire:~/anbox_project$ juju model-defaults
cloudinit-userdata='"ca_cert: blah"'

It seems like juju is interpreting the value of model default config parameters as yaml in both cases - Why is it doing that? that's not documented in the help. Given that it seems to just want a string value, that's very weird.

This came up in bug 1832974.

tags: added: cdo-qa foundations-engine
Revision history for this message
Heather Lanigan (hmlanigan) wrote :

juju model-config and juju model-defaults give different responses:

juju model-config cloudinit-userdata='ca-certs blah'
ERROR cloudinit-userdata: must be valid YAML: yaml: unmarshal errors:
  line 1: cannot unmarshal !!str `ca-cert...` into map[string]interface {}

Revision history for this message
Jason Hobbs (jason-hobbs) wrote :

Even with quoting it doesn't work in some cases:

['juju', 'bootstrap', '--config', 'bootstrap-timeout=1800', '--model-default', "cloudinit-userdata='ca-certs:\n trusted:\n - |\n -----BEGIN CERTIFICATE-----\n MIIDrzCCApegAwIBAgIJAO4AAZTYo3PAMA0GCSqGSIb3DQEBCwUAMG4xCzAJBgNV\n BAYTAlVTMREwDwYDVQQIDAhNaWNoaWdhbjEPMA0GA1UEBwwGT2tlbW9zMS8wLQYD\n VQQKDCZSZW5haXNzYW5jZSBIZWFsdGggU2VydmljZSBDb3Jwb3JhdGlvbjEKMAgG\n A1UEAwwBKjAeFw0xNjEyMDgwNDAwMjZaFw0yNjEyMDYwNDAwMjZaMG4xCzAJBgNV\n BAYTAlVTMREwDwYDVQQIDAhNaWNoaWdhbjEPMA0GA1UEBwwGT2tlbW9zMS8wLQYD\n VQQKDCZSZW5haXNzYW5jZSBIZWFsdGggU2VydmljZSBDb3Jwb3JhdGlvbjEKMAgG\n A1UEAwwBKjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMvKIkeiYNi6\n uKXiZ6STVoAI6/CwfJNrBgXht8Jq3CuUXXAN8TLyuIKZDdra9LXia6yjCZeK1vQe\n mS/xWlNH1JX0CQDn5LYwknLM1eO78xnsRAp6gSsDn8D5EZvHpNjWgIq0bh6UsZcK\n W2islPpyNRQG4bia4hRXL3JIc9JZC40QLUborV0tIhTylbvhHjWbRGy1wRRvCP4u\n 8eqnKzHcZ/FCRzK4K0u58YEwhKP9GF3eImjqY253vno5EyhjXnxfKTa1L186+LEn\n +5AekS4PgPGSYenOhaYnG4PG9QXxhZvLPNgiTE94HaOxX3wN89d+Oqn7Ks8E7YiE\n q5ud8sjXwSUCAwEAAaNQME4wHQYDVR0OBBYEFJnlVi54kMJkc1lTMlwaGwapzQIl\n MB8GA1UdIwQYMBaAFJnlVi54kMJkc1lTMlwaGwapzQIlMAwGA1UdEwQFMAMBAf8w\n DQYJKoZIhvcNAQELBQADggEBAI3a19/5uft0CHIoDnkc83eIkqsj4fYk41t3An41\n wk2CWvyPNk93xgDTwl7S6FtsuqaJ7srfSB5PcbRgToUkJyHizWuD9Q2+SfxbTgcn\n GwkWPRXK5jQvwJoIXQk25/Z8rks0KBaA2ZPdK2dAoeXxcuCWp+c79LQDSYPt4pbG\n 2u+ZFuj9EGLxf7ge7dRja+i18YUOPDBv3XA3dKCUprOpqn89FQPrgLkmMpU/YiEf\n SceG8zGQex/AApHPuUZ3KHhTEA6OPayn/TVZycxV/oFWv+fXd0VxcxaksU3/gaT0\n NpSDvFVYgezHZm9iEgsBwsyrbGC+ajKcCDQUru3IDpbC8fc= \n -----END CERTIFICATE-----\n'", 'lxd', 'lxd_controller']
ERROR cloudinit-userdata: must be valid YAML: yaml: mapping values are not allowed in this context

This is valid yaml - it parses fine with python's yaml parser. Why is it even trying to interpret this as yaml? Where is the error?

Changed in juju:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
John A Meinel (jameinel) wrote : Re: [Bug 1833110] Re: juju interprets model config values passed on the cli as yaml

Just to be clear, this happens from the CLI, it isn't because of anything
with Python in the mix. I was able to reproduce with:
$ juju bootstrap --debug lxd lxd --model-default
"cloudinit-userdata='ca-certs:
  trusted:
  - |
    -----BEGIN CERTIFICATE-----
    MIIDrzCCApegAwIBAgIJAO4AAZTYo3PAMA0GCSqGSIb3DQEBCwUAMG4xCzAJBgNV
...
    NpSDvFVYgezHZm9iEgsBwsyrbGC+ajKcCDQUru3IDpbC8fc=
    -----END CERTIFICATE-----
'"

On Mon, Jun 17, 2019 at 10:10 PM Heather Lanigan <email address hidden>
wrote:

> ** Changed in: juju
> Importance: Undecided => Medium
>
> ** Changed in: juju
> Status: New => Triaged
>
> --
> You received this bug notification because you are subscribed to juju.
> Matching subscriptions: juju bugs
> https://bugs.launchpad.net/bugs/1833110
>
> Title:
> juju interprets model config values passed on the cli as yaml
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/juju/+bug/1833110/+subscriptions
>

Felipe Reyes (freyes)
tags: added: seg
Jeff Hillman (jhillman)
tags: added: cpe-onsite
tags: added: sts
Ian Booth (wallyworld)
Changed in juju:
milestone: none → 2.8.8
Changed in juju:
milestone: 2.8.8 → 2.8.9
Changed in juju:
milestone: 2.8.9 → 2.8.10
Changed in juju:
milestone: 2.8.10 → 2.8.11
Revision history for this message
John A Meinel (jameinel) wrote :

so all of config gets interpret as YAML (IIRC), as that is the way we allow integers to be read properly rather than just always be strings.

For application config we support reading a config.yaml file, which might be a much cleaner way to express this.

I'm also not sure if it would have worked if we had done:

$ juju bootstrap --debug lxd lxd --model-default
cloudinit-userdata="'ca-certs:
  trusted:
  - |
    -----BEGIN CERTIFICATE-----
    MIIDrzCCApegAwIBAgIJAO4AAZTYo3PAMA0GCSqGSIb3DQEBCwUAMG4xCzAJBgNV
...
    NpSDvFVYgezHZm9iEgsBwsyrbGC+ajKcCDQUru3IDpbC8fc=
    -----END CERTIFICATE-----
'"

(putting the " after the = instead of before 'cloudinit-userdata')

Changed in juju:
milestone: 2.8.11 → none
Revision history for this message
Canonical Juju QA Bot (juju-qa-bot) wrote :

This Medium-priority bug has not been updated in 60 days, so we're marking it Low importance. If you believe this is incorrect, please update the importance.

Changed in juju:
importance: Medium → Low
tags: added: expirebugs-bot
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.