Skip to content
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
23 changes: 23 additions & 0 deletions clustertest/add_remove_host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package clustertest

import (
"fmt"
"testing"
"time"

Expand Down Expand Up @@ -198,3 +199,25 @@ func TestForcedHostRemovalWithDatabase(t *testing.T) {

tLog(t, "test completed successfully")
}

func TestRollingAddRemove(t *testing.T) {
// Regression test for PLAT-581
t.Parallel()

// Initialize a four-host cluster, then remove host-1, and add another host.
// The order of adds is important because this bug originates in the
// endpoint list for host-2+, so we add each host individually.
cluster := NewCluster(t, ClusterConfig{
Hosts: []HostConfig{
{ID: "host-1"},
},
})
cluster.Init(t)
for i := 2; i <= 4; i++ {
cluster.Add(t, HostConfig{ID: fmt.Sprintf("host-%d", i)})
cluster.Init(t)
}
cluster.Remove(t, "host-1")
cluster.Add(t, HostConfig{ID: "host-5"})
cluster.Init(t)
Comment thread
jason-lynch marked this conversation as resolved.
}
6 changes: 3 additions & 3 deletions clustertest/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ func (c *Cluster) Add(t testing.TB, hostCfg HostConfig) {
func (c *Cluster) Remove(t testing.TB, hostID string) {
t.Helper()

delete(c.hosts, hostID)
c.client = hostsClient(t, c.hosts)

resp, err := c.client.RemoveHost(t.Context(), &controlplane.RemoveHostPayload{
HostID: controlplane.Identifier(hostID),
})
Expand All @@ -114,9 +117,6 @@ func (c *Cluster) Remove(t testing.TB, hostID string) {
TaskID: resp.Task.TaskID,
})
require.NoError(t, err)

delete(c.hosts, hostID)
c.client = hostsClient(t, c.hosts)
}

// RefreshClient recreates the client with updated host configurations.
Expand Down
3 changes: 2 additions & 1 deletion server/internal/etcd/embedded.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,8 @@ func (e *EmbeddedEtcd) GetClient() (*clientv3.Client, error) {
}

cfg := e.cfg.Config()
clientCfg, err := clientConfig(cfg, e.logger, e.etcd.Server.Cluster().ClientURLs()...)
// We only want to connect to our own Etcd endpoint.
clientCfg, err := clientConfig(cfg, e.logger, e.ClientEndpoints()...)
if err != nil {
return nil, fmt.Errorf("failed to get client config: %w", err)
}
Expand Down