- Notifications
You must be signed in to change notification settings - Fork928
fix(coderd): ensure agent timings are non-zero on insert#18065
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
c148d0d
6afbafe
db019ea
1b83778
afe791f
e2a6e5e
1f1ceb1
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1176,6 +1176,16 @@ func (api *API) buildTimings(ctx context.Context, build database.WorkspaceBuild) | ||
} | ||
for _, t := range provisionerTimings { | ||
// Ref: #15432: agent script timings must not have a zero start or end time. | ||
if t.StartedAt.IsZero() || t.EndedAt.IsZero() { | ||
api.Logger.Debug(ctx, "ignoring provisioner timing with zero start or end time", | ||
slog.F("workspace_id", build.WorkspaceID), | ||
slog.F("workspace_build_id", build.ID), | ||
slog.F("provisioner_job_id", t.JobID), | ||
) | ||
continue | ||
} | ||
res.ProvisionerTimings = append(res.ProvisionerTimings, codersdk.ProvisionerTiming{ | ||
JobID: t.JobID, | ||
Stage: codersdk.TimingStage(t.Stage), | ||
@@ -1187,6 +1197,17 @@ func (api *API) buildTimings(ctx context.Context, build database.WorkspaceBuild) | ||
}) | ||
} | ||
for _, t := range agentScriptTimings { | ||
// Ref: #15432: agent script timings must not have a zero start or end time. | ||
if t.StartedAt.IsZero() || t.EndedAt.IsZero() { | ||
api.Logger.Debug(ctx, "ignoring agent script timing with zero start or end time", | ||
slog.F("workspace_id", build.WorkspaceID), | ||
slog.F("workspace_agent_id", t.WorkspaceAgentID), | ||
slog.F("workspace_build_id", build.ID), | ||
slog.F("workspace_agent_script_id", t.ScriptID), | ||
) | ||
continue | ||
} | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. The issue referenced in#15432 originates from the The We could always omit the entry, but personally I'd like to see it in the graph as an unterminated starting point, would give an indication we're waiting for something. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. We could represent both of these as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. It turns out the timings chart is built to render with a "loading" state until all of provisioner timings, script timings, and connection timings are populated with at least one value. The assumption here is that timings are only useful after a build has completed. My previous change (#18058) adds a check in the UI so that causes a time range with a zero time to be rendered as an "instant" with an "Invalid" label. I think that, for now, it makes sense to simply exclude the agent connection timing if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I'm fine with that if it can show up later if the agent finally connects 👍🏻 | ||
res.AgentScriptTimings = append(res.AgentScriptTimings, codersdk.AgentScriptTiming{ | ||
StartedAt: t.StartedAt, | ||
EndedAt: t.EndedAt, | ||
@@ -1199,6 +1220,14 @@ func (api *API) buildTimings(ctx context.Context, build database.WorkspaceBuild) | ||
}) | ||
} | ||
for _, agent := range agents { | ||
if agent.FirstConnectedAt.Time.IsZero() { | ||
api.Logger.Debug(ctx, "ignoring agent connection timing with zero first connected time", | ||
slog.F("workspace_id", build.WorkspaceID), | ||
slog.F("workspace_agent_id", agent.ID), | ||
slog.F("workspace_build_id", build.ID), | ||
) | ||
continue | ||
} | ||
res.AgentConnectionTimings = append(res.AgentConnectionTimings, codersdk.AgentConnectionTiming{ | ||
WorkspaceAgentID: agent.ID.String(), | ||
WorkspaceAgentName: agent.Name, | ||
Uh oh!
There was an error while loading.Please reload this page.