mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix!: enforce agent names be case-insensitive-unique per-workspace (#16614)
Relates to https://github.com/coder/coder-desktop-macos/issues/54 Currently, it's possible to have two agents within the same workspace whose names only differ in capitalization: This leads to an ambiguity in two cases: - For CoderVPN, we'd like to allow support to workspaces with a hostname of the form: `agent.workspace.username.coder`. - Workspace apps (`coder_app`s) currently use subdomains of the form: `<app>--<agent>--<workspace>--<username>(--<suffix>)?`. Of note is that DNS hosts must be strictly lower case, hence the ambiguity. This fix is technically a breaking change, but only for the incredibly rare use case where a user has: - A workspace with two agents - Those agent names differ only in capitalization. Those templates & workspaces will now fail to build. This can be fixed by choosing wholly unique names for the agents.
This commit is contained in:
@@ -1905,6 +1905,32 @@ func TestInsertWorkspaceResource(t *testing.T) {
|
||||
})
|
||||
require.ErrorContains(t, err, "duplicate app slug")
|
||||
})
|
||||
t.Run("DuplicateAgentNames", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db := dbmem.New()
|
||||
job := uuid.New()
|
||||
// case-insensitive-unique
|
||||
err := insert(db, job, &sdkproto.Resource{
|
||||
Name: "something",
|
||||
Type: "aws_instance",
|
||||
Agents: []*sdkproto.Agent{{
|
||||
Name: "dev",
|
||||
}, {
|
||||
Name: "Dev",
|
||||
}},
|
||||
})
|
||||
require.ErrorContains(t, err, "duplicate agent name")
|
||||
err = insert(db, job, &sdkproto.Resource{
|
||||
Name: "something",
|
||||
Type: "aws_instance",
|
||||
Agents: []*sdkproto.Agent{{
|
||||
Name: "dev",
|
||||
}, {
|
||||
Name: "dev",
|
||||
}},
|
||||
})
|
||||
require.ErrorContains(t, err, "duplicate agent name")
|
||||
})
|
||||
t.Run("Success", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db := dbmem.New()
|
||||
|
||||
Reference in New Issue
Block a user