juju / docs

Juju documentation, edited on https://discourse.charmhub.io/, and published on https://juju.is/docs
https://juju.is/docs
23 stars 103 forks source link

https://jujucharms.com/docs/2.2/authors-charm-config doc is incorrect about default values #2244

Closed hyperbolic2346 closed 7 years ago

hyperbolic2346 commented 7 years ago

If the default value is left empty as described in this document, proof will complain about it:

"proof: I: config.yaml: option extra_sans has no default value"

Is proof wrong here or is the documentation?

pmatulis commented 7 years ago

Thanks. I'll look into it. :confounded:

pmatulis commented 7 years ago

AIUI, this breaks: default:

and this works: default: ""

pmatulis commented 7 years ago

In the mysql charm's config.yaml,

I changed from this:

    prefer-ipv6:
        type: boolean
        default: False

to this:

    prefer-ipv6:
        type: boolean
        default:

And got this in the unit's logs:

2017-10-26 00:41:38 DEBUG config-changed Traceback (most recent call last):
2017-10-26 00:41:38 DEBUG config-changed   File "/var/lib/juju/agents/unit-mysql-0/charm/hooks/config-changed", line 80, in <module>
2017-10-26 00:41:38 DEBUG config-changed     if configs['prefer-ipv6']:
2017-10-26 00:41:38 DEBUG config-changed KeyError: 'prefer-ipv6'
2017-10-26 00:41:38 ERROR juju.worker.uniter.operation runhook.go:108 hook "config-changed" failed: exit status 1
2017-10-26 00:41:38 INFO juju.worker.uniter resolver.go:100 awaiting error resolution for "config-changed" hook
2017-10-26 00:41:58 INFO juju.worker.uniter resolver.go:100 awaiting error resolution for "config-changed" hook

So clearly just default: does not work across the board. Maybe it works for some charms but not all.

I tried to use default: "" and got this from Juju when trying to deploy:

ERROR invalid config default: option "prefer-ipv6" expected boolean, got ""

Perhaps just using default: allows Juju to try to deploy but depending on the charm it can cause breakages at the charm level.