From 6dca346161fc8c215e02fcb479efe06640b8a32e Mon Sep 17 00:00:00 2001 From: Israel Blancas Date: Fri, 16 Jun 2023 21:01:13 +0200 Subject: [PATCH] Add missing permissions Signed-off-by: Israel Blancas --- ...jaeger-operator.clusterserviceversion.yaml | 10 +++++- config/rbac/role.yaml | 8 +++++ .../jaegertracing/jaeger_controller.go | 1 + pkg/autodetect/main.go | 1 - pkg/autodetect/main_test.go | 31 +++++++++++++++++++ pkg/ingress/query.go | 2 +- 6 files changed, 50 insertions(+), 3 deletions(-) diff --git a/bundle/manifests/jaeger-operator.clusterserviceversion.yaml b/bundle/manifests/jaeger-operator.clusterserviceversion.yaml index 702f603ac..e1662f0df 100644 --- a/bundle/manifests/jaeger-operator.clusterserviceversion.yaml +++ b/bundle/manifests/jaeger-operator.clusterserviceversion.yaml @@ -19,7 +19,7 @@ metadata: categories: Logging & Tracing certified: "false" containerImage: quay.io/jaegertracing/jaeger-operator - createdAt: "2023-05-29T15:36:04Z" + createdAt: "2023-06-16T18:59:42Z" description: Provides tracing, monitoring and troubleshooting for microservices-based distributed systems operators.openshift.io/infrastructure-features: '["disconnected"]' @@ -333,6 +333,14 @@ spec: - patch - update - watch + - apiGroups: + - networking.k8s.io + resources: + - ingressclasses + verbs: + - get + - list + - watch - apiGroups: - networking.k8s.io resources: diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 41bc135c1..2422ccee8 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -219,6 +219,14 @@ rules: - patch - update - watch +- apiGroups: + - networking.k8s.io + resources: + - ingressclasses + verbs: + - get + - list + - watch - apiGroups: - networking.k8s.io resources: diff --git a/controllers/jaegertracing/jaeger_controller.go b/controllers/jaegertracing/jaeger_controller.go index 2ef1e182a..4b14d370a 100644 --- a/controllers/jaegertracing/jaeger_controller.go +++ b/controllers/jaegertracing/jaeger_controller.go @@ -50,6 +50,7 @@ func NewReconciler(client client.Client, clientReader client.Reader, scheme *run // +kubebuilder:rbac:groups=extensions,resources=ingresses,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=autoscaling,resources=horizontalpodautoscalers,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=networking.k8s.io,resources=ingresses,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=networking.k8s.io,resources=ingressclasses,verbs=get;list;watch; // +kubebuilder:rbac:groups=route.openshift.io,resources=routes,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=console.openshift.io,resources=consolelinks,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=batch,resources=jobs;cronjobs,verbs=get;list;watch;create;update;patch;delete diff --git a/pkg/autodetect/main.go b/pkg/autodetect/main.go index 7e869115e..89a0bd760 100644 --- a/pkg/autodetect/main.go +++ b/pkg/autodetect/main.go @@ -298,7 +298,6 @@ func (b *Background) detectDefaultIngressClass(ctx context.Context) { err := b.cl.List(ctx, &ingressClasses) if err != nil { log.Log.Info("It was not possible to get any IngressClasses from the Kubernetes cluster") - viper.Set(v1.FlagDefaultIngressClass, "") } oldValue := viper.GetString(v1.FlagDefaultIngressClass) diff --git a/pkg/autodetect/main_test.go b/pkg/autodetect/main_test.go index aa8f0cdca..1426738e2 100644 --- a/pkg/autodetect/main_test.go +++ b/pkg/autodetect/main_test.go @@ -631,6 +631,37 @@ func TestDetectDefaultIngressClass(t *testing.T) { assert.Equal(t, "nginx", viper.GetString(v1.FlagDefaultIngressClass)) } +func TestDetectNoDefaultIngressClass(t *testing.T) { + // prepare + viper.Set("platform", v1.FlagPlatformKubernetes) + defer viper.Reset() + + dcl := &fakeDiscoveryClient{} + cl := customFakeClient() + + cl.ListFunc = func(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error { + if listPointer, ok := list.(*networkingv1.IngressClassList); ok { + listPointer.Items = []networkingv1.IngressClass{ + { + ObjectMeta: metav1.ObjectMeta{ + Name: "nginx", + }, + }, + } + } + + return nil + } + b := WithClients(cl, dcl, cl) + + // test + b.detectDefaultIngressClass(context.Background()) + + // verify + assert.Equal(t, "", viper.GetString(v1.FlagDefaultIngressClass)) +} + + func TestCleanDeployments(t *testing.T) { for _, tt := range []struct { cap string // caption for the test diff --git a/pkg/ingress/query.go b/pkg/ingress/query.go index b1fb0c2f3..1e0d7c934 100644 --- a/pkg/ingress/query.go +++ b/pkg/ingress/query.go @@ -55,7 +55,7 @@ func (i *QueryIngress) Get() *networkingv1.Ingress { clusterDefaultIngressClass := viper.GetString(v1.FlagDefaultIngressClass) if i.jaeger.Spec.Ingress.IngressClassName != nil { spec.IngressClassName = i.jaeger.Spec.Ingress.IngressClassName - } else if clusterDefaultIngressClass != "" { + } else if clusterDefaultIngressClass != ""{ spec.IngressClassName = &clusterDefaultIngressClass }