KillTimeout can be modified in place

This commit is contained in:
Alex Dadgar
2016-08-01 20:19:12 -07:00
parent ded46507e9
commit 7ccf55caf0
2 changed files with 34 additions and 10 deletions

View File

@@ -159,17 +159,12 @@ func annotateTask(diff *structs.TaskDiff, parent *structs.TaskGroupDiff) {
}
}
// All changes to primitive fields result in a destructive update.
// All changes to primitive fields result in a destructive update except
// KillTimeout
destructive := false
if len(diff.Fields) != 0 {
destructive = true
}
// Changes that can be done in-place are log configs, services and
// constraints.
for _, oDiff := range diff.Objects {
switch oDiff.Name {
case "LogConfig", "Service", "Constraint":
for _, fDiff := range diff.Fields {
switch fDiff.Name {
case "KillTimeout":
continue
default:
destructive = true
@@ -177,6 +172,20 @@ func annotateTask(diff *structs.TaskDiff, parent *structs.TaskGroupDiff) {
}
}
// Object changes that can be done in-place are log configs, services,
// constraints.
if !destructive {
for _, oDiff := range diff.Objects {
switch oDiff.Name {
case "LogConfig", "Service", "Constraint":
continue
default:
destructive = true
break
}
}
}
if destructive {
diff.Annotations = append(diff.Annotations, AnnotationForcesDestructiveUpdate)
} else {

View File

@@ -347,6 +347,21 @@ func TestAnnotateTask(t *testing.T) {
Parent: &structs.TaskGroupDiff{Type: structs.DiffTypeEdited},
Desired: AnnotationForcesInplaceUpdate,
},
{
Diff: &structs.TaskDiff{
Type: structs.DiffTypeEdited,
Fields: []*structs.FieldDiff{
{
Type: structs.DiffTypeEdited,
Name: "KillTimeout",
Old: "200",
New: "2000000",
},
},
},
Parent: &structs.TaskGroupDiff{Type: structs.DiffTypeEdited},
Desired: AnnotationForcesInplaceUpdate,
},
// Task deleted new parent
{
Diff: &structs.TaskDiff{