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): call CloseSend and exit a goroutine when sync fails to start (backport of #7869) #7883

Merged
merged 1 commit into from
Sep 26, 2023
Merged
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
50 changes: 40 additions & 10 deletions pkg/kds/mux/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,26 @@ func (c *client) startGlobalToZoneSync(ctx context.Context, log logr.Logger, con
errorCh <- err
return
}
c.globalToZoneCb.OnGlobalToZoneSyncStarted(stream, errorCh)
<-stop
log.Info("Global to Zone Sync rpc stream stopped")
if err := stream.CloseSend(); err != nil {
errorCh <- errors.Wrap(err, "CloseSend returned an error")
processingErrorsCh := make(chan error)
c.globalToZoneCb.OnGlobalToZoneSyncStarted(stream, processingErrorsCh)
select {
case <-stop:
log.Info("Global to Zone Sync rpc stream stopped")
if err := stream.CloseSend(); err != nil {
errorCh <- errors.Wrap(err, "CloseSend returned an error")
}
case err := <-processingErrorsCh:
if status.Code(err) == codes.Unimplemented {
log.Error(err, "Global to Zone Sync rpc stream failed, because Global CP does not implement this rpc. Upgrade Global CP.")
// backwards compatibility. Do not rethrow error, so Admin RPC can still operate.
return
}
log.Error(err, "Global to Zone Sync rpc stream failed, will restart in background")
if err := stream.CloseSend(); err != nil {
log.Error(err, "CloseSend returned an error")
}
errorCh <- err
return
}
}

Expand All @@ -180,11 +195,26 @@ func (c *client) startZoneToGlobalSync(ctx context.Context, log logr.Logger, con
errorCh <- err
return
}
c.zoneToGlobalCb.OnZoneToGlobalSyncStarted(stream, errorCh)
<-stop
log.Info("Zone to Global Sync rpc stream stopped")
if err := stream.CloseSend(); err != nil {
errorCh <- errors.Wrap(err, "CloseSend returned an error")
processingErrorsCh := make(chan error)
c.zoneToGlobalCb.OnZoneToGlobalSyncStarted(stream, processingErrorsCh)
select {
case <-stop:
log.Info("Zone to Global Sync rpc stream stopped")
if err := stream.CloseSend(); err != nil {
errorCh <- errors.Wrap(err, "CloseSend returned an error")
}
case err := <-processingErrorsCh:
if status.Code(err) == codes.Unimplemented {
log.Error(err, "Zone to Global Sync rpc stream failed, because Global CP does not implement this rpc. Upgrade Global CP.")
// backwards compatibility. Do not rethrow error, so Admin RPC can still operate.
return
}
log.Error(err, "Zone to Global Sync rpc stream failed, will restart in background")
if err := stream.CloseSend(); err != nil {
log.Error(err, "CloseSend returned an error")
}
errorCh <- err
return
}
}

Expand Down