Skip to content

Commit

Permalink
fix : panic when second sidcar registe
Browse files Browse the repository at this point in the history
  • Loading branch information
njy17 committed Nov 30, 2023
1 parent 5f207e2 commit 2be94f1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apiserver/xdsserverv3/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (sc *XDSCache) CreateDeltaWatch(request *cachev3.DeltaRequest, state stream
}
item := sc.loadCache(request)
if item == nil {
value <- nil
value <- &NoReadyXdsResponse{}
return func() {}
}
return item.CreateDeltaWatch(request, state, value)
Expand Down
20 changes: 20 additions & 0 deletions apiserver/xdsserverv3/cache/response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package cache

import (
"errors"

discovery "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3"
cachev3 "github.com/envoyproxy/go-control-plane/pkg/cache/v3"
)

type NoReadyXdsResponse struct{
cachev3.DeltaResponse
}

func (r *NoReadyXdsResponse) GetDeltaRequest() *discovery.DeltaDiscoveryRequest{
return nil
}

func (r *NoReadyXdsResponse) GetDeltaDiscoveryResponse() (*discovery.DeltaDiscoveryResponse, error){
return nil, errors.New("node xds not created yet")
}

0 comments on commit 2be94f1

Please sign in to comment.