Skip to content

Commit 1506c39

Browse files
committed
easwars review #2
1 parent 4a0f4e6 commit 1506c39

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

xds/internal/clients/xdsclient/ads_stream.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,9 @@ func (s *adsStreamImpl) sendMessageLocked(stream clients.Stream, names []string,
445445
}
446446
}
447447

448-
// Call the event handler to remove unsubscribed cache entries.
448+
// Call the event handler to remove unsubscribed cache entries. It is to
449+
// ensure the cache entries are deleted even if discovery request fails. In
450+
// case of failure when the stream restarts, nonce is reset anyways.
449451
s.eventHandler.onRequest(url)
450452

451453
msg, err := proto.Marshal(req)

xds/internal/clients/xdsclient/authority.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -293,18 +293,19 @@ func (a *authority) fallbackToServer(xc *xdsChannelWithConfig) bool {
293293
// Subscribe to all existing resources from the new management server.
294294
for typ, resources := range a.resources {
295295
for name, state := range resources {
296-
if len(state.watchers) > 0 {
297-
if a.logger.V(2) {
298-
a.logger.Infof("Resubscribing to resource of type %q and name %q", typ.TypeName, name)
299-
}
300-
xc.channel.subscribe(typ, name)
301-
302-
// Add the new channel to the list of xdsChannels from which this
303-
// resource has been requested from. Retain the cached resource and
304-
// the set of existing watchers (and other metadata fields) in the
305-
// resource state.
306-
state.xdsChannelConfigs[xc] = true
296+
if len(state.watchers) == 0 {
297+
continue
298+
}
299+
if a.logger.V(2) {
300+
a.logger.Infof("Resubscribing to resource of type %q and name %q", typ.TypeName, name)
307301
}
302+
xc.channel.subscribe(typ, name)
303+
304+
// Add the new channel to the list of xdsChannels from which this
305+
// resource has been requested from. Retain the cached resource and
306+
// the set of existing watchers (and other metadata fields) in the
307+
// resource state.
308+
state.xdsChannelConfigs[xc] = true
308309
}
309310
}
310311
return true

xds/internal/clients/xdsclient/channel.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ func (xc *xdsChannel) close() {
147147

148148
// Get the resource types that this specific ADS stream was handling
149149
// before stopping it.
150+
//
151+
// TODO: Revisit if we can avoid acquiring the lock of ads (another type).
150152
xc.ads.mu.Lock()
151153
typesHandledByStream := make([]ResourceType, 0, len(xc.ads.resourceTypeState))
152154
for typ := range xc.ads.resourceTypeState {

0 commit comments

Comments
 (0)