scheduler: label loops with nested switch statements for effective break (#8528)

This commit is contained in:
Lars Lehtonen 2020-07-24 05:50:41 -07:00 committed by GitHub
parent 90aa15d39b
commit fb7b2282b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -166,26 +166,29 @@ func annotateTask(diff *structs.TaskDiff, parent *structs.TaskGroupDiff) {
// All changes to primitive fields result in a destructive update except
// KillTimeout
destructive := false
FieldsLoop:
for _, fDiff := range diff.Fields {
switch fDiff.Name {
case "KillTimeout":
continue
default:
destructive = true
break
break FieldsLoop
}
}
// Object changes that can be done in-place are log configs, services,
// constraints.
if !destructive {
ObjectsLoop:
for _, oDiff := range diff.Objects {
switch oDiff.Name {
case "LogConfig", "Service", "Constraint":
continue
default:
destructive = true
break
break ObjectsLoop
}
}
}