8000 feat: make pgCoordinator generally available by spikecurtis · Pull Request #8419 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat: make pgCoordinator generally available #8419

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 4 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Diff view
4 changes: 2 additions & 2 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

509 changes: 255 additions & 254 deletions coderd/database/dbfake/dbfake.go

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions coderd/database/pubsub/pubsub_memory.go
8000
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,22 @@ func (g genericListener) send(ctx context.Context, message []byte) {
}
}

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

func (m *memoryPubsub) Subscribe(event string, listener Listener) (cancel func(), err error) {
func (m *MemoryPubsub) Subscribe(event string, listener Listener) (cancel func(), err error) {
return m.subscribeGeneric(event, genericListener{l: listener})
}

func (m *memoryPubsub) SubscribeWithErr(event string, listener ListenerWithErr) (cancel func(), err error) {
func (m *MemoryPubsub) SubscribeWithErr(event string, listener ListenerWithErr) (cancel func(), err error) {
return m.subscribeGeneric(event, genericListener{le: listener})
}

func (m *memoryPubsub) subscribeGeneric(event string, listener genericListener) (cancel func(), err error) {
func (m *MemoryPubsub) subscribeGeneric(event string, listener genericListener) (cancel func(), err error) {
m.mut.Lock()
defer m.mut.Unlock()

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

func (m *memoryPubsub) Publish(event string, message []byte) error {
func (m *MemoryPubsub) Publish(event string, message []byte) error {
m.mut.RLock()
defer m.mut.RUnlock()
listeners, ok := m.listeners[event]
Expand All @@ -83,12 +84,12 @@ func (m *memoryPubsub) Publish(event string, message []byte) error {
return nil
}

func (*memoryPubsub) Close() error {
func (*MemoryPubsub) Close() error {
return nil
}

func NewInMemory() Pubsub {
return &memoryPubsub{
return &MemoryPubsub{
listeners: make(map[string]map[uuid.UUID]genericListener),
}
}
7 changes: 4 additions & 3 deletions codersdk/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -1755,9 +1755,10 @@ const (
// https://github.com/coder/coder/milestone/19
ExperimentWorkspaceActions Experiment = "workspace_actions"

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

// ExperimentConvertToOIDC enables users to convert from password to
// oidc.
Expand Down
2 changes: 1 addition & 1 deletion docs/api/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -2541,7 +2541,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
| ------------------------- |
| `moons` |
| `workspace_actions` |
| `tailnet_pg_coordinator` |
| `tailnet_ha_coordinator` |
| `convert-to-oidc` |
| `workspace_build_logs_ui` |

Expand Down
7 changes: 2 additions & 5 deletions enterprise/cli/features_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/stretchr/testify/require"

"github.com/coder/coder/cli/clitest"
"github.com/coder/coder/coderd/coderdtest"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/enterprise/coderd/coderdenttest"
"github.com/coder/coder/pty/ptytest"
Expand All @@ -19,8 +18,7 @@ func TestFeaturesList(t *testing.T) {
t.Parallel()
t.Run("Table", func(t *testing.T) {
t.Parallel()
client := coderdenttest.New(t, nil)
coderdtest.CreateFirstUser(t, client)
client, _ := coderdenttest.New(t, &coderdenttest.Options{DontAddLicense: true})
inv, conf := newCLI(t, "features", "list")
clitest.SetupConfig(t, client, conf)
pty := ptytest.New(t).Attach(inv)
Expand All @@ -31,8 +29,7 @@ func TestFeaturesList(t *testing.T) {
t.Run("JSON", func(t *testing.T) {
t.Parallel()

client := coderdenttest.New(t, nil)
coderdtest.CreateFirstUser(t, client)
client, _ := coderdenttest.New(t, &coderdenttest.Options{DontAddLicense: true})
inv, conf := newCLI(t, "features", "list", "-o", "json")
clitest.SetupConfig(t, client, conf)
doneChan := make(chan struct{})
Expand Down
7 changes: 2 additions & 5 deletions enterprise/cli/groupcreate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"github.com/coder/coder/cli/clitest"
"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/coderd/coderdtest"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/enterprise/coderd/coderdenttest"
"github.com/coder/coder/enterprise/coderd/license"
Expand All @@ -21,13 +20,11 @@ func TestCreateGroup(t *testing.T) {
t.Run("OK", func(t *testing.T) {
t.Parallel()

client := coderdenttest.New(t, nil)
coderdtest.CreateFirstUser(t, client)
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
client, _ := coderdenttest.New(t, &coderdenttest.Options{LicenseOptions: &coderdenttest.LicenseOptions{
Features: license.Features{
codersdk.FeatureTemplateRBAC: 1,
},
})
}})

var (
groupName = "test"
Expand Down
15 changes: 4 additions & 11 deletions enterprise/cli/groupdelete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"github.com/coder/coder/cli/clitest"
"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/coderd/coderdtest"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/enterprise/coderd/coderdenttest"
"github.com/coder/coder/enterprise/coderd/license"
Expand All @@ -22,14 +21,11 @@ func TestGroupDelete(t *testing.T) {
t.Run("OK", func(t *testing.T) {
t.Parallel()

client := coderdenttest.New(t, nil)
admin := coderdtest.CreateFirstUser(t, client)

_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
client, admin := coderdenttest.New(t, &coderdenttest.Options{LicenseOptions: &coderdenttest.LicenseOptions{
Features: license.Features{
codersdk.FeatureTemplateRBAC: 1,
},
})
}})

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

client := coderdenttest.New(t, nil)
_ = coderdtest.CreateFirstUser(t, client)

_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
client, _ := coderdenttest.New(t, &coderdenttest.Options{LicenseOptions: &coderdenttest.LicenseOptions{
Features: license.Features{
codersdk.FeatureTemplateRBAC: 1,
},
})
}})

inv, conf := newCLI(
t,
Expand Down
21 changes: 6 additions & 15 deletions enterprise/cli/groupedit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@ func TestGroupEdit(t *testing.T) {
t.Run("OK", func(t *testing.T) {
t.Parallel()

client := coderdenttest.New(t, nil)
admin := coderdtest.CreateFirstUser(t, client)

_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
client, admin := coderdenttest.New(t, &coderdenttest.Options{LicenseOptions: &coderdenttest.LicenseOptions{
Features: license.Features{
codersdk.FeatureTemplateRBAC: 1,
},
})
}})

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

client := coderdenttest.New(t, nil)
admin := coderdtest.CreateFirstUser(t, client)

_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
client, admin := coderdenttest.New(t, &coderdenttest.Options{LicenseOptions: &coderdenttest.LicenseOptions{
Features: license.Features{
codersdk.FeatureTemplateRBAC: 1,
},
})
}})

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

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

client := coderdenttest.New(t, nil)
_ = coderdtest.CreateFirstUser(t, client)

_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
client, _ := coderdenttest.New(t, &coderdenttest.Options{LicenseOptions: &coderdenttest.LicenseOptions{
Features: license.Features{
codersdk.FeatureTemplateRBAC: 1,
},
})
}})

inv, conf := newCLI(t, "groups", "edit")
clitest.SetupConfig(t, client, conf)
Expand Down
14 changes: 4 additions & 10 deletions enterprise/cli/grouplist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@ func TestGroupList(t *testing.T) {
t.Run("OK", func(t *testing.T) {
t.Parallel()

client := coderdenttest.New(t, nil)
admin := coderdtest.CreateFirstUser(t, client)

_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
client, admin := coderdenttest.New(t, &coderdenttest.Options{LicenseOptions: &coderdenttest.LicenseOptions{
Features: license.Features{
codersdk.FeatureTemplateRBAC: 1,
},
})
}})

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

client := coderdenttest.New(t, nil)
_ = coderdtest.CreateFirstUser(t, client)

_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
client, _ := coderdenttest.New(t, &coderdenttest.Options{LicenseOptions: &coderdenttest.LicenseOptions{
Features: license.Features{
codersdk.FeatureTemplateRBAC: 1,
},
})
}})

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

Expand Down
10 changes: 3 additions & 7 deletions enterprise/cli/licenses_test.go
F438
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (

"github.com/coder/coder/cli/clibase"
"github.com/coder/coder/cli/clitest"
"github.com/coder/coder/coderd/coderdtest"
"github.com/coder/coder/coderd/httpapi"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/enterprise/coderd/coderdenttest"
Expand Down Expand Up @@ -118,8 +117,7 @@ func TestLicensesAddReal(t *testing.T) {
t.Parallel()
t.Run("Fails", func(t *testing.T) {
t.Parallel()
client := coderdenttest.New(t, nil)
coderdtest.CreateFirstUser(t, client)
client, _ := coderdenttest.New(t, &coderdenttest.Options{DontAddLicense: true})
inv, conf := newCLI(
t,
"licenses", "add", "-l", fakeLicenseJWT,
Expand Down Expand Up @@ -173,8 +171,7 @@ func TestLicensesListReal(t *testing.T) {
t.Parallel()
t.Run("Empty", func(t *testing.T) {
t.Parallel()
client := coderdenttest.New(t, nil)
coderdtest.CreateFirstUser(t, client)
client, _ := coderdenttest.New(t, &coderdenttest.Options{DontAddLicense: true})
inv, conf := newCLI(
t,
"licenses", "list",
Expand Down Expand Up @@ -215,8 +212,7 @@ func TestLicensesDeleteReal(t *testing.T) {
t.Parallel()
t.Run("Empty", func(t *testing.T) {
t.Parallel()
client := coderdenttest.New(t, nil)
coderdtest.CreateFirstUser(t, client)
client, _ := coderdenttest.New(t, &coderdenttest.Options{DontAddLicense: true})
inv, conf := newCLI(
t,
"licenses", "delete", "1")
Expand Down
22 changes: 10 additions & 12 deletions enterprise/cli/workspaceproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ func Test_ProxyCRUD(t *testing.T) {
"*",
}

client := coderdenttest.New(t, &coderdenttest.Options{
client, _ := coderdenttest.New(t, &coderdenttest.Options{
Options: &coderdtest.Options{
DeploymentValues: dv,
},
})
_ = coderdtest.CreateFirstUser(t, client)
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
Features: license.Features{
codersdk.FeatureWorkspaceProxy: 1,
LicenseOptions: &coderdenttest.LicenseOptions{
Features: license.Features{
codersdk.FeatureWorkspaceProxy: 1,
},
},
})

Expand Down Expand Up @@ -102,15 +101,14 @@ func Test_ProxyCRUD(t *testing.T) {
"*",
}

client := coderdenttest.New(t, &coderdenttest.Options{
client, _ := coderdenttest.New(t, &coderdenttest.Options{
Options: &coderdtest.Options{
DeploymentValues: dv,
},
})
_ = coderdtest.CreateFirstUser(t, client)
_ = coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
Features: license.Features{
codersdk.FeatureWorkspaceProxy: 1,
LicenseOptions: &coderdenttest.LicenseOptions{
Features: license.Features{
codersdk.FeatureWorkspaceProxy: 1,
},
},
})

Expand Down
Loading
0