Content-Length: 325311 | pFad | https://github.com/coder/coder/commit/4b252eb0137c773e127866dc56a4698d20cb5919

68 filling out started_at when unhanging not started jobs · coder/coder@4b252eb · GitHub
Skip to content

Commit 4b252eb

Browse files
committed
filling out started_at when unhanging not started jobs
1 parent 2f3d606 commit 4b252eb

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

coderd/database/queries.sql.go

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/provisionerjobs.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ SET
252252
updated_at = $2,
253253
completed_at = $3,
254254
error = $4,
255-
error_code = $5
255+
error_code = $5,
256+
started_at = $6
256257
WHERE
257258
id = $1;
258259

coderd/unhanger/detector.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,21 @@ func unhangJob(ctx context.Context, log slog.Logger, db database.Store, pub pubs
295295
}
296296
lowestLogID = newLogs[0].ID
297297

298-
// Mark the job as failed.
299298
now = dbtime.Now()
299+
// If we are unhanging a job that was never picked up by the
300+
// provisioner, we need to set the started_at time to the current
301+
// time so that the build duration is correct.
302+
if !job.StartedAt.Valid {
303+
job.StartedAt = sql.NullTime{
304+
Time: now,
305+
Valid: true,
306+
}
307+
}
308+
// Mark the job as failed.
300309
err = db.UpdateProvisionerJobWithCompleteByID(ctx, database.UpdateProvisionerJobWithCompleteByIDParams{
301310
ID: job.ID,
302311
UpdatedAt: now,
312+
StartedAt: job.StartedAt,
303313
CompletedAt: sql.NullTime{
304314
Time: now,
305315
Valid: true,

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/coder/coder/commit/4b252eb0137c773e127866dc56a4698d20cb5919

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy