Skip to content

Commit

Permalink
backport of commit 01ca6e2
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Stucki committed Feb 17, 2023
1 parent 94f4347 commit b137e60
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions agent/xds/delta.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ type ADSDeltaStream = envoy_discovery_v3.AggregatedDiscoveryService_DeltaAggrega

// DeltaAggregatedResources implements envoy_discovery_v3.AggregatedDiscoveryServiceServer
func (s *Server) DeltaAggregatedResources(stream ADSDeltaStream) error {
// this guard is mainly for our tests where we sometimes nil out the
// server stream, any use of the stream after we nil it causes
// pretty much all of the below code to panic.
if stream == nil {
return nil
}

defer s.activeStreams.Increment(stream.Context())()

// a channel for receiving incoming requests
Expand Down
4 changes: 4 additions & 0 deletions agent/xds/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ func (e *TestEnvoy) Close() error {
// unblock the recv chans to simulate recv errors when client disconnects
if e.deltaStream != nil && e.deltaStream.recvCh != nil {
close(e.deltaStream.recvCh)
// TODO: This is causing a bunch of panics in testing code due to inflight
// requests attempting to grab a context from a stream that's nil. Added
// some defensive code in the xDS handler, but really, this should get fixed
// so we no longer have a data-race
e.deltaStream = nil
}
if e.cancel != nil {
Expand Down

0 comments on commit b137e60

Please sign in to comment.