Skip to content

Commit

Permalink
fix: calibrate clocks
Browse files Browse the repository at this point in the history
  • Loading branch information
rangoo94 committed Aug 13, 2024
1 parent a70e92b commit 5652bfd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
8 changes: 6 additions & 2 deletions pkg/api/v1/testkube/model_test_workflow_result_extended.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,12 @@ func (r *TestWorkflowResult) Recompute(sig []TestWorkflowSignature, scheduledAt
r.Status = common.Ptr(RUNNING_TestWorkflowStatus)
}

if r.FinishedAt.IsZero() && r.Status != nil && *r.Status == ABORTED_TestWorkflowStatus {
r.FinishedAt = r.LatestTimestamp()
// Ensure the finish time is after all other timestamps
if !r.FinishedAt.IsZero() || (r.Status != nil && *r.Status == ABORTED_TestWorkflowStatus) {
lastTs := r.LatestTimestamp()
if r.FinishedAt.Before(lastTs) {
r.FinishedAt = lastTs
}
}

// Compute the duration
Expand Down
6 changes: 3 additions & 3 deletions pkg/testworkflows/testworkflowcontroller/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,11 @@ func (n *notifier) Output(ref string, ts time.Time, output *instructions.Instruc
}

func (n *notifier) Finish(ts time.Time) {
n.resultMu.Lock()
defer n.resultMu.Unlock()
if !n.result.FinishedAt.Before(ts) {
if ts.IsZero() {
return
}
n.resultMu.Lock()
defer n.resultMu.Unlock()
n.result.FinishedAt = ts
n.emit()
}
Expand Down
15 changes: 11 additions & 4 deletions pkg/testworkflows/testworkflowcontroller/watchinstrumentedpod.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,20 +269,27 @@ func WatchInstrumentedPod(parentCtx context.Context, clientSet kubernetes.Interf
Status: testkube.ABORTED_TestWorkflowStepStatus,
ExitCode: -1,
Details: result.Details,
FinishedAt: result.FinishedAt,
FinishedAt: s.GetStepResult(ref).FinishedAt,
}
if status.FinishedAt.IsZero() {
status.FinishedAt = result.FinishedAt
}
if status.FinishedAt.IsZero() {
status.FinishedAt = state.FinishedAt("")
if status.FinishedAt.IsZero() {
status.FinishedAt = s.GetLastTimestamp(lastStarted)
}
}
if status.FinishedAt.IsZero() {
status.FinishedAt = s.GetLastTimestamp(lastStarted)
}

if len(result.Steps) > i {
status = result.Steps[i]
if status.Details == "" {
status.Details = result.Details
}
finishedAt := s.GetStepResult(ref).FinishedAt
if !finishedAt.IsZero() {
status.FinishedAt = finishedAt
}
}
s.FinishStep(ref, status)
if status.Status == testkube.ABORTED_TestWorkflowStepStatus {
Expand Down

0 comments on commit 5652bfd

Please sign in to comment.