mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 18:54:06 +00:00
Merge pull request #87003 from odinuge/node-e2e-instance-failure
Add error check for instance insert in node e2e
This commit is contained in:
commit
9277bac9b8
@ -623,8 +623,10 @@ func createInstance(imageConfig *internalGCEImage) (string, error) {
|
|||||||
}
|
}
|
||||||
i.Scheduling = &scheduling
|
i.Scheduling = &scheduling
|
||||||
i.Metadata = imageConfig.metadata
|
i.Metadata = imageConfig.metadata
|
||||||
|
var insertionOperationName string
|
||||||
if _, err := computeService.Instances.Get(*project, *zone, i.Name).Do(); err != nil {
|
if _, err := computeService.Instances.Get(*project, *zone, i.Name).Do(); err != nil {
|
||||||
op, err := computeService.Instances.Insert(*project, *zone, i).Do()
|
op, err := computeService.Instances.Insert(*project, *zone, i).Do()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ret := fmt.Sprintf("could not create instance %s: API error: %v", name, err)
|
ret := fmt.Sprintf("could not create instance %s: API error: %v", name, err)
|
||||||
if op != nil {
|
if op != nil {
|
||||||
@ -632,15 +634,37 @@ func createInstance(imageConfig *internalGCEImage) (string, error) {
|
|||||||
}
|
}
|
||||||
return "", fmt.Errorf(ret)
|
return "", fmt.Errorf(ret)
|
||||||
} else if op.Error != nil {
|
} else if op.Error != nil {
|
||||||
return "", fmt.Errorf("could not create instance %s: %+v", name, op.Error)
|
var errs []string
|
||||||
}
|
for _, insertErr := range op.Error.Errors {
|
||||||
|
errs = append(errs, fmt.Sprintf("%+v", insertErr))
|
||||||
}
|
}
|
||||||
|
return "", fmt.Errorf("could not create instance %s: %+v", name, errs)
|
||||||
|
|
||||||
|
}
|
||||||
|
insertionOperationName = op.Name
|
||||||
|
}
|
||||||
instanceRunning := false
|
instanceRunning := false
|
||||||
for i := 0; i < 30 && !instanceRunning; i++ {
|
for i := 0; i < 30 && !instanceRunning; i++ {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
time.Sleep(time.Second * 20)
|
time.Sleep(time.Second * 20)
|
||||||
}
|
}
|
||||||
|
var insertionOperation *compute.Operation
|
||||||
|
insertionOperation, err = computeService.ZoneOperations.Get(*project, *zone, insertionOperationName).Do()
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if strings.ToUpper(insertionOperation.Status) != "DONE" {
|
||||||
|
err = fmt.Errorf("instance insert operation %s not in state DONE, was %s", name, insertionOperation.Status)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if insertionOperation.Error != nil {
|
||||||
|
var errs []string
|
||||||
|
for _, insertErr := range insertionOperation.Error.Errors {
|
||||||
|
errs = append(errs, fmt.Sprintf("%+v", insertErr))
|
||||||
|
}
|
||||||
|
return name, fmt.Errorf("could not create instance %s: %+v", name, errs)
|
||||||
|
}
|
||||||
|
|
||||||
var instance *compute.Instance
|
var instance *compute.Instance
|
||||||
instance, err = computeService.Instances.Get(*project, *zone, name).Do()
|
instance, err = computeService.Instances.Get(*project, *zone, name).Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user