From 7ccf55caf0c53c309132b4de150fc24effcd658d Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Mon, 1 Aug 2016 20:19:12 -0700 Subject: [PATCH] KillTimeout can be modified in place --- scheduler/annotate.go | 29 +++++++++++++++++++---------- scheduler/annotate_test.go | 15 +++++++++++++++ 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/scheduler/annotate.go b/scheduler/annotate.go index 66c405fd6..05f768b41 100644 --- a/scheduler/annotate.go +++ b/scheduler/annotate.go @@ -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 { diff --git a/scheduler/annotate_test.go b/scheduler/annotate_test.go index 9ffcac2e8..ec9d3bc25 100644 --- a/scheduler/annotate_test.go +++ b/scheduler/annotate_test.go @@ -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{