Skip to content

Commit 05704ba

Browse files
authored
Merge pull request #154 from devrandom0/sina/fix_zero_capacity_scaler
Fix issue with capacity_scaler and zero value
2 parents 9d7331b + 50b3f5a commit 05704ba

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

controllers/autoneg.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ func (b *ProdBackendController) ReconcileBackends(actual, intended AutonegStatus
249249
// Add or update any new backends to the list
250250
for _, u := range upsert.backends {
251251
copy := true
252-
for beidx, be := range newSvc.Backends {
252+
for _, be := range newSvc.Backends {
253253
if u.Group == be.Group {
254254
// TODO: copy fields explicitly
255255
be.MaxRatePerEndpoint = u.MaxRatePerEndpoint
@@ -258,15 +258,10 @@ func (b *ProdBackendController) ReconcileBackends(actual, intended AutonegStatus
258258
var syncConfig AutonegSyncConfig = *intended.AutonegSyncConfig
259259
if syncConfig.CapacityScaler != nil && *syncConfig.CapacityScaler == true {
260260
be.CapacityScaler = u.CapacityScaler
261-
forceCapacity[beidx] = true
262261
}
263262
} else {
264263
// Force CapacityScaler to an "empty value"
265264
u.CapacityScaler = 0
266-
// Check if existing capacity scaler is zero
267-
if be.CapacityScaler == 0 {
268-
forceCapacity[beidx] = true
269-
}
270265
}
271266
copy = false
272267
break
@@ -283,6 +278,11 @@ func (b *ProdBackendController) ReconcileBackends(actual, intended AutonegStatus
283278
newSvc.Backends = append(newSvc.Backends, &newBackend)
284279
}
285280
}
281+
for beidx, be := range newSvc.Backends {
282+
if be.CapacityScaler == 0 {
283+
forceCapacity[beidx] = true
284+
}
285+
}
286286
if len(upsert.backends) > 0 {
287287
err = b.updateBackends(upsert.name, upsert.region, newSvc, forceCapacity)
288288
}

0 commit comments

Comments
 (0)