Uploaded image for project: 'Red Hat 3scale API Management'
  1. Red Hat 3scale API Management
  2. THREESCALE-11948

ApplicationCR: yet another nil pointer

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 2.15.0 GA, 2.16.0 GA
    • 3scale Operator
    • None
    • False
    • Hide

      None

      Show
      None
    • False
    • Not Started
    • Not Started
    • Not Started
    • Not Started
    • Not Started
    • Not Started

      Changing the ProductCR ref to another valid product will trigger a nil pointer exception

      2025-10-01T10:51:33+10:00       INFO    Observed a panic in reconciler: runtime error: invalid memory address or nil pointer dereference        {"controller": "application", "controllerGroup": "capabilities.3scale.net", "controllerKind": "Application", "Application": {"name":"application-cr","namespace":"3scale-test"}, "namespace": "3s
      cale-test", "name": "application-cr", "reconcileID": "ab2b930a-c93c-45a7-8548-4b9164117b4f"}
      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=0x1c3f9c6]
      
      goroutine 511 [running]:
      sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile.func1()
              /home/atra/trunk/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:116 +0x1e5
      panic({0x1f3eaa0?, 0x3813a00?})
              /usr/local/go/src/runtime/panic.go:770 +0x132
      github.com/3scale/3scale-operator/controllers/capabilities.(*ApplicationThreescaleReconciler).syncApplication(0xc00035d3b0, {0xc000775890?, 0x49e58f?})
              /home/atra/trunk/lib/3scale/3scale-operator/controllers/capabilities/applications.go:25 +0x266
      github.com/3scale/3scale-operator/pkg/helper.(*taskRunnerImpl).Run(0xc0007759e8)
              /home/atra/trunk/lib/3scale/3scale-operator/pkg/helper/task_runner.go:43 +0xcb
      github.com/3scale/3scale-operator/controllers/capabilities.(*ApplicationThreescaleReconciler).Reconcile(0xc00035d3b0)
              /home/atra/trunk/lib/3scale/3scale-operator/controllers/capabilities/application_threescale_reconciler.go:46 +0x190
      github.com/3scale/3scale-operator/controllers/capabilities.(*ApplicationReconciler).applicationReconciler(0xc0005aa358, 0xc000d00820, {{{0xc000e2c250?, 0xc00089b301?}, {0xc000e2c240?, 0xc000a8ca80?}}}, 0xc000b81620, {0xc000a83a10, 0x25}, 0xc000a9f800)
              /home/atra/trunk/lib/3scale/3scale-operator/controllers/capabilities/application_controller.go:262 +0x14e
      github.com/3scale/3scale-operator/controllers/capabilities.(*ApplicationReconciler).Reconcile(0xc0005aa358, {0x0?, 0x0?}, {{{0xc000e2c250, 0xb}, {0xc000e2c240, 0xe}}})
              /home/atra/trunk/lib/3scale/3scale-operator/controllers/capabilities/application_controller.go:167 +0x685
      sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile(0x26108a0?, {0x260b320?, 0xc000a49860?}, {{{0xc000e2c250?, 0xb?}, {0xc000e2c240?, 0x0?}}})
              /home/atra/trunk/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:119 +0xb7
      sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler(0xc000a90c80, {0x260b358, 0xc0005c0fa0}, {0x200ce00, 0xc00087a200})
              /home/atra/trunk/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:316 +0x3bc
      sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem(0xc000a90c80, {0x260b358, 0xc0005c0fa0})
              /home/atra/trunk/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:266 +0x1be
      sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2()
              /home/atra/trunk/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:227 +0x79
      created by sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2 in goroutine 191
              /home/atra/trunk/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.2/pkg/internal/controller/controller.go:223 +0x50c
      exit status 2
      make: *** [Makefile:103: run] Error 1
      

      This occurs because resource IDs are often accessed via pointers, which are not guaranteed to be available at runtime.

      Proposed solution

      Option 1: 

      Update the operator code to manage changes in both product and account references. This include detecting incoming changes, deleting the old application, and creating a new one. 

      Option 2:

      Mark both the account and product references as immutable, meaning the field cannot be changed once set.

      How to reproduce: 

      1. Create a DeveloperUserCR, a DeveloperAccountCR, 2 Products and an ApplicationCR 
      2. Wait for operator to sync all CR's, and check the assigned applicationID of application
      3. Update ApplicationCR to reference the other product
      4. Check operator log for exception

              Unassigned Unassigned
              rhn-support-atra An Tran
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: