Skip to content

Commit b39fde2

Browse files
committed
fix: executor: skip workspaces whose last build was not successful
1 parent cc0e161 commit b39fde2

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

coderd/lifecycle/executor/lifecycle_executor.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,28 @@ func (e *Executor) runOnce(t time.Time) error {
5757
// Determine the workspace state based on its latest build.
5858
latestBuild, err := db.GetWorkspaceBuildByWorkspaceIDWithoutAfter(e.ctx, ws.ID)
5959
if err != nil {
60-
return xerrors.Errorf("get latest build for workspace %q: %w", ws.ID, err)
60+
e.log.Warn(e.ctx, "get latest workspace build",
61+
slog.F("workspace_id", ws.ID),
62+
slog.Error(err),
63+
)
64+
continue
65+
}
66+
67+
lastBuild, err := db.GetProvisionerJobByID(e.ctx, latestBuild.JobID)
68+
if err != nil {
69+
e.log.Warn(e.ctx, "get last provisioner job for workspace %q: %w",
70+
slog.F("workspace_id", ws.ID),
71+
slog.Error(err),
72+
)
73+
continue
74+
}
75+
76+
if !lastBuild.CompletedAt.Valid || lastBuild.Error.String != "" {
77+
e.log.Warn(e.ctx, "last workspace build did not complete successfully, skipping",
78+
slog.F("workspace_id", ws.ID),
79+
slog.F("error", lastBuild.Error.String),
80+
)
81+
continue
6182
}
6283

6384
var validTransition database.WorkspaceTransition

0 commit comments

Comments
 (0)