diff --git a/pkg/cmd/start/main.go b/pkg/cmd/start/main.go index bb9a4ca23..ccd5d84d2 100644 --- a/pkg/cmd/start/main.go +++ b/pkg/cmd/start/main.go @@ -182,11 +182,13 @@ func start(cmd *cobra.Command, args []string) { } // Create Service object to expose the metrics port. - var operatorService *corev1.Service - if operatorService, err = metrics.ExposeMetricsPort(ctx, viper.GetInt32("metrics-port")); err != nil { - log.Fatal(err) - } else if err = setOwnerReference(operatorService); err != nil { + operatorService, err := metrics.ExposeMetricsPort(ctx, viper.GetInt32("metrics-port")) + if err != nil { log.Fatal(err) + } else if operatorService != nil { + if err := setOwnerReference(operatorService); err != nil { + log.Fatal(err) + } } // Start the Cmd