Request: clients should not be responsible for parsing constraints

Bug #1645402 reported by Pen Gale
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Canonical Juju
Triaged
Wishlist
Unassigned

Bug Description

Currently, if a client like the gui or python-libjuju wants to deploy a bundle with constraints, it will get a string like the following back from the plan generator specifying those constraints:

    "mem=7G"

The GUI then expects the client to translate this into the following json:

    {"mem": 7168}

Basically, the client needs to know that juju wants memory specified in Mb, and translate the string to Mb. Similarly, for other constraints, the client needs to know what conventions juju core expects, and translate the strings that the user has specified into those conventions. The conventions are documented in constraints.go, but are not available as an API call.

It would be much nicer if core instead accepted:

    {"mem": "7G"}

or even

    {"constraints": "mem=7G"}

That way, we won't have to maintain constraints.py and constraints.js, duplicating the work already done in constraints.go.

Tags: libjuju
Revision history for this message
Cory Johns (johnsca) wrote :

To clarify, this is about the websocket API and not the GUI or python-libjuju specifically.

The clients call the client_facade.GetBundleChanges API call with the bundle yaml and get back a plan of steps consisting of other API methods to call with the args to provide them. However, the call to AddMachines in the plan has the constraints returned as an unparsed string, while client_facade.AddMachines expects the constraints to be given as constraints.Value serialized structure.

The Juju Go client uses constraints.Parse but that doesn't appear to be exposed anywhere, so neither the GUI nor python-libjuju can use it and have to reimplement all of the constraint parsing logic themselves.

The easiest solution would be to expose constraints.Parse in the API. Perhaps a better solution would be to have the plan come back with the constraints already parsed, but that will raise backwards compatibility issues.

Revision history for this message
Cory Johns (johnsca) wrote :

Actually, I should say that the easiest solution from our side is what Pete suggested to have the AddMachines API also accept the unparsed constraints string and do the parsing on that side if necessary. But having to make another API call to parse the constraints wouldn't be too terribly bad either, I don't think.

Changed in juju:
status: New → Triaged
importance: Undecided → Wishlist
Changed in juju:
assignee: nobody → Francesco Banconi (frankban)
Revision history for this message
Anastasia (anastasia-macmood) wrote :
Changed in juju:
status: Triaged → In Progress
milestone: none → 2.1.0-rc1
Changed in juju:
assignee: Francesco Banconi (frankban) → nobody
Changed in juju:
status: In Progress → Triaged
milestone: 2.1-rc1 → none
Cory Johns (johnsca)
tags: added: matrix
Cory Johns (johnsca)
tags: added: libjuju
Caner Derici (cderici)
tags: removed: matrix
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.