Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create metrics service only when running in k8s cluster #444

Merged
merged 2 commits into from
May 28, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions pkg/cmd/start/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,14 @@ 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 {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check was missing there. The ExposeMetricsPort returns nil, nil if the code does not run inside the k8s cluster.

err = setOwnerReference(operatorService)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor point: could be if err = setOwnerReference(operatorService); err != nil {

if err != nil {
log.Fatal(err)
}
}

// Start the Cmd
Expand Down