Skip to content

Commit 9124b00

Browse files
committed
Denest packages for replicas
1 parent fdb3557 commit 9124b00

File tree

7 files changed

+17
-25
lines changed

7 files changed

+17
-25
lines changed

enterprise/coderd/coderd.go

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ import (
2424
"github.com/coder/coder/enterprise/audit"
2525
"github.com/coder/coder/enterprise/audit/backends"
2626
"github.com/coder/coder/enterprise/coderd/license"
27-
"github.com/coder/coder/enterprise/highavailability"
28-
"github.com/coder/coder/enterprise/highavailability/derpmesh"
29-
"github.com/coder/coder/enterprise/highavailability/replicasync"
30-
"github.com/coder/coder/tailnet"
27+
"github.com/coder/coder/enterprise/derpmesh"
28+
"github.com/coder/coder/enterprise/replicasync"
29+
"github.com/coder/coder/enterprise/tailnet"
30+
agpltailnet "github.com/coder/coder/tailnet"
3131
)
3232

3333
// New constructs an Enterprise coderd API instance.
@@ -117,15 +117,6 @@ func New(ctx context.Context, options *Options) (*API, error) {
117117
})
118118
}
119119

120-
// If high availability is disabled and multiple replicas appear, show an error.
121-
// If high availability is enabled and the built-in DERP is but the DERP relay isn't set, show an error.
122-
// We need to block meshing if high availability is disabled, because the meshing code would just work.
123-
// SetAddresses([]string{})
124-
125-
api.AGPL.RootHandler.Route("/replicas", func(r chi.Router) {
126-
127-
})
128-
129120
var err error
130121
api.replicaManager, err = replicasync.New(ctx, options.Logger, options.Database, options.Pubsub, replicasync.Options{
131122
ID: options.ReplicaID,
@@ -244,9 +235,9 @@ func (api *API) updateEntitlements(ctx context.Context) error {
244235
}
245236

246237
if changed, enabled := featureChanged(codersdk.FeatureHighAvailability); changed {
247-
coordinator := tailnet.NewCoordinator()
238+
coordinator := agpltailnet.NewCoordinator()
248239
if enabled {
249-
haCoordinator, err := highavailability.NewCoordinator(api.Logger, api.Pubsub)
240+
haCoordinator, err := tailnet.NewCoordinator(api.Logger, api.Pubsub)
250241
if err != nil {
251242
api.Logger.Error(ctx, "unable to set up high availability coordinator", slog.Error(err))
252243
// If we try to setup the HA coordinator and it fails, nothing
@@ -265,6 +256,7 @@ func (api *API) updateEntitlements(ctx context.Context) error {
265256
})
266257
} else {
267258
api.derpMesh.SetAddresses([]string{})
259+
api.replicaManager.SetCallback(func() {})
268260
}
269261

270262
// Recheck changed in case the HA coordinator failed to set up.

enterprise/highavailability/derpmesh/derpmesh_test.go renamed to enterprise/derpmesh/derpmesh_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616

1717
"cdr.dev/slog"
1818
"cdr.dev/slog/sloggers/slogtest"
19-
"github.com/coder/coder/enterprise/highavailability/derpmesh"
19+
"github.com/coder/coder/enterprise/derpmesh"
2020
"github.com/coder/coder/tailnet"
2121
)
2222

enterprise/highavailability/replicasync/replicasync_test.go renamed to enterprise/replicasync/replicasync_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"cdr.dev/slog/sloggers/slogtest"
1818
"github.com/coder/coder/coderd/database"
1919
"github.com/coder/coder/coderd/database/dbtestutil"
20-
"github.com/coder/coder/enterprise/highavailability/replicasync"
20+
"github.com/coder/coder/enterprise/replicasync"
2121
"github.com/coder/coder/testutil"
2222
)
2323

enterprise/highavailability/coordinator.go renamed to enterprise/tailnet/coordinator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package highavailability
1+
package tailnet
22

33
import (
44
"bytes"

enterprise/highavailability/coordinator_test.go renamed to enterprise/tailnet/coordinator_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package highavailability_test
1+
package tailnet_test
22

33
import (
44
"net"
@@ -11,7 +11,7 @@ import (
1111
"cdr.dev/slog/sloggers/slogtest"
1212

1313
"github.com/coder/coder/coderd/database"
14-
"github.com/coder/coder/enterprise/highavailability"
14+
"github.com/coder/coder/enterprise/tailnet"
1515
agpl "github.com/coder/coder/tailnet"
1616
"github.com/coder/coder/testutil"
1717
)
@@ -20,7 +20,7 @@ func TestCoordinatorSingle(t *testing.T) {
2020
t.Parallel()
2121
t.Run("ClientWithoutAgent", func(t *testing.T) {
2222
t.Parallel()
23-
coordinator, err := highavailability.NewCoordinator(slogtest.Make(t, nil), database.NewPubsubInMemory())
23+
coordinator, err := tailnet.NewCoordinator(slogtest.Make(t, nil), database.NewPubsubInMemory())
2424
require.NoError(t, err)
2525
defer coordinator.Close()
2626

@@ -48,7 +48,7 @@ func TestCoordinatorSingle(t *testing.T) {
4848

4949
t.Run("AgentWithoutClients", func(t *testing.T) {
5050
t.Parallel()
51-
coordinator, err := highavailability.NewCoordinator(slogtest.Make(t, nil), database.NewPubsubInMemory())
51+
coordinator, err := tailnet.NewCoordinator(slogtest.Make(t, nil), database.NewPubsubInMemory())
5252
require.NoError(t, err)
5353
defer coordinator.Close()
5454

@@ -76,7 +76,7 @@ func TestCoordinatorSingle(t *testing.T) {
7676
t.Run("AgentWithClient", func(t *testing.T) {
7777
t.Parallel()
7878

79-
coordinator, err := highavailability.NewCoordinator(slogtest.Make(t, nil), database.NewPubsubInMemory())
79+
coordinator, err := tailnet.NewCoordinator(slogtest.Make(t, nil), database.NewPubsubInMemory())
8080
require.NoError(t, err)
8181
defer coordinator.Close()
8282

@@ -169,11 +169,11 @@ func TestCoordinatorHA(t *testing.T) {
169169

170170
pubsub := database.NewPubsubInMemory()
171171

172-
coordinator1, err := highavailability.NewCoordinator(slogtest.Make(t, nil), pubsub)
172+
coordinator1, err := tailnet.NewCoordinator(slogtest.Make(t, nil), pubsub)
173173
require.NoError(t, err)
174174
defer coordinator1.Close()
175175

176-
coordinator2, err := highavailability.NewCoordinator(slogtest.Make(t, nil), pubsub)
176+
coordinator2, err := tailnet.NewCoordinator(slogtest.Make(t, nil), pubsub)
177177
require.NoError(t, err)
178178
defer coordinator2.Close()
179179

0 commit comments

Comments
 (0)