cmd/juju/addmachine.go might fail with unsupported container
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
juju-core |
Fix Released
|
Medium
|
Ian Booth |
Bug Description
http://
In addmachine.go there's this code:
59 if c.ContainerType, err = instance.
60 if !names.
61 return fmt.Errorf(
62 }
63 sep := strings.
65 c.MachineId = containerSpec[
66 c.ContainerType, err = instance.
67 }
There are a few issues with it:
1) If containerSpec is not one of the supported container types ("none", "lxc", "kvm") it assumes it's in the form "type:machine", which might not be the case (on 59 err will be != nil)
2) IsMachineOrNewC
Roger has proposed to add a names.SplitCont
and use that here to handle the case better.
There should be better tests for the invalid cases specified above: 1) and 2).
Related branches
- Juju Engineering: Pending requested
-
Diff: 351 lines (+93/-135)9 files modifiedcmd/juju/addmachine.go (+1/-1)
cmd/juju/addmachine_test.go (+8/-4)
cmd/juju/addunit.go (+1/-2)
cmd/names.go (+25/-0)
cmd/names_test.go (+36/-0)
names/machine.go (+3/-13)
names/machine_test.go (+3/-32)
names/service_test.go (+16/-1)
state/state_test.go (+0/-82)
Changed in juju-core: | |
assignee: | nobody → Ian Booth (wallyworld) |
status: | Confirmed → In Progress |
Changed in juju-core: | |
status: | In Progress → Fix Committed |
Changed in juju-core: | |
milestone: | none → 1.13.0 |
Changed in juju-core: | |
status: | Fix Committed → Fix Released |
The correct behavior is to accept either "type:machine" or "type", where "type" is one of the supported container types. If just a machine id is passed, it should display a more meaningful error message.