8000 chore: pull in cherry picks for v2.24 by stirby · Pull Request #18674 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

chore: pull in cherry picks for v2.24 #18674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Jul 1, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
73ffb71
chore: remove chats experiment (#18535)
dannykopping Jun 25, 2025
cc51308
feat: allow new immutable parameters for existing workspaces (#18579)
Emyrk Jun 25, 2025
fac6263
chore: upgrade aisdk-go lib, remove vestigial code (#18577)
dannykopping Jun 25, 2025
4c938c0
refactor: remove beta label from 'select a preset' menu (#18538)
BrunoQuaresma Jun 25, 2025
19d8a40
fix: hide the preset parameter visibility switch when it has no effec…
SasSwart Jun 26, 2025
a4a5892
feat: graduate prebuilds to general availability (#18607)
SasSwart Jun 26, 2025
8e6417a
fix(agent): start devcontainers through agentcontainers package (#18471)
DanielleMaywood Jun 25, 2025
63b619c
fix(agent/agentcontainers): filter out "is test run" devcontainers (#…
mafredri Jun 25, 2025
03d1570
feat(agent/agentcontainers): add feature options as envs (#18576)
mafredri Jun 25, 2025
5be5bf3
fix(coderd/agentapi): make sub agent slugs more unique (#18581)
DanielleMaywood Jun 25, 2025
cf6d208
feat(agent/agentcontainers): add more envs to readconfig for app URL …
mafredri Jun 26, 2025
226aec1
fix!: use devcontainer ID when rebuilding a devcontainer (#18604)
DanielleMaywood Jun 26, 2025
766fc4c
fix(agent/agentcontainers): chown coder binary (#18611) 8000
DanielleMaywood Jun 26, 2025
07d749c
fix(agent/agentcontainers): stop logging empty lines (#18605)
DanielleMaywood Jun 26, 2025
aab5059
chore: parse app status link (#18439)
code-asher Jun 26, 2025
cbc97de
fix(agent): delay containerAPI init to ensure startup scripts run bef…
mafredri Jun 27, 2025
5058d1b
feat: add task link in the workspace page when it is running a task (…
BrunoQuaresma Jun 27, 2025
b7c7d1a
refactor: move required external auth buttons to the submit side (#18…
BrunoQuaresma Jun 27, 2025
b8930ec
fix(agent): fix script filtering for devcontainers (#18635)
mafredri Jun 27, 2025
1891c6f
refactor: show the apps as soon as possible (#18625)
BrunoQuaresma Jun 27, 2025
99f3664
feat: redirect to the task page after creation (#18626)
BrunoQuaresma Jun 27, 2025
19089ad
fix: use default preset when creating a workspace for task (#18623)
BrunoQuaresma Jun 27, 2025
47f813e
fix(agent/agentcontainers): ensure proper channel closure for updateT…
mafredri Jun 27, 2025
2a68b01
fix(agent/agentcontainers): split Init into Init and Start for early …
mafredri Jun 27, 2025
2daec01
feat: make task panels resizable (#18590)
BrunoQuaresma Jun 27, 2025
9e923f9
fix: use only template version ID to create task workspace (#18642)
BrunoQuaresma Jun 27, 2025
830a9ed
chore: add beta badge to tasks (#18656)
dannykopping Jun 30, 2025
da71915
fix(agent/agentcontainers): always derive devcontainer name from work…
mafredri Jun 30, 2025
9a9dd5d
fix: handle health status when displaying task apps (#18675)
hugodutka Jun 30, 2025
4bcbc96
fix: improve reliability of app statuses (#18622)
code-asher Jun 30, 2025
2d210aa
chore: fix idle state icon when disabled (#18554)
code-asher Jun 25, 2025
459b9d9
docs: add warning about prebuilds incompatibility with certain featur…
ssncferreira Jul 1, 2025
b975443
Merge branch 'release/2.24' into cherry-picks-2.24
stirby Jul 1, 2025
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
8000
Diff view
Prev Previous commit
Next Next commit
fix(agent/agentcontainers): always derive devcontainer name from work…
…space folder (#18666)

(cherry picked from commit 9ccaf86)
  • Loading branch information
mafredri authored and stirby committed Jun 30, 2025
commit da71915b1f8711b3a1bc8f7cb2d4543814df931b
28 changes: 21 additions & 7 deletions agent/agentcontainers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,25 @@ func WithDevcontainers(devcontainers []codersdk.WorkspaceAgentDevcontainer, scri
if dc.Status == "" {
dc.Status = codersdk.WorkspaceAgentDevcontainerStatusStarting
}
logger := api.logger.With(
slog.F("devcontainer_id", dc.ID),
slog.F("devcontainer_name", dc.Name),
slog.F("workspace_folder", dc.WorkspaceFolder),
slog.F("config_path", dc.ConfigPath),
)

// Devcontainers have a name originating from Terraform, but
// we need to ensure that the name is unique. We will use
// the workspace folder name to generate a unique agent name,
// and if that fails, we will fall back to the devcontainers
// original name.
name, usingWorkspaceFolder := api.makeAgentName(dc.WorkspaceFolder, dc.Name)
if name != dc.Name {
logger = logger.With(slog.F("devcontainer_name", name))
logger.Debug(api.ctx, "updating devcontainer name", slog.F("devcontainer_old_name", dc.Name))
dc.Name = name
api.usingWorkspaceFolderName[dc.WorkspaceFolder] = usingWorkspaceFolder
}

api.knownDevcontainers[dc.WorkspaceFolder] = dc
api.devcontainerNames[dc.Name] = true
Expand All @@ -223,12 +242,7 @@ func WithDevcontainers(devcontainers []codersdk.WorkspaceAgentDevcontainer, scri
}
}
if api.devcontainerLogSourceIDs[dc.WorkspaceFolder] == uuid.Nil {
api.logger.Error(api.ctx, "devcontainer log source ID not found for devcontainer",
slog.F("devcontainer_id", dc.ID),
8000 slog.F("devcontainer_name", dc.Name),
slog.F("workspace_folder", dc.WorkspaceFolder),
slog.F("config_path", dc.ConfigPath),
)
logger.Error(api.ctx, "devcontainer log source ID not found for devcontainer")
}
}
}
Expand Down Expand Up @@ -872,7 +886,7 @@ func (api *API) getContainers() (codersdk.WorkspaceAgentListContainersResponse,
devcontainers = append(devcontainers, dc)
}
slices.SortFunc(devcontainers, func(a, b codersdk.WorkspaceAgentDevcontainer) int {
return strings.Compare(a.Name, b.Name)
return strings.Compare(a.WorkspaceFolder, b.WorkspaceFolder)
})
}

Expand Down
79 changes: 79 additions & 0 deletions agent/agentcontainers/api_test.go
6F70
Original file line number Diff line number Diff line change
Expand Up @@ -2596,3 +2596,82 @@ func fakeContainer(t *testing.T, mut ...func(*codersdk.WorkspaceAgentContainer))
}
return ct
}

func TestWithDevcontainersNameGeneration(t *testing.T) {
t.Parallel()

if runtime.GOOS == "windows" {
t.Skip("Dev Container tests are not supported on Windows")
}

devcontainers := []codersdk.WorkspaceAgentDevcontainer{
{
ID: uuid.New(),
Name: "original-name",
WorkspaceFolder: "/home/coder/foo/project",
ConfigPath: "/home/coder/foo/project/.devcontainer/devcontainer.json",
},
{
ID: uuid.New(),
Name: "another-name",
WorkspaceFolder: "/home/coder/bar/project",
ConfigPath: "/home/coder/bar/project/.devcontainer/devcontainer.json",
},
}

scripts := []codersdk.WorkspaceAgentScript{
{ID: devcontainers[0].ID, LogSourceID: uuid.New()},
{ID: devcontainers[1].ID, LogSourceID: uuid.New()},
}

logger := testutil.Logger(t)

// This should trigger the WithDevcontainers code path where names are generated
api := agentcontainers.NewAPI(logger,
agentcontainers.WithDevcontainers(devcontainers, scripts),
agentcontainers.WithContainerCLI(&fakeContainerCLI{
containers: codersdk.WorkspaceAgentListContainersResponse{
Containers: []codersdk.WorkspaceAgentContainer{
fakeContainer(t, func(c *codersdk.WorkspaceAgentContainer) {
c.ID = "some-container-id-1"
c.FriendlyName = "container-name-1"
c.Labels[agentcontainers.DevcontainerLocalFolderLabel] = "/home/coder/baz/project"
c.Labels[agentcontainers.DevcontainerConfigFileLabel] = "/home/coder/baz/project/.devcontainer/devcontainer.json"
}),
},
},
}),
agentcontainers.WithDevcontainerCLI(&fakeDevcontainerCLI{}),
agentcontainers.WithSubAgentClient(&fakeSubAgentClient{}),
agentcontainers.WithWatcher(watcher.NewNoop()),
)
defer api.Close()
api.Start()

r := chi.NewRouter()
r.Mount("/", api.Routes())

ctx := context.Background()

err := api.RefreshContainers(ctx)
require.NoError(t, err, "RefreshContainers should not error")

// Initial request returns the initial data.
req := httptest.NewRequest(http.MethodGet, "/", nil).
WithContext(ctx)
rec := httptest.NewRecorder()
r.ServeHTTP(rec, req)

require.Equal(t, http.StatusOK, rec.Code)
var response codersdk.WorkspaceAgentListContainersResponse
err = json.NewDecoder(rec.Body).Decode(&response)
require.NoError(t, err)

// Verify the devcontainers have the expected names.
require.Len(t, response.Devcontainers, 3, "should have two devcontainers")
assert.NotEqual(t, "original-name", response.Devcontainers[2].Name, "first devcontainer should not keep original name")
assert.Equal(t, "project", response.Devcontainers[2].Name, "first devcontainer should use the project folder name")
assert.NotEqual(t, "another-name", response.Devcontainers[0].Name, "second devcontainer should not keep original name")
assert.Equal(t, "bar-project", response.Devcontainers[0].Name, "second devcontainer should has a collision and uses the folder name with a prefix")
assert.Equal(t, "baz-project", response.Devcontainers[1].Name, "third devcontainer should use the folder name with a prefix since it collides with the first two")
}
Loading
0