Uploaded image for project: 'OpenShift Logging'
  1. OpenShift Logging
  2. LOG-5006

Nil pointer exception with clusterLogging.Spec.Collection empty

    XMLWordPrintable

Details

    • False
    • None
    • False
    • NEW
    • NEW
    • Hide
      When the ClusterLogForwarder was enabled, the Cluster Logging Operator could run into a nil pointer exception when
      ClusterLogging.Spec.Collection was nil. This bug is now fixed in the Cluster Logging Operator.
      Show
      When the ClusterLogForwarder was enabled, the Cluster Logging Operator could run into a nil pointer exception when ClusterLogging.Spec.Collection was nil. This bug is now fixed in the Cluster Logging Operator.
    • Bug Fix
    • Log Collection - Sprint 249, Log Collection - Sprint 250
    • Low

    Description

      The following affects the old / legacy implementation of the forwarder. For the upstream bug, see: https://github.com/openshift/cluster-logging-operator/issues/2312

      Nil pointer exception with clusterLogging.Spec.Collection empty and Forwarder enabled.

      The following combination throws a nil pointer exception:

      ClusterLogging:

      apiVersion: "logging.openshift.io/v1"
      kind: "ClusterLogging"
      metadata:
        name: "instance" 
        namespace: openshift-logging
      spec:
        managementState: "Managed"
      

      ClusterLogForwarder:

      apiVersion: logging.openshift.io/v1
      kind: ClusterLogForwarder
      metadata:
        name: instance
        namespace: openshift-logging
      spec:
        pipelines:
         - inputRefs:
           - audit
           outputRefs:
           - loki-external
           labels:
             job: openshift-audit
             clusterid: sno10
         - inputRefs:
           - application
           outputRefs:
           - loki-external
           labels:
             job: openshift-application
             clusterid: sno10
         - inputRefs:
           - infrastructure
           outputRefs:
           - loki-external
           labels:
             job: openshift-infrastructure
             clusterid: sno10
        outputs:
        - name: loki-external
          type: loki
          url: http://192.168.18.75:310
      
      [akaris@workstation logging]$ oc apply -f configuring-cluster-logging-minimal-minimal.yaml
      clusterlogging.logging.openshift.io/instance created
      [akaris@workstation logging]$ oc apply -f configuring-log-forwarder.yaml
      clusterlogforwarder.logging.openshift.io/instance created
      [akaris@workstation logging]$ 
      
      $ LOG_LEVEL=3 make run
      (...)
      {"_ts":"2024-01-18T11:18:45.623084752Z","_file:line":"internal/reconcile/rbac.go:37","_level":"3","_component":"cluster-logging-operator","_message":"Roles are the same skipping update"}
      {"_ts":"2024-01-18T11:18:45.623126639Z","_file:line":"internal/reconcile/rbac.go:70","_level":"3","_component":"cluster-logging-operator","_message":"RoleBindings are the same skipping update"}
      {"_ts":"2024-01-18T11:18:45.623159759Z","_file:line":"internal/k8shandler/clusterloggingrequest.go:107","_level":"3","_component":"cluster-logging-operator","_message":"Getting object","namespacedName":{"Namespace":"openshift-logging","Name":"logcollector-token"},"object":{"metadata":{"creationTimestamp":null}}}
      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=0x15c31d8]
      
      goroutine 351 [running]:
      sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile.func1()
      	/home/akaris/development/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.5/pkg/internal/controller/controller.go:119 +0x1e5
      panic({0x1737be0?, 0x28a4ed0?})
      	/usr/lib/golang/src/runtime/panic.go:914 +0x21f
      github.com/openshift/cluster-logging-operator/internal/k8shandler.(*ClusterLoggingRequest).generateCollectorConfig(0xc000927058)
      	/home/akaris/development/cluster-logging-operator/internal/k8shandler/forwarding.go:48 +0x298
      github.com/openshift/cluster-logging-operator/internal/k8shandler.(*ClusterLoggingRequest).CreateOrUpdateCollection(0xc000927058)
      	/home/akaris/development/cluster-logging-operator/internal/k8shandler/collection.go:72 +0x2b2
      github.com/openshift/cluster-logging-operator/internal/k8shandler.Reconcile(0xc0008d84e0, 0xc000898a80, {0x1c12238, 0xc000290180}, {0x7fb45823e568, 0xc000292770}, {0x1c099b0, 0xc0002d8340}, {0xc0003ca158, 0x6}, ...)
      	/home/akaris/development/cluster-logging-operator/internal/k8shandler/reconciler.go:67 +0x81f
      github.com/openshift/cluster-logging-operator/controllers/forwarding.(*ReconcileForwarder).Reconcile(0xc000700420, {0x30?, 0xc000588000?}, {{{0xc00063dfb0?, 0x0?}, {0xc000331060?, 0x412205?}}})
      	/home/akaris/development/cluster-logging-operator/controllers/forwarding/forwarding_controller.go:115 +0xc35
      sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile(0x1c0ab18?, {0x1c0ab18?, 0xc000b04d50?}, {{{0xc00063dfb0?, 0x1684940?}, {0xc000331060?, 0xc000c037d0?}}})
      	/home/akaris/development/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.5/pkg/internal/controller/controller.go:122 +0xb7
      sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler(0xc000298460, {0x1c0ab50, 0xc0002a90e0}, {0x17b7fe0?, 0xc000332da0?})
      	/home/akaris/development/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.5/pkg/internal/controller/controller.go:323 +0x353
      sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem(0xc000298460, {0x1c0ab50, 0xc0002a90e0})
      	/home/akaris/development/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.5/pkg/internal/controller/controller.go:274 +0x1c9
      sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2()
      	/home/akaris/development/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.5/pkg/internal/controller/controller.go:235 +0x79
      created by sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2 in goroutine 107
      	/home/akaris/development/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.5/pkg/internal/controller/controller.go:231 +0x565
      exit status 2
      make: *** [Makefile:150: run] Error 1
      

      Directly related to this is upstream bug: https://github.com/openshift/cluster-logging-operator/issues/2314
      After a valid ClusterLogForwarder and an invalid ClusterLogging resource are created, the ClusterLogForwarder's status will show that the CLF is not available. When the ClusterLogging CR is then changed to a valid configuration, the CLF's status should reflect that everything is o.k. - but currently, code for that is missing.

      Attachments

        Activity

          People

            akaris@redhat.com Andreas Karis
            akaris@redhat.com Andreas Karis
            Anping Li Anping Li
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: