builder/amazon/common: if instance query returns none, ignore
This commit is contained in:
parent
535d2a7cfc
commit
67c71aa836
|
@ -25,6 +25,8 @@ BUG FIXES:
|
||||||
|
|
||||||
* builder/amazon/all: When copying AMI to multiple regions, copy
|
* builder/amazon/all: When copying AMI to multiple regions, copy
|
||||||
the metadata (tags and attributes) as well. [GH-388]
|
the metadata (tags and attributes) as well. [GH-388]
|
||||||
|
* builder/amazon/all: Fix panic case where eventually consistent
|
||||||
|
instance state caused an index out of bounds.
|
||||||
* builder/vmware: Autoanswer VMware dialogs. [GH-393]
|
* builder/vmware: Autoanswer VMware dialogs. [GH-393]
|
||||||
* command/inspect: Fix weird output for default values for optional vars.
|
* command/inspect: Fix weird output for default values for optional vars.
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,12 @@ func InstanceStateRefreshFunc(conn *ec2.EC2, i *ec2.Instance) StateRefreshFunc {
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(resp.Reservations) == 0 || len(resp.Reservations[0].Instances) == 0 {
|
||||||
|
// Sometimes AWS just has consistency issues and doesn't see
|
||||||
|
// our instance yet. Return an empty state.
|
||||||
|
return nil, "", nil
|
||||||
|
}
|
||||||
|
|
||||||
i = &resp.Reservations[0].Instances[0]
|
i = &resp.Reservations[0].Instances[0]
|
||||||
return i, i.State.Name, nil
|
return i, i.State.Name, nil
|
||||||
}
|
}
|
||||||
|
@ -57,27 +63,31 @@ func WaitForState(conf *StateChangeConf) (i interface{}, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if currentState == conf.Target {
|
// Check states only if we were able to refresh to an instance
|
||||||
return
|
// that exists.
|
||||||
}
|
if i != nil {
|
||||||
|
if currentState == conf.Target {
|
||||||
if conf.StepState != nil {
|
return
|
||||||
if _, ok := conf.StepState.GetOk(multistep.StateCancelled); ok {
|
|
||||||
return nil, errors.New("interrupted")
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
found := false
|
if conf.StepState != nil {
|
||||||
for _, allowed := range conf.Pending {
|
if _, ok := conf.StepState.GetOk(multistep.StateCancelled); ok {
|
||||||
if currentState == allowed {
|
return nil, errors.New("interrupted")
|
||||||
found = true
|
}
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if !found {
|
found := false
|
||||||
fmt.Errorf("unexpected state '%s', wanted target '%s'", currentState, conf.Target)
|
for _, allowed := range conf.Pending {
|
||||||
return
|
if currentState == allowed {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !found {
|
||||||
|
fmt.Errorf("unexpected state '%s', wanted target '%s'", currentState, conf.Target)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(2 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
|
|
Loading…
Reference in New Issue