Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of gc: be consistent with setting create/modify timestamp tz into release/1.9.x #24400

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions nomad/blocked_evals.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ func (b *BlockedEvals) Unblock(computedClass string, index uint64) {
// Store the index in which the unblock happened. We use this on subsequent
// block calls in case the evaluation was in the scheduler when a trigger
// occurred.
b.unblockIndexes[computedClass] = unblockEvent{index, time.Now()}
b.unblockIndexes[computedClass] = unblockEvent{index, time.Now().UTC()}

// Capture chan in lock as Flush overwrites it
ch := b.capacityChangeCh
Expand Down Expand Up @@ -446,7 +446,7 @@ func (b *BlockedEvals) UnblockQuota(quota string, index uint64) {
// Store the index in which the unblock happened. We use this on subsequent
// block calls in case the evaluation was in the scheduler when a trigger
// occurred.
b.unblockIndexes[quota] = unblockEvent{index, time.Now()}
b.unblockIndexes[quota] = unblockEvent{index, time.Now().UTC()}
ch := b.capacityChangeCh
done := b.stopCh
b.l.Unlock()
Expand Down Expand Up @@ -475,7 +475,7 @@ func (b *BlockedEvals) UnblockClassAndQuota(class, quota string, index uint64) {
// Store the index in which the unblock happened. We use this on subsequent
// block calls in case the evaluation was in the scheduler when a trigger
// occurred.
now := time.Now()
now := time.Now().UTC()
if quota != "" {
b.unblockIndexes[quota] = unblockEvent{index, now}
}
Expand Down
2 changes: 1 addition & 1 deletion nomad/core_sched.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ func (c *CoreScheduler) gcEval(eval *structs.Evaluation, cutoffTime time.Time, a
gcEval := true
var gcAllocIDs []string
for _, alloc := range allocs {
if !allocGCEligible(alloc, job, time.Now(), cutoffTime) {
if !allocGCEligible(alloc, job, time.Now().UTC(), cutoffTime) {
// Can't GC the evaluation since not all of the allocations are
// terminal
gcEval = false
Expand Down
16 changes: 8 additions & 8 deletions nomad/core_sched_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ func TestCoreScheduler_EvalGC(t *testing.T) {
// Insert "dead" eval
store := s1.fsm.State()
eval := mock.Eval()
eval.CreateTime = time.Now().Add(-6 * time.Hour).UnixNano() // make sure objects we insert are older than GC thresholds
eval.ModifyTime = time.Now().Add(-5 * time.Hour).UnixNano()
eval.CreateTime = time.Now().UTC().Add(-6 * time.Hour).UnixNano() // make sure objects we insert are older than GC thresholds
eval.ModifyTime = time.Now().UTC().Add(-5 * time.Hour).UnixNano()
eval.Status = structs.EvalStatusFailed
must.NoError(t, store.UpsertJobSummary(999, mock.JobSummary(eval.JobID)))
must.NoError(t, store.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval}))
Expand Down Expand Up @@ -120,17 +120,17 @@ func TestCoreScheduler_EvalGC_ReschedulingAllocs(t *testing.T) {
// Insert "dead" eval
store := s1.fsm.State()
eval := mock.Eval()
eval.CreateTime = time.Now().Add(-6 * time.Hour).UnixNano() // make sure objects we insert are older than GC thresholds
eval.ModifyTime = time.Now().Add(-5 * time.Hour).UnixNano()
eval.CreateTime = time.Now().UTC().Add(-6 * time.Hour).UnixNano() // make sure objects we insert are older than GC thresholds
eval.ModifyTime = time.Now().UTC().Add(-5 * time.Hour).UnixNano()
eval.Status = structs.EvalStatusFailed
must.NoError(t, store.UpsertJobSummary(999, mock.JobSummary(eval.JobID)))
must.NoError(t, store.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval}))

// Insert "pending" eval for same job
eval2 := mock.Eval()
eval2.JobID = eval.JobID
eval2.CreateTime = time.Now().Add(-6 * time.Hour).UnixNano() // make sure objects we insert are older than GC thresholds
eval2.ModifyTime = time.Now().Add(-5 * time.Hour).UnixNano()
eval2.CreateTime = time.Now().UTC().Add(-6 * time.Hour).UnixNano() // make sure objects we insert are older than GC thresholds
eval2.ModifyTime = time.Now().UTC().Add(-5 * time.Hour).UnixNano()
must.NoError(t, store.UpsertJobSummary(999, mock.JobSummary(eval2.JobID)))
must.NoError(t, store.UpsertEvals(structs.MsgTypeTestSetup, 1003, []*structs.Evaluation{eval2}))

Expand Down Expand Up @@ -215,8 +215,8 @@ func TestCoreScheduler_EvalGC_StoppedJob_Reschedulable(t *testing.T) {
store := s1.fsm.State()
eval := mock.Eval()
eval.Status = structs.EvalStatusFailed
eval.CreateTime = time.Now().Add(-6 * time.Hour).UnixNano() // make sure objects we insert are older than GC thresholds
eval.ModifyTime = time.Now().Add(-5 * time.Hour).UnixNano()
eval.CreateTime = time.Now().UTC().Add(-6 * time.Hour).UnixNano() // make sure objects we insert are older than GC thresholds
eval.ModifyTime = time.Now().UTC().Add(-5 * time.Hour).UnixNano()
must.NoError(t, store.UpsertJobSummary(999, mock.JobSummary(eval.JobID)))
must.NoError(t, store.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval}))

Expand Down
4 changes: 2 additions & 2 deletions nomad/mock/csi.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ func CSIVolume(plugin *structs.CSIPlugin) *structs.CSIVolume {
ControllersExpected: len(plugin.Controllers),
NodesHealthy: plugin.NodesHealthy,
NodesExpected: len(plugin.Nodes),
CreateTime: time.Now().Add(-6 * time.Hour).UnixNano(),
ModifyTime: time.Now().Add(-5 * time.Hour).UnixNano(),
CreateTime: time.Now().UTC().Add(-6 * time.Hour).UnixNano(),
ModifyTime: time.Now().UTC().Add(-5 * time.Hour).UnixNano(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion nomad/mock/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func Job() *structs.Job {
CreateIndex: 42,
ModifyIndex: 99,
JobModifyIndex: 99,
SubmitTime: time.Now().Add(-6 * time.Hour).UnixNano(),
SubmitTime: time.Now().UTC().Add(-6 * time.Hour).UnixNano(),
}
job.Canonicalize()
return job
Expand Down
2 changes: 1 addition & 1 deletion scheduler/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func NewAllocReconciler(logger log.Logger, allocUpdateFn allocUpdateType, batch
evalID: evalID,
evalPriority: evalPriority,
supportsDisconnectedClients: supportsDisconnectedClients,
now: time.Now(),
now: time.Now().UTC(),
result: &reconcileResults{
attributeUpdates: make(map[string]*structs.Allocation),
disconnectUpdates: make(map[string]*structs.Allocation),
Expand Down