Skip to content

fix: avoid deleting peers on graceful close #14165

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 14 commits into from
Aug 14, 2024
Prev Previous commit
Next Next commit
pr comments
  • Loading branch information
sreya committed Aug 12, 2024
commit 04472e324adf0c53f44845d62f4db02ab89810ec
6 changes: 1 addition & 5 deletions enterprise/tailnet/pgcoord_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,15 +403,11 @@ func TestPGCoordinatorUnhealthy(t *testing.T) {
mStore.EXPECT().CleanTailnetCoordinators(gomock.Any()).AnyTimes().Return(nil)
mStore.EXPECT().CleanTailnetLostPeers(gomock.Any()).AnyTimes().Return(nil)
mStore.EXPECT().CleanTailnetTunnels(gomock.Any()).AnyTimes().Return(nil)
mStore.EXPECT().UpdateTailnetPeerStatusByCoordinator(gomock.Any(), gomock.Any())

coordinator, err := newPGCoordInternal(ctx, logger, ps, mStore, mClock)
require.NoError(t, err)

mStore.EXPECT().UpdateTailnetPeerStatusByCoordinator(gomock.Any(), database.UpdateTailnetPeerStatusByCoordinatorParams{
CoordinatorID: coordinator.id,
Status: database.TailnetStatusLost,
})

expectedPeriod := HeartbeatPeriod
tfCall, err := tfTrap.Wait(ctx)
require.NoError(t, err)
Expand Down
6 changes: 3 additions & 3 deletions tailnet/test/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/xerrors"

"github.com/coder/coder/v2/tailnet"
Expand Down Expand Up @@ -199,7 +198,7 @@ func (p *Peer) AssertNeverUpdateKind(peer uuid.UUID, kind proto.CoordinateRespon
p.t.Helper()

updates, ok := p.peerUpdates[peer]
require.True(p.t, ok, "expected updates for peer %s", peer)
assert.True(p.t, ok, "expected updates for peer %s", peer)

for _, update := range updates {
assert.NotEqual(p.t, kind, update.Kind, update)
Expand All @@ -224,6 +223,8 @@ func (p *Peer) handleOneResp() error {
if err != nil {
return err
}
p.peerUpdates[id] = append(p.peerUpdates[id], update)

switch update.Kind {
case proto.CoordinateResponse_PeerUpdate_NODE, proto.CoordinateResponse_PeerUpdate_LOST:
peer := p.peers[id]
Expand All @@ -239,7 +240,6 @@ func (p *Peer) handleOneResp() error {
default:
return xerrors.Errorf("unhandled update kind %s", update.Kind)
}
p.peerUpdates[id] = append(p.peerUpdates[id], update)
}
}
return nil
Expand Down
Loading