Skip to content

Commit d2e0652

Browse files
committed
fixing nil pointer
Signed-off-by: Chengxuan Xing <chengxuan.xing@kaleido.io>
1 parent c27698e commit d2e0652

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

internal/apiserver/server.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ 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-
var monitoringServer httpserver.HTTPServer
119118
serverName := "metrics"
120119
mConfig := deprecatedMetricsConfig
121120
if as.monitoringEnabled {
@@ -124,14 +123,14 @@ func (as *apiServer) Serve(ctx context.Context, mgr namespace.Manager) (err erro
124123
}
125124

126125
if as.deprecatedMetricsEnabled || as.monitoringEnabled {
127-
monitoringServer, err = httpserver.NewHTTPServer(ctx, serverName, as.createMonitoringMuxRouter(), metricsErrChan, mConfig, corsConfig, &httpserver.ServerOptions{
126+
monitoringServer, err := httpserver.NewHTTPServer(ctx, serverName, as.createMonitoringMuxRouter(), metricsErrChan, mConfig, corsConfig, &httpserver.ServerOptions{
128127
MaximumRequestTimeout: as.apiMaxTimeout,
129128
})
129+
if err != nil {
130+
return err
131+
}
132+
go monitoringServer.ServeHTTP(ctx)
130133
}
131-
if err != nil {
132-
return err
133-
}
134-
go monitoringServer.ServeHTTP(ctx)
135134

136135
return as.waitForServerStop(httpErrChan, spiErrChan, metricsErrChan)
137136
}

0 commit comments

Comments
 (0)