actions.yaml schema does not support "float"
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
| juju |
Low
|
Unassigned |
Bug Description
when authoring a charm action, received error on testing:
$ juju upgrade-charm swift-proxy --path `pwd`/charm-
ERROR invalid params schema for action schema update-replicas: float is not a valid type
actions.yaml entry for update-replicas action is below.
update-replicas:
description: |
Update object, account, and container server replica count
Useful when needing to slowly weight up or down between replica settings
Implements 'Make ring's replica count adjustable' blueprint in charm
https:/
This action will trigger a rebalance and synchronization of the builder
and ring files
params:
replicas:
type: float
description: |
Number of replicas (floating point replicas can be used to gradually
reweight replica changes to reduce replication i/o overhead)
Example - 3.0
server:
type: string
description: |
One of "account", "container", or "object". "all" can be specified
to make the change to all 3 builder/ring settings
required:
- replicas
- server
Changed type: to "string" in actions.yaml and get the following error trying to input a floating point number:
$ juju run-action swift-proxy/1 update-replicas server=object replicas=2.9
ERROR validation failed: (root).replicas : must be of type string, given 2.9
$ juju run-action swift-proxy/1 update-replicas server=object replicas="2.9"
ERROR validation failed: (root).replicas : must be of type string, given 2.9
I have been successful in using type: float in config.yaml for the same charm. This seems an inconsistent implementation of input schemas.
juju version 2.2.2 on xenial
Drew Freiberger (afreiberger) wrote : | #1 |
John A Meinel (jameinel) wrote : Re: [Bug 1714405] Re: actions.yaml schema does not support "float" | #2 |
YAML tries to interpret things that aren't in quotes as numbers and then
falls back to strings. Also, your shell would be trying to interpret "" on
the command-line. I think the syntax would be
juju run-action ... --value="'2.9'"
John
=:->
On Sep 1, 2017 07:50, "Drew Freiberger" <email address hidden> wrote:
> It appears "number" is the proper type for a floating point value. My
> use of type: float in config.yaml worked in juju 1.25.6. Perhaps the
> types changed between versions. Will use "number" for this solution,
> but more useful expounding upon available types in the upgrade-charm
> check would be helpful.
>
> Lastly, a number should be acceptable as a string, though I know it's
> not a strong type-cast, string should be allowed by juju run-action
> var=<number>.
>
> --
> You received this bug notification because you are subscribed to juju.
> Matching subscriptions: juju bugs
> https:/
>
> Title:
> actions.yaml schema does not support "float"
>
> To manage notifications about this bug go to:
> https:/
>
Anastasia (anastasia-macmood) wrote : | #3 |
Yes, I am pretty sure "float" in config.yaml works fine - we have a unit test exercising this.
I suspect that there may be a bug in parsing actions.yaml. To ensure that we'd see the same thing you have, could you please provide simple repro steps?
Changed in juju: | |
status: | New → Triaged |
importance: | Undecided → Low |
tags: | added: usability |
Tytus Kurek (tkurek) wrote : | #4 |
I've just faced that when trying to implement an action with a param of the 'float' type. When trying to upgrade the charm the following error message is displayed:
ERROR invalid params schema for action schema set-weight: int is not a valid type
When I change the type to 'number' I can successfully upgrade the charm. I tried changing the type manually to 'float' later on (by modifying the 'actions.yaml' file on the deployed application unit), but then when running the action I get the following error and action fails:
ERROR juju.worker.
Juju version is 2.5.1
Michał Ajduk (majduk) wrote : | #5 |
This is related to https:/
Tytus Kurek (tkurek) wrote : | #6 |
I've just tried to implement this option as 'string' and convert it to 'float' later on, but now I got the following error when running the action:
ERROR validation failed: (root).myoption : must be of type string, given 0
So it looks like 'number' is the only way to go for now.
John A Meinel (jameinel) wrote : | #7 |
https:/
maybe you meant: https:/
I have the feeling that somewhere the conversion is ending up as a default conversion (eg, whole numbers default to being deserialized as 'int'.) And we're missing a "its ok to put an int into a float" step.
But maybe that has already been fixed according to majduk?
Richard Harding (rharding) wrote : | #8 |
https:/
It appears "number" is the proper type for a floating point value. My use of type: float in config.yaml worked in juju 1.25.6. Perhaps the types changed between versions. Will use "number" for this solution, but more useful expounding upon available types in the upgrade-charm check would be helpful.
Lastly, a number should be acceptable as a string, though I know it's not a strong type-cast, string should be allowed by juju run-action var=<number>.