Be more specific about the type of error to retry on
This commit is contained in:
parent
24d9aada11
commit
bc8b658a5c
1 changed files with 16 additions and 2 deletions
|
@ -153,6 +153,12 @@ func (b *Backends) create(igs []*compute.InstanceGroup, namedPort *compute.Named
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
errs := []string{}
|
errs := []string{}
|
||||||
|
// We first try to create the backend with balancingMode=RATE. If this
|
||||||
|
// fails, it's mostly likely because there are existing backends with
|
||||||
|
// balancingMode=UTILIZATION. This failure mode throws a googleapi error
|
||||||
|
// which wraps a HTTP 400 status code. We handle it in the loop below
|
||||||
|
// and come around to retry with the right balancing mode. The goal is to
|
||||||
|
// switch everyone to using RATE.
|
||||||
for _, bm := range []BalancingMode{Rate, Utilization} {
|
for _, bm := range []BalancingMode{Rate, Utilization} {
|
||||||
backends := getBackendsForIGs(igs)
|
backends := getBackendsForIGs(igs)
|
||||||
for _, b := range backends {
|
for _, b := range backends {
|
||||||
|
@ -175,8 +181,16 @@ func (b *Backends) create(igs []*compute.InstanceGroup, namedPort *compute.Named
|
||||||
PortName: namedPort.Name,
|
PortName: namedPort.Name,
|
||||||
}
|
}
|
||||||
if err := b.cloud.CreateBackendService(backend); err != nil {
|
if err := b.cloud.CreateBackendService(backend); err != nil {
|
||||||
glog.Infof("Error creating backend service with balancing mode %v", bm)
|
// This is probably a failure because we tried to create the backend
|
||||||
errs = append(errs, fmt.Sprintf("%v", err))
|
// with balancingMode=RATE when there are already backends with
|
||||||
|
// balancingMode=UTILIZATION. Just ignore it and retry setting
|
||||||
|
// balancingMode=UTILIZATION (b/35102911).
|
||||||
|
if utils.IsHTTPErrorCode(err, http.StatusBadRequest) {
|
||||||
|
glog.Infof("Error creating backend service with balancing mode %v:%v", bm, err)
|
||||||
|
errs = append(errs, fmt.Sprintf("%v", err))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
return b.Get(namedPort.Port)
|
return b.Get(namedPort.Port)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue