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

fix(kds): try returning unavailable on app context finish #8050

Merged
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions pkg/kds/global/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ func Setup(rt runtime.Runtime) error {
*rt.Config().Multizone.Global.KDS,
rt.Metrics(),
service.NewGlobalKDSServiceServer(
rt.AppContext(),
rt.KDSContext().EnvoyAdminRPCs,
rt.ResourceManager(),
rt.GetInstanceId(),
Expand All @@ -195,6 +196,7 @@ func Setup(rt runtime.Runtime) error {
rt.Config().Multizone.Global.KDS.ZoneHealthCheck.PollInterval.Duration,
),
mux.NewKDSSyncServiceServer(
rt.AppContext(),
onGlobalToZoneSyncConnect,
onZoneToGlobalSyncConnect,
rt.KDSContext().GlobalServerFiltersV2,
Expand Down
17 changes: 8 additions & 9 deletions pkg/kds/mux/zone_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,12 @@ type KDSSyncServiceServer struct {
extensions context.Context
eventBus events.EventBus
mesh_proto.UnimplementedKDSSyncServiceServer
context context.Context
}

func NewKDSSyncServiceServer(
globalToZoneCb OnGlobalToZoneSyncConnectFunc,
zoneToGlobalCb OnZoneToGlobalSyncConnectFunc,
filters []FilterV2,
extensions context.Context,
eventBus events.EventBus,
) *KDSSyncServiceServer {
func NewKDSSyncServiceServer(ctx context.Context, globalToZoneCb OnGlobalToZoneSyncConnectFunc, zoneToGlobalCb OnZoneToGlobalSyncConnectFunc, filters []FilterV2, extensions context.Context, eventBus events.EventBus) *KDSSyncServiceServer {
return &KDSSyncServiceServer{
context: ctx,
globalToZoneCb: globalToZoneCb,
zoneToGlobalCb: zoneToGlobalCb,
filters: filters,
Expand Down Expand Up @@ -87,10 +83,13 @@ func (g *KDSSyncServiceServer) GlobalToZoneSync(stream mesh_proto.KDSSyncService
select {
case <-shouldDisconnectStream.Recv():
logger.Info("ending stream, zone health check failed")
return nil
return status.Error(codes.Canceled, "stream canceled - zone hc failed")
case <-stream.Context().Done():
logger.Info("GlobalToZoneSync rpc stream stopped")
return nil
return status.Error(codes.Canceled, "stream canceled - stream stopped")
case <-g.context.Done():
logger.Info("app context done")
return status.Error(codes.Unavailable, "stream unavailable")
case err := <-processingErrorsCh:
if status.Code(err) == codes.Unimplemented {
return errors.Wrap(err, "GlobalToZoneSync rpc stream failed, because Global CP does not implement this rpc. Upgrade Global CP.")
Expand Down
18 changes: 7 additions & 11 deletions pkg/kds/service/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,12 @@ type GlobalKDSServiceServer struct {
eventBus events.EventBus
zoneHealthCheckInterval time.Duration
mesh_proto.UnimplementedGlobalKDSServiceServer
context context.Context
}

func NewGlobalKDSServiceServer(
envoyAdminRPCs EnvoyAdminRPCs,
resManager manager.ResourceManager,
instanceID string,
filters []StreamInterceptor,
extensions context.Context,
upsertCfg config_store.UpsertConfig,
eventBus events.EventBus,
zoneHealthCheckInterval time.Duration,
) *GlobalKDSServiceServer {
func NewGlobalKDSServiceServer(ctx context.Context, envoyAdminRPCs EnvoyAdminRPCs, resManager manager.ResourceManager, instanceID string, filters []StreamInterceptor, extensions context.Context, upsertCfg config_store.UpsertConfig, eventBus events.EventBus, zoneHealthCheckInterval time.Duration) *GlobalKDSServiceServer {
return &GlobalKDSServiceServer{
context: ctx,
envoyAdminRPCs: envoyAdminRPCs,
resManager: resManager,
instanceID: instanceID,
Expand Down Expand Up @@ -203,9 +196,12 @@ func (g *GlobalKDSServiceServer) streamEnvoyAdminRPC(
}
}()
select {
case <-g.context.Done():
logger.Info("app context done")
return status.Error(codes.Unavailable, "stream unavailable")
case <-shouldDisconnectStream.Recv():
logger.Info("ending stream, zone health check failed")
return nil
return status.Error(codes.Canceled, "stream canceled")
case res := <-streamResult:
return res
}
Expand Down
Loading