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

Removed 'expose metrics port' to prevent 'failed to create or get service' error #462

Merged
Merged
Changes from all commits
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
52 changes: 1 addition & 51 deletions pkg/cmd/start/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,18 @@ import (

"github.com/operator-framework/operator-sdk/pkg/k8sutil"
"github.com/operator-framework/operator-sdk/pkg/leader"
"github.com/operator-framework/operator-sdk/pkg/metrics"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/discovery"
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/runtime/signals"

"github.com/jaegertracing/jaeger-operator/pkg/apis"
"github.com/jaegertracing/jaeger-operator/pkg/apis/jaegertracing/v1"
v1 "github.com/jaegertracing/jaeger-operator/pkg/apis/jaegertracing/v1"
"github.com/jaegertracing/jaeger-operator/pkg/controller"
"github.com/jaegertracing/jaeger-operator/pkg/version"
)
Expand Down Expand Up @@ -178,16 +173,6 @@ func start(cmd *cobra.Command, args []string) {
log.Fatal(err)
}

// Create Service object to expose the metrics port.
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
log.Fatal(mgr.Start(signals.SetupSignalHandler()))
}
Expand Down Expand Up @@ -225,38 +210,3 @@ func isElasticsearchOperatorAvailable(apiList *metav1.APIGroupList) bool {
}
return false
}

func setOwnerReference(operatorService *corev1.Service) error {
config, err := rest.InClusterConfig()
if err != nil {
return err
}

client, err := client.New(config, client.Options{})
if err != nil {
return err
}

deployment := &appsv1.Deployment{}
err = client.Get(context.Background(), types.NamespacedName{
Name: operatorService.Name,
Namespace: operatorService.Namespace,
}, deployment)
if err != nil {
return err
}

flag := true
operatorService.OwnerReferences = []metav1.OwnerReference{
metav1.OwnerReference{
APIVersion: "apps/v1",
Kind: "Deployment",
Name: deployment.Name,
UID: deployment.UID,
Controller: &flag,
},
}

// Update the service object with the owner reference
return client.Update(context.Background(), operatorService)
}