Skip to content

Commit bdddc3e

Browse files
authored
fix: change auto-start to automatically update workspaces (coder#6053)
Fixes coder#6049.
1 parent d6947ae commit bdddc3e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

coderd/autobuild/executor/lifecycle_executor.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ func build(ctx context.Context, store database.Store, workspace database.Workspa
295295
CreatedAt: now,
296296
UpdatedAt: now,
297297
WorkspaceID: workspace.ID,
298-
TemplateVersionID: priorHistory.TemplateVersionID,
298+
TemplateVersionID: template.ActiveVersionID,
299299
BuildNumber: priorBuildNumber + 1,
300300
ProvisionerState: priorHistory.ProvisionerState,
301301
InitiatorID: workspace.OwnerID,

coderd/autobuild/executor/lifecycle_executor_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ func TestExecutorAutostartTemplateUpdated(t *testing.T) {
9999
close(tickCh)
100100
}()
101101

102-
// Then: the workspace should be started using the previous template version, and not the updated version.
102+
// Then: the workspace is started using the new template version, not the old one.
103103
stats := <-statsCh
104104
assert.NoError(t, stats.Error)
105105
assert.Len(t, stats.Transitions, 1)
106106
assert.Contains(t, stats.Transitions, workspace.ID)
107107
assert.Equal(t, database.WorkspaceTransitionStart, stats.Transitions[workspace.ID])
108108
ws := coderdtest.MustWorkspace(t, client, workspace.ID)
109-
assert.Equal(t, workspace.LatestBuild.TemplateVersionID, ws.LatestBuild.TemplateVersionID, "expected workspace build to be using the old template version")
109+
assert.Equal(t, newVersion.ID, ws.LatestBuild.TemplateVersionID, "expected workspace build to be using the new template version")
110110
}
111111

112112
func TestExecutorAutostartAlreadyRunning(t *testing.T) {

0 commit comments

Comments
 (0)