mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-19 15:39:17 +00:00
Switch kube-proxy/server.go to context-aware logging APIs (HandleErrorWithContext, UntilWithContext)
This commit is contained in:
@@ -440,7 +440,7 @@ func serveHealthz(ctx context.Context, hz *healthcheck.ProxyHealthServer, errCh
|
||||
return
|
||||
}
|
||||
|
||||
fn := func() {
|
||||
fn := func(ctx context.Context) {
|
||||
err := hz.Run(ctx)
|
||||
if err != nil {
|
||||
logger.Error(err, "Healthz server failed")
|
||||
@@ -454,7 +454,7 @@ func serveHealthz(ctx context.Context, hz *healthcheck.ProxyHealthServer, errCh
|
||||
logger.Error(nil, "Healthz server returned without error")
|
||||
}
|
||||
}
|
||||
go wait.Until(fn, 5*time.Second, ctx.Done())
|
||||
go wait.UntilWithContext(ctx, fn, 5*time.Second)
|
||||
}
|
||||
|
||||
func serveMetrics(ctx context.Context, bindAddress string, proxyMode kubeproxyconfig.ProxyMode, enableProfiling bool, flagzReader flagz.Reader, errCh chan error) {
|
||||
@@ -493,12 +493,11 @@ func serveMetrics(ctx context.Context, bindAddress string, proxyMode kubeproxyco
|
||||
statusz.Install(proxyMux, kubeProxy, reg)
|
||||
}
|
||||
|
||||
fn := func() {
|
||||
fn := func(ctx context.Context) {
|
||||
var err error
|
||||
defer func() {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("starting metrics server failed: %w", err)
|
||||
utilruntime.HandleError(err)
|
||||
utilruntime.HandleErrorWithContext(ctx, err, "starting metrics server failed")
|
||||
if errCh != nil {
|
||||
errCh <- err
|
||||
// if in hardfail mode, never retry again
|
||||
@@ -520,7 +519,7 @@ func serveMetrics(ctx context.Context, bindAddress string, proxyMode kubeproxyco
|
||||
}
|
||||
|
||||
}
|
||||
go wait.Until(fn, 5*time.Second, wait.NeverStop)
|
||||
go wait.UntilWithContext(ctx, fn, 5*time.Second)
|
||||
}
|
||||
|
||||
// Run runs the specified ProxyServer. This should never exit (unless CleanupAndExit is set).
|
||||
|
||||
Reference in New Issue
Block a user