From c6824ca145db47214151985d9fa54c863e4d3d11 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Mon, 29 Jul 2024 18:29:02 +0000 Subject: [PATCH 1/2] fix: duplicate tags map in mutation to resolve race See: https://github.com/coder/coder/actions/runs/10149619748/job/28064952716?pr=14046 --- provisionersdk/provisionertags.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/provisionersdk/provisionertags.go b/provisionersdk/provisionertags.go index 9dc9bd7392678..741fbeede279d 100644 --- a/provisionersdk/provisionertags.go +++ b/provisionersdk/provisionertags.go @@ -18,9 +18,10 @@ const ( // NOTE: "owner" must NEVER be nil. Otherwise it will end up being // duplicated in the database, as idx_provisioner_daemons_name_owner_key // is a partial unique index that includes a JSON field. -func MutateTags(userID uuid.UUID, tags map[string]string) map[string]string { - if tags == nil { - tags = map[string]string{} +func MutateTags(userID uuid.UUID, provided map[string]string) map[string]string { + tags := map[string]string{} + for k, v := range provided { + tags[k] = v } _, ok := tags[TagScope] if !ok { From d49a116d95e000fe4288d3064ced437f1609e849 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Mon, 29 Jul 2024 20:12:36 +0000 Subject: [PATCH 2/2] Fix deployment values race --- enterprise/cli/create_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/enterprise/cli/create_test.go b/enterprise/cli/create_test.go index ee0d7297c52de..33423e366a538 100644 --- a/enterprise/cli/create_test.go +++ b/enterprise/cli/create_test.go @@ -34,11 +34,11 @@ func TestEnterpriseCreate(t *testing.T) { secondTemplates []string } - dv := coderdtest.DeploymentValues(t) - dv.Experiments = []string{string(codersdk.ExperimentMultiOrganization)} // setupMultipleOrganizations creates an extra organization, assigns a member // both organizations, and optionally creates templates in each organization. setupMultipleOrganizations := func(t *testing.T, args setupArgs) setupData { + dv := coderdtest.DeploymentValues(t) + dv.Experiments = []string{string(codersdk.ExperimentMultiOrganization)} ownerClient, first := coderdenttest.New(t, &coderdenttest.Options{ Options: &coderdtest.Options{ DeploymentValues: dv,