Merge lp:~axwalk/juju-core/lp1270252-local-invalid-instances into lp:~go-bot/juju-core/trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Andrew Wilkins | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 2236 | ||||
Proposed branch: | lp:~axwalk/juju-core/lp1270252-local-invalid-instances | ||||
Merge into: | lp:~go-bot/juju-core/trunk | ||||
Diff against target: |
44 lines (+23/-7) 1 file modified
provider/local/environ.go (+23/-7) |
||||
To merge this branch: | bzr merge lp:~axwalk/juju-core/lp1270252-local-invalid-instances | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email:
|
Commit message
provider/local: check ID validity in Instances
The Instances method in the local provider was
not checking whether ids are valid. Thus,
DestroyEnvironment would fail when it maps when
machine in state remain but their instances are
already destroyed.
Instances is updated to check the existence of
instances, and return ErrPartialInstances or
ErrNoInstances accordingly.
Fixes #1270252
Description of the change
provider/local: check ID validity in Instances
The Instances method in the local provider was
not checking whether ids are valid. Thus,
DestroyEnvironment would fail when it maps when
machine in state remain but their instances are
already destroyed.
Instances is updated to check the existence of
instances, and return ErrPartialInstances or
ErrNoInstances accordingly.
Fixes #1270252
Reviewers: mp+202572_ code.launchpad. net,
Message:
Please take a look.
Description:
provider/local: check ID validity in Instances
The Instances method in the local provider was
not checking whether ids are valid. Thus,
DestroyEnvironment would fail when it maps when
machine in state remain but their instances are
already destroyed.
Instances is updated to check the existence of
instances, and return ErrPartialInstances or
ErrNoInstances accordingly.
Fixes #1270252
https:/ /code.launchpad .net/~axwalk/ juju-core/ lp1270252- local-invalid- instances/ +merge/ 202572
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/51230044/
Affected files (+25, -7 lines): local/environ. go
A [revision details]
M provider/
Index: [revision details] 20140121052439- o3gacqa1rvnhb3l b
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-
+New revision: <email address hidden>
Index: provider/ local/environ. go local/environ. go' local/environ. go 2014-01-05 22:20:24 +0000 local/environ. go 2014-01-21 23:04:24 +0000
=== modified file 'provider/
--- provider/
+++ provider/
@@ -325,17 +325,33 @@
// Instances is specified in the Environ interface. Instance, error) { instance. Instance, len(ids)) instance. Id]instance. Instance) inst.Id( )] = inst instance. Instance, len(ids)) ErrNoInstances ErrPartialInsta nces
func (env *localEnviron) Instances(ids []instance.Id)
([]instance.
- // NOTE: do we actually care about checking the existance of the
instances?
- // I posit that here we don't really care, and that we are only called
with
- // instance ids that we know exist.
if len(ids) == 0 {
return nil, nil
}
- insts := make([]
+ insts, err := env.AllInstances()
+ if err != nil {
+ return nil, err
+ }
+ allInstances := make(map[
+ for _, inst := range insts {
+ allInstances[
+ }
+ var found int
+ insts = make([]
for i, id := range ids {
- insts[i] = &localInstance{id, env}
- }
- return insts, nil
+ if inst, ok := allInstances[id]; ok {
+ insts[i] = inst
+ found++
+ }
+ }
+ if found == 0 {
+ insts, err = nil, environs.
+ } else if found < len(ids) {
+ err = environs.
+ } else {
+ err = nil
+ }
+ return insts, err
}
// AllInstances is specified in the InstanceBroker interface.