Skip to content

Commit 20235ed

Browse files
committed
ensure access to the sections are direct
Signed-off-by: Chengxuan Xing <[email protected]>
1 parent 88a4c15 commit 20235ed

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

internal/apiserver/server.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,18 @@ func (as *apiServer) Serve(ctx context.Context, mgr namespace.Manager) (err erro
115115
} else if config.GetBool(coreconfig.LegacyAdminEnabled) {
116116
log.L(ctx).Warnf("Your config includes an 'admin' section, which should be renamed to 'spi' - SPI server will not be enabled until this is corrected")
117117
}
118-
serverName := "metrics"
119-
mConfig := deprecatedMetricsConfig
120-
if as.monitoringEnabled {
121-
serverName = "monitoring"
122-
mConfig = monitoringConfig
123-
}
124-
125118
if as.deprecatedMetricsEnabled || as.monitoringEnabled {
126-
monitoringServer, err := httpserver.NewHTTPServer(ctx, serverName, as.createMonitoringMuxRouter(), metricsErrChan, mConfig, corsConfig, &httpserver.ServerOptions{
127-
MaximumRequestTimeout: as.apiMaxTimeout,
128-
})
119+
var monitoringServer httpserver.HTTPServer
120+
var err error
121+
if as.monitoringEnabled {
122+
monitoringServer, err = httpserver.NewHTTPServer(ctx, "monitoring", as.createMonitoringMuxRouter(), metricsErrChan, monitoringConfig, corsConfig, &httpserver.ServerOptions{
123+
MaximumRequestTimeout: as.apiMaxTimeout,
124+
})
125+
} else {
126+
monitoringServer, err = httpserver.NewHTTPServer(ctx, "metrics", as.createMonitoringMuxRouter(), metricsErrChan, deprecatedMetricsConfig, corsConfig, &httpserver.ServerOptions{
127+
MaximumRequestTimeout: as.apiMaxTimeout,
128+
})
129+
}
129130
if err != nil {
130131
return err
131132
}

0 commit comments

Comments
 (0)