invalid instance type should sort the valid instance types

Bug #1764963 reported by John A Meinel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical Juju
Fix Released
Medium
Nam Nguyen

Bug Description

I just did:

juju bootstrap aws ... --model-default instance-type=m4.medium

And it came back with:

11:48:04 ERROR juju.cmd.juju.commands bootstrap.go:528 invalid constraint value: instance-type=m4.medium
valid values are: [p2.8xlarge r3.8xlarge r3.4xlarge i2.4xlarge t2.medium d2.4xlarge m3.xlarge r4.4xlarge c3.large t2.nano i3.xlarge i3.8xlarge d2.2xlarge t2.2xlarge x1.32xlarge g3.8xlarge t2.large m3.large x1.16xlarge r4.16xlarge m4.large i3.4xlarge c4.4xlarge r4.xlarge i3.16xlarge g2.2xlarge m4.2xlarge m3.2xlarge t2.small c4.8xlarge m4.xlarge r3.xlarge d2.8xlarge i2.2xlarge d2.xlarge m3.medium i3.large c3.xlarge r3.large m4.4xlarge g3.4xlarge p2.xlarge c3.8xlarge c3.2xlarge r3.2xlarge i2.xlarge c3.4xlarge c4.2xlarge g2.8xlarge t2.xlarge g3.16xlarge m4.16xlarge i2.8xlarge t2.micro i3.2xlarge r4.8xlarge r4.2xlarge r4.large p2.16xlarge c4.large m4.10xlarge c4.xlarge]

This would be a lot more useful if that list was sorted:
[c3.2xlarge c3.4xlarge c3.8xlarge c3.large c3.xlarge c4.2xlarge c4.4xlarge c4.8xlarge c4.large c4.xlarge d2.2xlarge d2.4xlarge d2.8xlarge d2.xlarge g2.2xlarge g2.8xlarge g3.16xlarge g3.4xlarge g3.8xlarge i2.2xlarge i2.4xlarge i2.8xlarge i2.xlarge i3.16xlarge i3.2xlarge i3.4xlarge i3.8xlarge i3.large i3.xlarge m3.2xlarge m3.large m3.medium m3.xlarge m4.10xlarge m4.16xlarge m4.2xlarge m4.4xlarge m4.large m4.xlarge p2.16xlarge p2.8xlarge p2.xlarge r3.2xlarge r3.4xlarge r3.8xlarge r3.large r3.xlarge r4.16xlarge r4.2xlarge r4.4xlarge r4.8xlarge r4.large r4.xlarge t2.2xlarge t2.large t2.medium t2.micro t2.nano t2.small t2.xlarge x1.16xlarge x1.32xlarge]

That would let us scan through to find the "m4" and then do something with it. Arguably it should be "naturally" sorted, as that would put 2xlarge before 16xlarge (though it wouldn't put "xlarge" before "2xlarge").

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

Maybe even better if we did something like group them by prefix, so you would end up with:

[
c3.2xlarge c3.4xlarge c3.8xlarge c3.large c3.xlarge
c4.2xlarge c4.4xlarge c4.8xlarge c4.large c4.xlarge
d2.2xlarge d2.4xlarge d2.8xlarge d2.xlarge
g2.2xlarge g2.8xlarge
g3.16xlarge g3.4xlarge g3.8xlarge
i2.2xlarge i2.4xlarge i2.8xlarge i2.xlarge
i3.16xlarge i3.2xlarge i3.4xlarge i3.8xlarge i3.large i3.xlarge
m3.2xlarge m3.large m3.medium m3.xlarge
m4.10xlarge m4.16xlarge m4.2xlarge m4.4xlarge m4.large m4.xlarge
p2.16xlarge p2.8xlarge p2.xlarge
r3.2xlarge r3.4xlarge r3.8xlarge r3.large r3.xlarge
r4.16xlarge r4.2xlarge r4.4xlarge r4.8xlarge r4.large r4.xlarge
t2.2xlarge t2.large t2.medium t2.micro t2.nano t2.small t2.xlarge
x1.16xlarge x1.32xlarge
]

Revision history for this message
Nam Nguyen (nammn) wrote :

Would this output suffice?

[c3.2xlarge c3.4xlarge c3.8xlarge c3.large c3.xlarge c4.2xlarge c4.4xlarge c4.8xlarge c4.large c4.xlarge d2.2xlarge d2.4xlarge d2.8xlarge d2.xlarge g2.2xlarge g2.8xlarge g3.16xlarge g3.4xlarge g3.8xlarge i2.2xlarge i2.4xlarge i2.8xlarge i2.xlarge i3.16xlarge i3.2xlarge i3.4xlarge i3.8xlarge i3.large i3.xlarge m3.2xlarge m3.large m3.medium m3.xlarge m4.10xlarge m4.16xlarge m4.2xlarge m4.4xlarge m4.large m4.xlarge p2.16xlarge p2.8xlarge p2.xlarge r3.2xlarge r3.4xlarge r3.8xlarge r3.large r3.xlarge r4.16xlarge r4.2xlarge r4.4xlarge r4.8xlarge r4.large r4.xlarge t2.2xlarge t2.large t2.medium t2.micro t2.nano t2.small t2.xlarge x1.16xlarge x1.32xlarge]

or do you mean by grouping actually grouping by a key? Or grouping by adding a newline?

Revision history for this message
Richard Harding (rharding) wrote : Re: [Bug 1764963] Re: invalid instance type should sort the valid instance types

I think we'd need to sort by category (c3) and then withing all the c3.
instances.

On Fri, Sep 20, 2019, 12:21 PM Nam Nguyen <email address hidden>
wrote:

> Would this output suffice?
>
> [c3.2xlarge c3.4xlarge c3.8xlarge c3.large c3.xlarge c4.2xlarge
> c4.4xlarge c4.8xlarge c4.large c4.xlarge d2.2xlarge d2.4xlarge
> d2.8xlarge d2.xlarge g2.2xlarge g2.8xlarge g3.16xlarge g3.4xlarge
> g3.8xlarge i2.2xlarge i2.4xlarge i2.8xlarge i2.xlarge i3.16xlarge
> i3.2xlarge i3.4xlarge i3.8xlarge i3.large i3.xlarge m3.2xlarge m3.large
> m3.medium m3.xlarge m4.10xlarge m4.16xlarge m4.2xlarge m4.4xlarge
> m4.large m4.xlarge p2.16xlarge p2.8xlarge p2.xlarge r3.2xlarge
> r3.4xlarge r3.8xlarge r3.large r3.xlarge r4.16xlarge r4.2xlarge
> r4.4xlarge r4.8xlarge r4.large r4.xlarge t2.2xlarge t2.large t2.medium
> t2.micro t2.nano t2.small t2.xlarge x1.16xlarge x1.32xlarge]
>
>
> or do you mean by grouping actually grouping by a key? Or grouping by
> adding a newline?
>
> --
> You received this bug notification because you are subscribed to juju.
> https://bugs.launchpad.net/bugs/1764963
>
> Title:
> invalid instance type should sort the valid instance types
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/juju/+bug/1764963/+subscriptions
>

Revision history for this message
Nam Nguyen (nammn) wrote :

Additionally, it should happen for other providers as well.
E.g. for openstack

: [cpu1-ram4-disk20 cpu8-ram16-disk10 cpu2-ram4-disk50 cpu1-ram2-disk20 cpu1-ram6-disk50 m1.small cpu1-ram12-disk50 cpu8-ram4-disk10 cpu4-ram16-disk10 m1.tiny cpu2-ram16-disk20 cpu1-ram12-disk10 cpu8-ram8-disk20 cpu2-ram12-disk20 cpu4-ram12-disk50 cpu2-ram8-disk10 cpu2-ram2-disk50 cpu8-ram6-disk10 cpu1-ram8-disk10 cpu2-ram8-disk50 cpu1-ram1-disk10 cpu4-ram6-disk20 cpu2-ram16-disk10 cpu2-ram1-disk20 cpu2-ram1-disk10 ... ]

Im thinking about sorting the instance in the validator place.
Somewhere around this place:
https://github.com/juju/juju/blob/14dcb838d37ab5cd77eb27969161683af318f265/core/constraints/validation.go#L194

Revision history for this message
Nam Nguyen (nammn) wrote :

Joe and I were talking last week to make it provider specific because adding the change into the validator class could lead to unexpected side effect.

The idea would be to sort the output on each provider with sort.Sort(ByType(instancetypes)) in each constraintvalidator method before using it.

The only class which "jumps out" is openstack. Which uses "Flavor" instead of instanceTypes.

Solutions could be:

- openstack get's its own sort (?), which is only a lexical sort
- gce, ec2 ... are using the custom instanceType sort

Sort would do the following. Sort by prefix, if not the same name. If the same name sort by cost.

Nam Nguyen (nammn)
Changed in juju:
status: Triaged → Won't Fix
status: Won't Fix → Fix Committed
milestone: none → 2.7-beta1
Revision history for this message
Nam Nguyen (nammn) wrote :

PR https://github.com/juju/juju/pull/10652 fixes the BUG for the next milestone

Nam Nguyen (nammn)
Changed in juju:
assignee: nobody → Nam Nguyen (nammn)
Changed in juju:
status: Fix Committed → Fix Released
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.