3scale/3scale-operator

The operator doesn't process the API capability CR

Closed this issue · 9 comments

b1zzu commented

I have the 3scale-operator installed on OpenShift and I would like to create a new API using the API capabilities.3scale.net/v1alpha1 CRD, but after creating the CR nothing happen, the 3scale-operator doesn't report any error or logs related to it, the CR isn't updated with the Status, and I can't see it if I open the 3scale console

CR

apiVersion: capabilities.3scale.net/v1alpha1
kind: API
metadata:
  creationTimestamp: '2020-05-22T10:01:53Z'
  generation: 1
  labels:
    environment: testing
  name: example-api
  namespace: redhat-rhmi-3scale
  resourceVersion: '69884'
  selfLink: >-
    /apis/capabilities.3scale.net/v1alpha1/namespaces/redhat-rhmi-3scale/apis/example-api
  uid: 43e992c3-df76-4f43-b381-14a95406f91b
spec:
  description: api01
  integrationMethod:
    apicastHosted:
      apiTestGetRequest: /
      authenticationSettings:
        credentials:
          apiKey:
            authParameterName: user-key
            credentialsLocation: headers
        errors:
          authenticationFailed:
            contentType: text/plain; charset=us-ascii
            responseBody: Authentication failed
            responseCode: 403
          authenticationMissing:
            contentType: text/plain; charset=us-ascii
            responseBody: Authentication Missing
            responseCode: 403
        hostHeader: ''
        secretToken: MySecretTokenBetweenApicastAndMyBackend_1237120312
      mappingRulesSelector:
        matchLabels:
          api: api01
      privateBaseURL: 'https://echo-api.3scale.net:443'

Version
3scale-operator: 0.5.0

Operator Logs:
3scale-operator-75b858757c-qdzgk-3scale-operator.log

Am I doing something wrong? Any idea how could I debug this problem?

Your logs makes me think you lack Binding object.

$ cat 3scale-operator-75b858757c-qdzgk-3scale-operator.log | grep controller_binding
{"level":"info","ts":1590139875.2850602,"logger":"controller_binding","msg":"Reconciling Binding","Request.Namespace":"redhat-rhmi-3scale","Request.Name":"_NonBinding"}
{"level":"info","ts":1590141713.7071269,"logger":"controller_binding","msg":"Reconciling Binding","Request.Namespace":"redhat-rhmi-3scale","Request.Name":"_NonBinding"}

Operator capabilities doc

Binding CRD reference

b1zzu commented

Thanks for the tip @eguzki

But is it possible to create a Binding without creating a Tenant, the reason why I'm asking it si that the Binding require the credentialsRef which are generated when creating a Tenant, but I would just like to use my default one

b1zzu commented

I managed to create the Binding but I crashed the operator:

{"level":"info","ts":1590154235.4606383,"logger":"controller_binding","msg":"Reconciling Binding","Request.Namespace":"redhat-rhmi-3scale","Request.Name":"_NonBinding"}
2020/05/22 13:30:35 API is missing from 3scale: example-api
E0522 13:30:35.504501       1 runtime.go:69] Observed a panic: "invalid memory address or nil pointer dereference" (runtime error: invalid memory address or nil pointer dereference)
/tmp/go/src/github.com/3scale/3scale-operator/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:76
/tmp/go/src/github.com/3scale/3scale-operator/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:65
/tmp/go/src/github.com/3scale/3scale-operator/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:51
/opt/rh/go-toolset-1.12/root/usr/lib/go-toolset-1.12-golang/src/runtime/panic.go:522
/opt/rh/go-toolset-1.12/root/usr/lib/go-toolset-1.12-golang/src/runtime/panic.go:82
/opt/rh/go-toolset-1.12/root/usr/lib/go-toolset-1.12-golang/src/runtime/signal_unix.go:390
/tmp/go/src/github.com/3scale/3scale-operator/pkg/apis/capabilities/v1alpha1/api_types.go:295
/tmp/go/src/github.com/3scale/3scale-operator/pkg/apis/capabilities/v1alpha1/binding_types.go:284
/tmp/go/src/github.com/3scale/3scale-operator/pkg/controller/binding/binding_controller.go:192
/tmp/go/src/github.com/3scale/3scale-operator/pkg/controller/binding/binding_controller.go:112
/tmp/go/src/github.com/3scale/3scale-operator/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:215
/tmp/go/src/github.com/3scale/3scale-operator/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:158
/tmp/go/src/github.com/3scale/3scale-operator/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:133
/tmp/go/src/github.com/3scale/3scale-operator/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:134
/tmp/go/src/github.com/3scale/3scale-operator/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:88
/opt/rh/go-toolset-1.12/root/usr/lib/go-toolset-1.12-golang/src/runtime/asm_amd64.s:1337
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x11f7ffe]

goroutine 669 [running]:
github.com/3scale/3scale-operator/vendor/k8s.io/apimachinery/pkg/util/runtime.HandleCrash(0x0, 0x0, 0x0)
	/tmp/go/src/github.com/3scale/3scale-operator/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:58 +0x105
panic(0x15ce600, 0x28d4590)
	/opt/rh/go-toolset-1.12/root/usr/lib/go-toolset-1.12-golang/src/runtime/panic.go:522 +0x1b5
github.com/3scale/3scale-operator/pkg/apis/capabilities/v1alpha1.API.GetInternalAPI(0x0, 0x0, 0x0, 0x0, 0xc000840e50, 0xb, 0x0, 0x0, 0xc000e568e0, 0x12, ...)
	/tmp/go/src/github.com/3scale/3scale-operator/pkg/apis/capabilities/v1alpha1/api_types.go:295 +0xce
github.com/3scale/3scale-operator/pkg/apis/capabilities/v1alpha1.Binding.NewDesiredState(0x0, 0x0, 0x0, 0x0, 0xc0006ff120, 0xf, 0x0, 0x0, 0xc0008152a0, 0x12, ...)
	/tmp/go/src/github.com/3scale/3scale-operator/pkg/apis/capabilities/v1alpha1/binding_types.go:284 +0x2b9
github.com/3scale/3scale-operator/pkg/controller/binding.ReconcileBindingFunc(0x0, 0x0, 0x0, 0x0, 0xc0006ff120, 0xf, 0x0, 0x0, 0xc0008152a0, 0x12, ...)
	/tmp/go/src/github.com/3scale/3scale-operator/pkg/controller/binding/binding_controller.go:192 +0x69c
github.com/3scale/3scale-operator/pkg/controller/binding.(*ReconcileBinding).Reconcile(0xc0004b98a0, 0xc000e568e0, 0x12, 0x17b2e1a, 0xb, 0x28ef360, 0xdf8475800, 0x0, 0x0)
	/tmp/go/src/github.com/3scale/3scale-operator/pkg/controller/binding/binding_controller.go:112 +0x67a
github.com/3scale/3scale-operator/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem(0xc0005fab40, 0x0)
	/tmp/go/src/github.com/3scale/3scale-operator/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:215 +0x1cc
github.com/3scale/3scale-operator/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func1()
	/tmp/go/src/github.com/3scale/3scale-operator/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:158 +0x36
github.com/3scale/3scale-operator/vendor/k8s.io/apimachinery/pkg/util/wait.JitterUntil.func1(0xc000b94080)
	/tmp/go/src/github.com/3scale/3scale-operator/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:133 +0x54
github.com/3scale/3scale-operator/vendor/k8s.io/apimachinery/pkg/util/wait.JitterUntil(0xc000b94080, 0x3b9aca00, 0x0, 0x1, 0xc00083ca20)
	/tmp/go/src/github.com/3scale/3scale-operator/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:134 +0xf8
github.com/3scale/3scale-operator/vendor/k8s.io/apimachinery/pkg/util/wait.Until(0xc000b94080, 0x3b9aca00, 0xc00083ca20)
	/tmp/go/src/github.com/3scale/3scale-operator/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:88 +0x4d
created by github.com/3scale/3scale-operator/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start
	/tmp/go/src/github.com/3scale/3scale-operator/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:157 +0x311
b1zzu commented

It was failing here

metrics, err := getMetrics(api.Namespace, api.Spec.MetricSelector.MatchLabels, c)
because I didn't set the metricSelector

  metricSelector:
    matchLabels:
      api: api01
b1zzu commented

Same at line 301 for the planSelector:

plans, err := getPlans(api.Namespace, api.Spec.PlanSelector.MatchLabels, c)

Thanks for spotting this.

The api.capabilities.3scale.net/v1alpha1 CRD is going to be deprecated and some code will be reused. I will make sure these pitfalls are not propagated.

Stay tuned for coming new CRD's to configure your 3scale service using k8s custom resources.

b1zzu commented

Thanks @eguzki, can I ask what's the plan for the new CRDs, and when (more or less) should they be released?

WIP #357

Expected to be available on 2.9

closing as this issue is related to deprecated APIs in tech preview.