← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/juju-core/release-instances into lp:~maas-maintainers/juju-core/maas-provider-skeleton

 

Raphaël Badin has proposed merging lp:~rvb/juju-core/release-instances into lp:~maas-maintainers/juju-core/maas-provider-skeleton.

Commit message:
Release instances (instead of stopping them) when something goes wrong.

Requested reviews:
  MAAS Maintainers (maas-maintainers)

For more details, see:
https://code.launchpad.net/~rvb/juju-core/release-instances/+merge/158341

fwreade 10 & 16.

The change to Bootstrap() is the real change (from stopInstance to releaseInstance).  The other one (in obtainNode()) is only to make it clearer that we're releasing the instance (that's what *S*topInstance() does).
-- 
https://code.launchpad.net/~rvb/juju-core/release-instances/+merge/158341
Your team MAAS Maintainers is requested to review the proposed merge of lp:~rvb/juju-core/release-instances into lp:~maas-maintainers/juju-core/maas-provider-skeleton.
=== modified file 'environs/maas/environ.go'
--- environs/maas/environ.go	2013-04-11 08:32:01 +0000
+++ environs/maas/environ.go	2013-04-11 12:02:21 +0000
@@ -160,7 +160,7 @@
 	}
 	err = env.saveState(&bootstrapState{StateInstances: []state.InstanceId{inst.Id()}})
 	if err != nil {
-		env.stopInstance(inst)
+		env.releaseInstance(inst)
 		return fmt.Errorf("cannot save state: %v", err)
 	}
 
@@ -341,7 +341,7 @@
 	}
 	err = environ.startNode(node, tools, userdata)
 	if err != nil {
-		environ.StopInstances([]environs.Instance{&instance})
+		environ.releaseInstance(&instance)
 		return nil, fmt.Errorf("cannot start instance: %v", err)
 	}
 	log.Debugf("environs/maas: started instance %q", instance.Id())
@@ -382,19 +382,6 @@
 	return firstErr
 }
 
-// stopInstance stops a single instance.  Avoid looping over this in bulk
-// operations: use StopInstances for those.
-func (environ *maasEnviron) stopInstance(inst environs.Instance) error {
-	maasInst := inst.(*maasInstance)
-	maasObj := maasInst.maasObject
-	_, err := maasObj.CallPost("stop", nil)
-	if err != nil {
-		log.Debugf("environs/maas: error stopping instance %v", maasInst)
-	}
-
-	return err
-}
-
 // releaseInstance releases a single instance.
 func (environ *maasEnviron) releaseInstance(inst environs.Instance) error {
 	maasInst := inst.(*maasInstance)