diff --git a/nomad/structs/diff.go b/nomad/structs/diff.go index 251ceee5d..812a28e17 100644 --- a/nomad/structs/diff.go +++ b/nomad/structs/diff.go @@ -226,12 +226,12 @@ func (tg *TaskGroup) Diff(other *TaskGroup, contextual bool) (*TaskGroupDiff, er // ShutdownDelay diff if tg.ShutdownDelay == nil { - oldPrimitiveFlat["ShutdownDelay"] = "nil" + oldPrimitiveFlat["ShutdownDelay"] = "" } else { oldPrimitiveFlat["ShutdownDelay"] = fmt.Sprintf("%d", *tg.ShutdownDelay) } if other.ShutdownDelay == nil { - newPrimitiveFlat["ShutdownDelay"] = "nil" + newPrimitiveFlat["ShutdownDelay"] = "" } else { newPrimitiveFlat["ShutdownDelay"] = fmt.Sprintf("%d", *other.ShutdownDelay) } diff --git a/nomad/structs/diff_test.go b/nomad/structs/diff_test.go index 06ac79ad1..ed6ea0797 100644 --- a/nomad/structs/diff_test.go +++ b/nomad/structs/diff_test.go @@ -3050,6 +3050,42 @@ func TestTaskGroupDiff(t *testing.T) { }, }, }, + { + TestCase: "TaskGroup shutdown_delay removed", + Old: &TaskGroup{ + ShutdownDelay: helper.TimeToPtr(30 * time.Second), + }, + New: &TaskGroup{}, + Expected: &TaskGroupDiff{ + Type: DiffTypeEdited, + Fields: []*FieldDiff{ + { + Type: DiffTypeDeleted, + Name: "ShutdownDelay", + Old: "30000000000", + New: "", + }, + }, + }, + }, + { + TestCase: "TaskGroup shutdown_delay added", + Old: &TaskGroup{}, + New: &TaskGroup{ + ShutdownDelay: helper.TimeToPtr(30 * time.Second), + }, + Expected: &TaskGroupDiff{ + Type: DiffTypeEdited, + Fields: []*FieldDiff{ + { + Type: DiffTypeAdded, + Name: "ShutdownDelay", + Old: "", + New: "30000000000", + }, + }, + }, + }, } for i, c := range cases {