actions.yaml schema does not support "float"

Bug #1714405 reported by Drew Freiberger
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Canonical Juju
Triaged
Low
Unassigned

Bug Description

when authoring a charm action, received error on testing:

$ juju upgrade-charm swift-proxy --path `pwd`/charm-swift-proxy/
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://blueprints.launchpad.net/swift/+spec/adjustable-replica-counts
    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

Revision history for this message
Drew Freiberger (afreiberger) 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>.

Revision history for this message
John A Meinel (jameinel) wrote : Re: [Bug 1714405] Re: actions.yaml schema does not support "float"

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://bugs.launchpad.net/bugs/1714405
>
> Title:
> actions.yaml schema does not support "float"
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/juju/+bug/1714405/+subscriptions
>

Revision history for this message
Anastasia (anastasia-macmood) wrote :

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
Revision history for this message
Tytus Kurek (tkurek) wrote :

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.dependency engine.go:636 "uniter" manifold worker returned unexpected error: preparing operation "run action 35513ba2-6ab3-463e-8eee-c0dab5653d91": cannot create runner for action "35513ba2-6ab3-463e-8eee-c0dab5653d91": invalid params schema for action schema set-weight: float is not a valid type

Juju version is 2.5.1

Revision history for this message
Michał Ajduk (majduk) wrote :

This is related to https://bugs.launchpad.net/juju/+bug/1613838, for which a fix was released in juju 2.5.2

Revision history for this message
Tytus Kurek (tkurek) wrote :

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.

Revision history for this message
John A Meinel (jameinel) wrote :

https://bugs.launchpad.net/juju/+bug/1613838 is a bug about multi architecture builds for Juju, I'm guessing it is adifferent bug that you are referencing.

maybe you meant: https://bugs.launchpad.net/juju/+bug/1815222 ?

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?

Revision history for this message
Richard Harding (rharding) wrote :

https://bugs.launchpad.net/juju/+bug/1613839 is the bug recently addressing an issue with a float. Given that was in bundle code I'm not sure what overlap with the actions it would be here. This also seems more around the idea of upgrading a charm and changing the type of a property in an action file. Juju isn't liking the change to the type?

Revision history for this message
Canonical Juju QA Bot (juju-qa-bot) wrote :

This bug has not been updated in 2 years, so we're marking it Low importance. If you believe this is incorrect, please update the importance.

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.