Add retries to PrepareNodes utility function

This commit is contained in:
Shyam Jeedigunta 2018-02-13 18:51:01 +01:00
parent 46df831351
commit a03b24bd03
No known key found for this signature in database
GPG Key ID: 745AA51D657EAD2C
2 changed files with 9 additions and 2 deletions

View File

@ -5059,7 +5059,7 @@ func DumpDebugInfo(c clientset.Interface, ns string) {
}
func IsRetryableAPIError(err error) bool {
return apierrs.IsTimeout(err) || apierrs.IsServerTimeout(err) || apierrs.IsTooManyRequests(err) || apierrs.IsInternalError(err)
return apierrs.IsTimeout(err) || apierrs.IsServerTimeout(err) || apierrs.IsTooManyRequests(err)
}
// DsFromManifest reads a .json/yaml file and returns the daemonset in it.

View File

@ -73,7 +73,14 @@ func (p *IntegrationTestNodePreparer) PrepareNodes() error {
},
}
for i := 0; i < numNodes; i++ {
if _, err := p.client.CoreV1().Nodes().Create(baseNode); err != nil {
var err error
for retry := 0; retry < retries; retry++ {
_, err = p.client.CoreV1().Nodes().Create(baseNode)
if err == nil || !e2eframework.IsRetryableAPIError(err) {
break
}
}
if err != nil {
glog.Fatalf("Error creating node: %v", err)
}
}