builder/googlecompute: fix all sorts of zone issues

This commit is contained in:
Mitchell Hashimoto 2013-12-12 22:23:00 -08:00
parent 7f140cdf9c
commit f72f7a37d1
3 changed files with 6 additions and 4 deletions

View File

@ -141,7 +141,7 @@ func (d *driverGCE) RunInstance(c *InstanceConfig) (<-chan error, error) {
}
errCh := make(chan error, 1)
go waitForState(errCh, "DONE", d.refreshZoneOp(op))
go waitForState(errCh, "DONE", d.refreshZoneOp(zone.Name, op))
return errCh, nil
}
@ -162,9 +162,9 @@ func (d *driverGCE) getImage(name string) (image *compute.Image, err error) {
return
}
func (d *driverGCE) refreshZoneOp(op *compute.Operation) stateRefreshFunc {
func (d *driverGCE) refreshZoneOp(zone string, op *compute.Operation) stateRefreshFunc {
return func() (string, error) {
newOp, err := d.service.ZoneOperations.Get(d.projectId, op.Zone, op.Name).Do()
newOp, err := d.service.ZoneOperations.Get(d.projectId, zone, op.Name).Do()
if err != nil {
return "", err
}

View File

@ -18,7 +18,8 @@ func processPrivateKeyFile(privateKeyFile, passphrase string) ([]byte, error) {
PEMBlock, _ := pem.Decode(rawPrivateKeyBytes)
if PEMBlock == nil {
return nil, fmt.Errorf("%s does not contain a vaild private key", privateKeyFile)
return nil, fmt.Errorf(
"%s does not contain a vaild private key", privateKeyFile)
}
if x509.IsEncryptedPEMBlock(PEMBlock) {

View File

@ -39,6 +39,7 @@ func (s *StepCreateInstance) Run(state multistep.StateBag) multistep.StepAction
})
if err == nil {
ui.Message("Waiting for creation operation to complete...")
select {
case err = <-errCh:
case <-time.After(config.stateTimeout):