diff --git a/nomad/state/state_store.go b/nomad/state/state_store.go index d06b2d7e1..a47c9af59 100644 --- a/nomad/state/state_store.go +++ b/nomad/state/state_store.go @@ -1894,13 +1894,8 @@ func (s *StateStore) nestedUpdateAllocFromClient(txn *memdb.Txn, index uint64, a // Merge the deployment status taking only what the client should set oldDeploymentStatus := copyAlloc.DeploymentStatus copyAlloc.DeploymentStatus = alloc.DeploymentStatus - if oldDeploymentStatus != nil { - if oldDeploymentStatus.Canary { - copyAlloc.DeploymentStatus.Canary = true - } - if oldDeploymentStatus.Timestamp.After(copyAlloc.DeploymentStatus.Timestamp) { - copyAlloc.DeploymentStatus.Timestamp = oldDeploymentStatus.Timestamp - } + if oldDeploymentStatus != nil && oldDeploymentStatus.Canary { + copyAlloc.DeploymentStatus.Canary = true } // Update the modify index diff --git a/nomad/state/state_store_test.go b/nomad/state/state_store_test.go index adf3ed500..0ee8c9c57 100644 --- a/nomad/state/state_store_test.go +++ b/nomad/state/state_store_test.go @@ -3582,18 +3582,15 @@ func TestStateStore_UpdateAllocsFromClient_DeploymentStateMerges(t *testing.T) { require := require.New(t) state := testStateStore(t) - ts1 := time.Now() - ts2 := ts1.Add(1 * time.Hour) - alloc := mock.Alloc() - alloc.CreateTime = ts1.UnixNano() + now := time.Now() + alloc.CreateTime = now.UnixNano() pdeadline := 5 * time.Minute deployment := mock.Deployment() deployment.TaskGroups[alloc.TaskGroup].ProgressDeadline = pdeadline alloc.DeploymentID = deployment.ID alloc.DeploymentStatus = &structs.AllocDeploymentStatus{ - Canary: true, - Timestamp: ts2, + Canary: true, } require.Nil(state.UpsertJob(999, alloc.Job)) @@ -3606,9 +3603,8 @@ func TestStateStore_UpdateAllocsFromClient_DeploymentStateMerges(t *testing.T) { JobID: alloc.JobID, TaskGroup: alloc.TaskGroup, DeploymentStatus: &structs.AllocDeploymentStatus{ - Healthy: helper.BoolToPtr(true), - Canary: false, - Timestamp: ts1, + Healthy: helper.BoolToPtr(true), + Canary: false, }, } require.Nil(state.UpdateAllocsFromClient(1001, []*structs.Allocation{update})) @@ -3618,7 +3614,6 @@ func TestStateStore_UpdateAllocsFromClient_DeploymentStateMerges(t *testing.T) { require.Nil(err) require.NotNil(out) require.True(out.DeploymentStatus.Canary) - require.Equal(ts2, out.DeploymentStatus.Timestamp) } func TestStateStore_UpsertAlloc_Alloc(t *testing.T) {