8000 feat: make pgCoordinator generally available (#8419) · coder/coder@b4057bd · GitHub
[go: up one dir, main page]

Skip to content

Commit b4057bd

Browse files
authored
feat: make pgCoordinator generally available (#8419)
* pgCoord to GA, fix tests Signed-off-by: Spike Curtis <spike@coder.com> * Fix generation and coordinator delete RBAC Signed-off-by: Spike Curtis <spike@coder.com> * Fix fakeQuerier -> FakeQuerier Signed-off-by: Spike Curtis <spike@coder.com> --------- Signed-off-by: Spike Curtis <spike@coder.com>
1 parent 2e9f3e0 commit b4057bd

35 files changed

+818
-949
lines changed

coderd/apidoc/docs.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/dbfake/dbfake.go

Lines changed: 255 additions & 254 deletions
Large diffs are not rendered by default.

coderd/database/pubsub/pubsub_memory.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,22 @@ func (g genericListener) send(ctx context.Context, message []byte) {
2222
}
2323
}
2424

25-
// memoryPubsub is an in-memory Pubsub implementation.
26-
type memoryPubsub struct {
25+
// MemoryPubsub is an in-memory Pubsub implementation. It's an exported type so that our test code can do type
26+
// checks.
27+
type MemoryPubsub struct {
2728
mut sync.RWMutex
2829
listeners map[string]map[uuid.UUID]genericListener
2930
}
3031

31-
func (m *memoryPubsub) Subscribe(event string, listener Listener) (cancel func(), err error) {
32+
func (m *MemoryPubsub) Subscribe(event string, listener Listener) (cancel func(), err error) {
3233
return m.subscribeGeneric(event, genericListener{l: listener})
3334
}
3435

35-
func (m *memoryPubsub) SubscribeWithErr(event string, listener ListenerWithErr) (cancel func(), err error) {
36+
func (m *MemoryPubsub) SubscribeWithErr(event string, listener ListenerWithErr) (cancel func(), err error) {
3637
return m.subscribeGeneric(event, genericListener{le: listener})
3738
}
3839

39-
func (m *memoryPubsub) subscribeGeneric(event string, listener genericListener) (cancel func(), err error) {
40+
func (m *MemoryPubsub) subscribeGeneric(event string, listener genericListener) (cancel func(), err error) {
4041
m.mut.Lock()
4142
defer m.mut.Unlock()
4243

@@ -62,7 +63,7 @@ func (m *memoryPubsub) subscribeGeneric(event string, listener genericListener)
6263
}, nil
6364
}
6465

65-
func (m *memoryPubsub) Publish(event string, message []byte) error {
66+
func (m *MemoryPubsub) Publish(event string, message []byte) error {
6667
m.mut.RLock()
6768
defer m.mut.RUnlock()
6869
listeners, ok := m.listeners[event]
@@ -83,12 +84,12 @@ func (m *memoryPubsub) Publish(event string, message []byte) error {
8384
return nil
8485
}
8586

86-
func (*memoryPubsub) Close() error {
87+
func (*MemoryPubsub) Close() error {
8788
return nil
8889
}
8990

9091
func NewInMemory() Pubsub {
91-
return &memoryPubsub{
92+
return &MemoryPubsub{
9293
listeners: make(map[string]map[uuid.UUID]genericListener),
9394
}
9495
}

codersdk/deployment.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,9 +1755,10 @@ const (
17551755
// https://github.com/coder/coder/milestone/19
17561756
ExperimentWorkspaceActions Experiment = "workspace_actions"
17571757

1758-
// ExperimentTailnetPGCoordinator enables the PGCoord in favor of the pubsub-
1759-
// only Coordinator
1760-
ExperimentTailnetPGCoordinator Experiment = "tailnet_pg_coordinator"
1758+
// ExperimentTailnetHACoordinator downgrades to the haCoordinator instead
1759+
// of PGCoord. Should only be used if we see issues in prod with PGCoord
1760+
// which is now the default.
1761+
ExperimentTailnetHACoordinator Experiment = "tailnet_ha_coordinator"
17611762

17621763
// ExperimentConvertToOIDC enables users to convert from password to
17631764
// oidc.

docs/api/schemas.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2541,7 +2541,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
25412541
| ------------------------- |
25422542
| `moons` |
25432543
| `workspace_actions` |
2544-
| `tailnet_pg_coordinator` |
2544+
| `tailnet_ha_coordinator` |
25452545
| `convert-to-oidc` |
25462546
| `workspace_build_logs_ui` |
25472547

enterprise/cli/features_test.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/stretchr/testify/require"
1010

1111
"github.com/coder/coder/cli/clitest"
12-
"github.com/coder/coder/coderd/coderdtest"
1312
"github.com/coder/coder/codersdk"
1413
"github.com/coder/coder/enterprise/coderd/coderdenttest"
1514
"github.com/coder/coder/pty/ptytest"
@@ -19,8 +18,7 @@ func TestFeaturesList(t *testing.T) {
1918
t.Parallel()
2019
t.Run("Table", func(t *testing.T) {
2120
t.Parallel()
22-
client := coderdenttest.New(t, nil)
23-
coderdtest.CreateFirstUser(t, client)
21+
client, _ := coderdenttest.New(t, &coderdenttest.Options{DontAddLicense: true})
2422
inv, conf := newCLI(t, "features", "list")
2523
clitest.SetupConfig(t, client, conf)
2624
pty := ptytest.New(t).Attach(inv)
@@ -31,8 +29,7 @@ func TestFeaturesList(t *testing.T) {
3129
t.Run("JSON", func(t *testing.T) {
3230
t.Parallel()
3331

34-
client := coderdenttest.New(t, nil)
35-
coderdtest.CreateFirstUser(t, client)
32+
client, _ := coderdenttest.New(t, &coderdenttest.Options{DontAddLicense: true})
3633
inv, conf := newCLI(t, "features", "list", "-o", "json")
3734
clitest.SetupConfig(t, client, conf)
3835
doneChan := make(chan struct{})

enterprise/cli/groupcreate_test.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88

99
"github.com/coder/coder/cli/clitest"
1010
"github.com/coder/coder/cli/cliui"
11-
"github.com/coder/coder/coderd/coderdtest"
1211
"github.com/coder/coder/codersdk"
1312
"github.com/coder/coder/enterprise/coderd/coderdenttest"
1413
"github.com/coder/coder/enterprise/coderd/license"
@@ -21,13 +20,11 @@ func TestCreateGroup(t *testing.T) {
2120
t.Run("OK", func(t *testing.T) {
2221
t.Parallel()
2322

24-
client := coderdenttest.New(t, nil)
25-
coderdtest.CreateFirstUser(t, client)
26-
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
23+
client, _ := coderdenttest.New(t, &coderdenttest.Options{LicenseOptions: &coderdenttest.LicenseOptions{
2724
Features: license.Features{
2825
codersdk.FeatureTemplateRBAC: 1,
2926
},
30-
})
27+
}})
3128

3229
var (
3330
groupName = "test"

enterprise/cli/groupdelete_test.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88

99
"github.com/coder/coder/cli/clitest"
1010
"github.com/coder/coder/cli/cliui"
11-
"github.com/coder/coder/coderd/coderdtest"
1211
"github.com/coder/coder/codersdk"
1312
"github.com/coder/coder/enterprise/coderd/coderdenttest"
1413
"github.com/coder/coder/enterprise/coderd/license"
@@ -22,14 +21,11 @@ func TestGroupDelete(t *testing.T) {
2221
t.Run("OK", func(t *testing.T) {
2322
t.Parallel()
2423

25-
client := coderdenttest.New(t, nil)
26-
admin := coderdtest.CreateFirstUser(t, client)
27-
28-
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
24+
client, admin := coderdenttest.New(t, &coderdenttest.Options{LicenseOptions: &coderdenttest.LicenseOptions{
2925
Features: license.Features{
3026
codersdk.FeatureTemplateRBAC: 1,
3127
},
32-
})
28+
}})
3329

3430
ctx := testutil.Context(t, testutil.WaitLong)
3531
group, err := client.CreateGroup(ctx, admin.OrganizationID, codersdk.CreateGroupRequest{
@@ -55,14 +51,11 @@ func TestGroupDelete(t *testing.T) {
5551
t.Run("NoArg", func(t *testing.T) {
5652
t.Parallel()
5753

58-
client := coderdenttest.New(t, nil)
59-
_ = coderdtest.CreateFirstUser(t, client)
60-
61-
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
54+
client, _ := coderdenttest.New(t, &coderdenttest.Options{LicenseOptions: &coderdenttest.LicenseOptions{
6255
Features: license.Features{
6356
codersdk.FeatureTemplateRBAC: 1,
6457
},
65-
})
58+
}})
6659

6760
inv, conf := newCLI(
6861
t,

enterprise/cli/groupedit_test.go

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,11 @@ func TestGroupEdit(t *testing.T) {
2222
t.Run("OK", func(t *testing.T) {
2323
t.Parallel()
2424

25-
client := coderdenttest.New(t, nil)
26-
admin := coderdtest.CreateFirstUser(t, client)
27-
28-
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
25+
client, admin := coderdenttest.New(t, &coderdenttest.Options{LicenseOptions: &coderdenttest.LicenseOptions{
2926
Features: license.Features{
3027
codersdk.FeatureTemplateRBAC: 1,
3128
},
32-
})
29+
}})
3330

3431
ctx := testutil.Context(t, testutil.WaitLong)
3532
_, user1 := coderdtest.CreateAnotherUser(t, client, admin.OrganizationID)
@@ -74,14 +71,11 @@ func TestGroupEdit(t *testing.T) {
7471
t.Run("InvalidUserInput", func(t *testing.T) {
7572
t.Parallel()
7673

77-
client := coderdenttest.New(t, nil)
78-
admin := coderdtest.CreateFirstUser(t, client)
79-
80-
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
74+
client, admin := coderdenttest.New(t, &coderdenttest.Options{LicenseOptions: &coderdenttest.LicenseOptions{
8175
Features: license.Features{
8276
codersdk.FeatureTemplateRBAC: 1,
8377
},
84-
})
78+
}})
8579

8680
ctx := testutil.Context(t, testutil.WaitLong)
8781

@@ -106,14 +100,11 @@ func TestGroupEdit(t *testing.T) {
106100
t.Run("NoArg", func(t *testing.T) {
107101
t.Parallel()
108102

109-
client := coderdenttest.New(t, nil)
110-
_ = coderdtest.CreateFirstUser(t, client)
111-
112-
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
103+
client, _ := coderdenttest.New(t, &coderdenttest.Options{LicenseOptions: &coderdenttest.LicenseOptions{
113104
Features: license.Features{
114105
codersdk.FeatureTemplateRBAC: 1,
115106
},
116-
})
107+
}})
117108

118109
inv, conf := newCLI(t, "groups", "edit")
119110
clitest.SetupConfig(t, client, conf)

enterprise/cli/grouplist_test.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,11 @@ func TestGroupList(t *testing.T) {
2020
t.Run("OK", func(t *testing.T) {
2121
t.Parallel()
2222

23-
client := coderdenttest.New(t, nil)
24-
admin := coderdtest.CreateFirstUser(t, client)
25-
26-
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
23+
client, admin := coderdenttest.New(t, &coderdenttest.Options{LicenseOptions: &coderdenttest.LicenseOptions{
2724
Features: license.Features{
2825
codersdk.FeatureTemplateRBAC: 1,
2926
},
30-
})
27+
}})
3128

3229
ctx := testutil.Context(t, testutil.WaitLong)
3330
_, user1 := coderdtest.CreateAnotherUser(t, client, admin.OrganizationID)
@@ -80,14 +77,11 @@ func TestGroupList(t *testing.T) {
8077
t.Run("NoGroups", func(t *testing.T) {
8178
t.Parallel()
8279

83-
client := coderdenttest.New(t, nil)
84-
_ = coderdtest.CreateFirstUser(t, client)
85-
86-
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
80+
client, _ := coderdenttest.New(t, &coderdenttest.Options{LicenseOptions: &coderdenttest.LicenseOptions{
8781
Features: license.Features{
8882
codersdk.FeatureTemplateRBAC: 1,
8983
},
90-
})
84+
}})
9185

9286
inv, conf := newCLI(t, "groups", "list")
9387

enterprise/cli/licenses_test.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818

1919
"github.com/coder/coder/cli/clibase"
2020
"github.com/coder/coder/cli/clitest"
21-
"github.com/coder/coder/coderd/coderdtest"
2221
"github.com/coder/coder/coderd/httpapi"
2322
"github.com/coder/coder/codersdk"
2423
"github.com/coder/coder/enterprise/coderd/coderdenttest"
@@ -118,8 +117,7 @@ func TestLicensesAddReal(t *testing.T) {
118117
t.Parallel()
119118
t.Run("Fails", func(t *testing.T) {
120119
t.Parallel()
121-
client := coderdenttest.New(t, nil)
122-
coderdtest.CreateFirstUser(t, client)
120+
client, _ := coderdenttest.New(t, &coderdenttest.Options{DontAddLicense: true})
123121
inv, conf := newCLI(
124122
t,
125123
"licenses", "add", "-l", fakeLicenseJWT,
@@ -173,8 +171,7 @@ func TestLicensesListReal(t *testing.T) {
173171
t.Parallel()
174172
t.Run("Empty", func(t *testing.T) {
175173
t.Parallel()
176-
client := coderdenttest.New(t, nil)
177-
coderdtest.CreateFirstUser(t, client)
174+
client, _ := coderdenttest.New(t, &coderdenttest.Options{DontAddLicense: true})
178175
inv, conf := newCLI(
179176
t,
180177
"licenses", "list",
@@ -215,8 +212,7 @@ func TestLicensesDeleteReal(t *testing.T) {
215212
t.Parallel()
216213
t.Run("Empty", func(t *testing.T) {
217214
t.Parallel()
218-
client := coderdenttest.New(t, nil)
219-
coderdtest.CreateFirstUser(t, client)
215+
client, _ := coderdenttest.New(t, &coderdenttest.Options{DontAddLicense: true})
220216
inv, conf := newCLI(
221217
t,
222218
"licenses", "delete", "1")

enterprise/cli/workspaceproxy_test.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,14 @@ func Test_ProxyCRUD(t *testing.T) {
2929
"*",
3030
}
3131

32-
client := coderdenttest.New(t, &coderdenttest.Options{
32+
client, _ := coderdenttest.New(t, &coderdenttest.Options{
3333
Options: &coderdtest.Options{
3434
DeploymentValues: dv,
3535
},
36-
})
37-
_ = coderdtest.CreateFirstUser(t, client)
38-
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
39-
Features: license.Features{
40-
codersdk.FeatureWorkspaceProxy: 1,
36+
LicenseOptions: &coderdenttest.LicenseOptions{
37+
Features: license.Features{
38+
codersdk.FeatureWorkspaceProxy: 1,
39+
},
4140
},
4241
})
4342

@@ -102,15 +101,14 @@ func Test_ProxyCRUD(t *testing.T) {
102101
"*",
103102
}
104103

105-
client := coderdenttest.New(t, &coderdenttest.Options{
104+
client, _ := coderdenttest.New(t, &coderdenttest.Options{
106105
Options: &coderdtest.Options{
107106
DeploymentValues: dv,
108107
},
109-
})
110-
_ = coderdtest.CreateFirstUser(t, client)
111-
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
112-
Features: license.Features{
113-
codersdk.FeatureWorkspaceProxy: 1,
108+
LicenseOptions: &coderdenttest.LicenseOptions{
109+
Features: license.Features{
110+
codersdk.FeatureWorkspaceProxy: 1,
111+
},
114112
},
115113
})
116114

0 commit comments

Comments
 (0)
0