mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: fix replicasync to function for NATS even if no DERP relay address is set (#27235)
<!-- If you have used AI to produce some or all of this PR, please ensure you have read our [AI Contribution guidelines](https://coder.com/docs/about/contributing/AI_CONTRIBUTING) before submitting. --> Fixes `replicasync` so that it keeps peers even if they don't set a RelayAddress. This allows NATS to function even if you are not running a DERP relay on the primay Coderd instances. Also renames some replicasync functions to make it clear they are for DERP.
This commit is contained in:
@@ -1024,7 +1024,7 @@ func (api *API) updateEntitlements(ctx context.Context) error {
|
||||
// Only update DERP mesh if the built-in server is enabled.
|
||||
if api.Options.DeploymentValues.DERP.Server.Enable {
|
||||
addresses := make([]string, 0)
|
||||
for _, replica := range api.replicaManager.Regional() {
|
||||
for _, replica := range api.replicaManager.DERPReplicasThisRegion() {
|
||||
// Don't add replicas with an empty relay address.
|
||||
if replica.RelayAddress == "" {
|
||||
continue
|
||||
|
||||
@@ -671,10 +671,7 @@ func TestMultiReplica_NATSPubsubPeers(t *testing.T) {
|
||||
t.Cleanup(func() { _ = natsB.Close() })
|
||||
|
||||
mgr, err := replicasync.New(ctx, logger.Named("replica-b"), db, pgPubsub, &replicasync.Options{
|
||||
ID: uuid.New(),
|
||||
// port doesn't matter because we don't have an API up, but replicasync will refuse peers that don't set
|
||||
// RelayAddress at all.
|
||||
RelayAddress: "https://127.0.0.1",
|
||||
ID: uuid.New(),
|
||||
ClusterHost: "127.0.0.1",
|
||||
RegionID: 12345,
|
||||
UpdateInterval: testutil.IntervalFast,
|
||||
|
||||
@@ -723,7 +723,7 @@ func (api *API) workspaceProxyRegister(rw http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
|
||||
// Find sibling regions to respond with for derpmesh.
|
||||
siblings := api.replicaManager.InRegion(regionID)
|
||||
siblings := api.replicaManager.DERPReplicasInRegion(regionID)
|
||||
siblingsRes := make([]codersdk.Replica, 0, len(siblings))
|
||||
for _, replica := range siblings {
|
||||
if replica.ID == req.ReplicaID {
|
||||
|
||||
Reference in New Issue
Block a user