Skip to content

Commit

Permalink
Support specific case of specific subscription removed while in wildc…
Browse files Browse the repository at this point in the history
…ard mode

Signed-off-by: Valerian Roche <valerian.roche@datadoghq.com>
  • Loading branch information
valerian-roche committed Apr 19, 2022
1 parent ce2ff57 commit 5f4d7df
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/cache/v3/delta.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func createDeltaResponse(ctx context.Context, req *DeltaRequest, state stream.St
}

// Compute resources for removal
// The resource version can be set to "" here to trigger a removal even if never returned before
for name := range state.GetResourceVersions() {
if _, ok := resources.resourceMap[name]; !ok {
toRemove = append(toRemove, name)
Expand Down
8 changes: 8 additions & 0 deletions pkg/server/delta/v3/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,5 +235,13 @@ func (s *server) unsubscribe(resources []string, streamState *stream.StreamState
continue
}
delete(sv, resource)
if _, ok := sv[resource]; ok && streamState.IsWildcard() {
// xds protocol specifically states that if a resource if unsubscribed while a wildcard watch is present,
// the control-plane must return a response with either the resource set as removed (if no longer present in the snapshot)
// or with its content
// If the stream is in wildcard mode specifying an empty entry in the resource versions will either send the resource content
// or mark it as removed (done in createDeltaResponse)
state.GetResourceVersions()[resource] = ""
}
}
}

0 comments on commit 5f4d7df

Please sign in to comment.