@@ -57,7 +57,28 @@ func (e *Executor) runOnce(t time.Time) error {
57
57
// Determine the workspace state based on its latest build.
58
58
latestBuild ,err := db .GetWorkspaceBuildByWorkspaceIDWithoutAfter (e .ctx ,ws .ID )
59
59
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
61
82
}
62
83
63
84
var validTransition database.WorkspaceTransition