Skip to content
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

xdsclient: make watch timer a no-op if authority is closed #6502

Merged
merged 1 commit into from
Aug 4, 2023
Merged
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
11 changes: 10 additions & 1 deletion xds/internal/xdsclient/authority.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ type authority struct {
// actual state of the resource.
resourcesMu sync.Mutex
resources map[xdsresource.Type]map[string]*resourceState
closed bool
}

// authorityArgs is a convenience struct to wrap arguments required to create a
Expand Down Expand Up @@ -443,6 +444,10 @@ func (a *authority) unrefLocked() int {

func (a *authority) close() {
a.transport.Close()

a.resourcesMu.Lock()
a.closed = true
a.resourcesMu.Unlock()
}

func (a *authority) watchResource(rType xdsresource.Type, resourceName string, watcher xdsresource.ResourceWatcher) func() {
Expand Down Expand Up @@ -507,10 +512,14 @@ func (a *authority) watchResource(rType xdsresource.Type, resourceName string, w
}

func (a *authority) handleWatchTimerExpiry(rType xdsresource.Type, resourceName string, state *resourceState) {
a.logger.Warningf("Watch for resource %q of type %s timed out", resourceName, rType.TypeName())
a.resourcesMu.Lock()
defer a.resourcesMu.Unlock()

if a.closed {
return
}
a.logger.Warningf("Watch for resource %q of type %s timed out", resourceName, rType.TypeName())

switch state.wState {
case watchStateRequested:
// This is the only state where we need to handle the timer expiry by
Expand Down