Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Apply suggestions from code review
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
  • Loading branch information
johnstcn and mafredri authored Aug 27, 2025
commit bcc545949e344b23fcc3cdd4f8ad0198d730459a
6 changes: 3 additions & 3 deletions coderd/provisionerdserver/provisionerdserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1997,7 +1997,7 @@ func (s *server) completeWorkspaceBuildJob(ctx context.Context, job database.Pro

// This is a hacky workaround for the issue with tasks 'disappearing' on stop:
// reuse has_ai_task and sidebar_app_id from the previous build.
// It should be removed as soon as possible.
// This workaround should be removed as soon as possible.
if workspaceBuild.Transition == database.WorkspaceTransitionStop && workspaceBuild.BuildNumber > 1 {
if prevBuild, err := s.Database.GetWorkspaceBuildByWorkspaceIDAndBuildNumber(ctx, database.GetWorkspaceBuildByWorkspaceIDAndBuildNumberParams{
WorkspaceID: workspaceBuild.WorkspaceID,
Expand All @@ -2006,7 +2006,7 @@ func (s *server) completeWorkspaceBuildJob(ctx context.Context, job database.Pro
hasAITask = prevBuild.HasAITask.Bool
sidebarAppID = prevBuild.AITaskSidebarAppID
warnUnknownSidebarAppID = false
s.Logger.Warn(ctx, "hacky task workaround: reused has_ai_task and sidebar_app_id from previous build",
s.Logger.Debug(ctx, "task workaround: reused has_ai_task and sidebar_app_id from previous build to keep track of task",
slog.F("job_id", job.ID.String()),
slog.F("build_number", prevBuild.BuildNumber),
slog.F("workspace_id", workspace.ID),
Expand All @@ -2016,7 +2016,7 @@ func (s *server) completeWorkspaceBuildJob(ctx context.Context, job database.Pro
slog.F("has_ai_task", hasAITask),
)
} else {
s.Logger.Error(ctx, "hacky task workaround failed",
s.Logger.Error(ctx, "task workaround: tracking via has_ai_task and sidebar_app from previous build failed",
slog.Error(err),
slog.F("job_id", job.ID.String()),
slog.F("workspace_id", workspace.ID),
Expand Down
2 changes: 1 addition & 1 deletion coderd/provisionerdserver/provisionerdserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2842,7 +2842,7 @@ func TestCompleteJob(t *testing.T) {
// has_ai_task has a default value of nil, but once the workspace build completes it will have a value;
// it is set to "true" if the related template has any coder_ai_task resources defined, and its sidebar app ID
// will be set as well in that case.
// HACK: we also set it to "true" if any _previous_ workspace builds ever had it set to "true".
// HACK(johnstcn): we also set it to "true" if any _previous_ workspace builds ever had it set to "true".
// This is to avoid tasks "disappearing" when you stop them.
t.Run("WorkspaceBuild", func(t *testing.T) {
type testcase struct {
Expand Down
Loading