Skip to content

Commit 2f3d606

Browse files
committed
added detector handling of not started jobs
1 parent 0f51f35 commit 2f3d606

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

coderd/unhanger/detector.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,14 @@ func (d *Detector) run(t time.Time) Stats {
179179
stats.Error = xerrors.Errorf("get hung provisioner jobs: %w", err)
180180
return stats
181181
}
182+
// Find all provisioner jobs that are currently running but have not
183+
// received an update in the last 5 minutes.
184+
if err != nil {
185+
stats.Error = xerrors.Errorf("get not started provisioner jobs: %w", err)
186+
return stats
187+
}
188+
jobsUnstarted, err := d.db.GetNotStartedProvisionerJobs(ctx, t.Add(-HungJobDuration))
189+
jobs = append(jobs, jobsUnstarted...)
182190

183191
// Limit the number of jobs we'll unhang in a single run to avoid
184192
// timing out.
@@ -229,14 +237,6 @@ func unhangJob(ctx context.Context, log slog.Logger, db database.Store, pub pubs
229237
return xerrors.Errorf("get provisioner job: %w", err)
230238
}
231239

232-
// Check if we should still unhang it.
233-
if !job.StartedAt.Valid {
234-
// This shouldn't be possible to hit because the query only selects
235-
// started and not completed jobs, and a job can't be "un-started".
236-
return jobIneligibleError{
237-
Err: xerrors.New("job is not started"),
238-
}
239-
}
240240
if job.CompletedAt.Valid {
241241
return jobIneligibleError{
242242
Err: xerrors.Errorf("job is completed (status %s)", job.JobStatus),

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy