1
0
mirror of https://github.com/kubernetes-sigs/descheduler.git synced 2026-01-26 05:14:13 +01:00

fix panic

Signed-off-by: dongjiang <dongjiang1989@126.com>
This commit is contained in:
dongjiang
2025-03-12 18:04:33 +08:00
parent d883c8a9e1
commit 581d997379
2 changed files with 16 additions and 8 deletions

View File

@@ -142,8 +142,10 @@ func (rs *DeschedulerServer) Apply() error {
return err
}
secureServing.DisableHTTP2 = !rs.EnableHTTP2
rs.SecureServingInfo = secureServing
if secureServing != nil {
secureServing.DisableHTTP2 = !rs.EnableHTTP2
rs.SecureServingInfo = secureServing
}
return nil
}

View File

@@ -97,10 +97,14 @@ func Run(rootCtx context.Context, rs *options.DeschedulerServer) error {
healthz.InstallHandler(pathRecorderMux, healthz.NamedCheck("Descheduler", healthz.PingHealthz.Check))
stoppedCh, _, err := rs.SecureServingInfo.Serve(pathRecorderMux, 0, ctx.Done())
if err != nil {
klog.Fatalf("failed to start secure server: %v", err)
return err
var stoppedCh <-chan struct{}
var err error
if rs.SecureServingInfo != nil {
stoppedCh, _, err = rs.SecureServingInfo.Serve(pathRecorderMux, 0, ctx.Done())
if err != nil {
klog.Fatalf("failed to start secure server: %v", err)
return err
}
}
err = tracing.NewTracerProvider(ctx, rs.Tracing.CollectorEndpoint, rs.Tracing.TransportCert, rs.Tracing.ServiceName, rs.Tracing.ServiceNamespace, rs.Tracing.SampleRate, rs.Tracing.FallbackToNoOpProviderOnError)
@@ -118,8 +122,10 @@ func Run(rootCtx context.Context, rs *options.DeschedulerServer) error {
}
done()
// wait for metrics server to close
<-stoppedCh
if stoppedCh != nil {
// wait for metrics server to close
<-stoppedCh
}
return nil
}