Skip to content

Commit

Permalink
do not return err when canceled
Browse files Browse the repository at this point in the history
Signed-off-by: Qing Hao <[email protected]>
  • Loading branch information
haoqing0110 committed Nov 27, 2024
1 parent 1d29ae0 commit bebdbe4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pkg/registration/spoke/spokeagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,10 @@ func (o *SpokeAgentConfig) RunSpokeAgentWithSpokeInformers(ctx context.Context,
if err := wait.PollUntilContextCancel(bootstrapCtx, 1*time.Second, true, o.internalHubConfigValidFunc); err != nil {
// TODO need run the bootstrap CSR forever to re-establish the client-cert if it is ever lost.
stopBootstrap()
return fmt.Errorf("failed to wait for hub client config for managed cluster to be ready: %w", err)
// DO NOT return error if context canceled, allows leader election to release the leadership.
if err != context.Canceled {
return fmt.Errorf("failed to wait for hub client config for managed cluster to be ready: %w", err)
}
}

// stop the clientCertForHubController for bootstrap once the hub client config is ready
Expand Down
5 changes: 4 additions & 1 deletion pkg/singleton/spoke/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ func (a *AgentConfig) RunSpokeAgent(ctx context.Context, controllerContext *cont
// wait for the hub client config ready.
klog.Info("Waiting for hub client config and managed cluster to be ready")
if err := wait.PollUntilContextCancel(ctx, 1*time.Second, true, a.registrationConfig.IsHubKubeConfigValid); err != nil {
return err
// DO NOT return error if context canceled, allows leader election to release the leadership.
if err != context.Canceled {
return err
}
}

// start work agent
Expand Down

0 comments on commit bebdbe4

Please sign in to comment.