Skip to content

Commit

Permalink
make stream shutdown if self-node has been removed
Browse files Browse the repository at this point in the history
Currently we will read the node from database, and since it is
deleted, the id might be set to nil. Keep the node around and
just shutdown, so it is cleanly removed from notifier.

Fixes #2118

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
  • Loading branch information
kradalby committed Sep 11, 2024
1 parent cac0ff3 commit eb71f8a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions hscontrol/poll.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"math/rand/v2"
"net/http"
"slices"
"sort"
"strings"
"time"
Expand Down Expand Up @@ -273,6 +274,12 @@ func (m *mapSession) serveLongPoll() {
return
}

// If the node has been removed from headscale, close the stream
if slices.Contains(update.Removed, m.node.ID) {
m.tracef("node removed, closing stream")
return
}

m.tracef("received stream update: %s %s", update.Type.String(), update.Message)
mapResponseUpdateReceived.WithLabelValues(update.Type.String()).Inc()

Expand Down

0 comments on commit eb71f8a

Please sign in to comment.