Skip to content

Build controller panics with nil pointer dereference on every build in 2.10.0 #6587

@Diesel93

Description

@Diesel93

Camel K version: 2.10.0 (Helm chart)

Kubernetes: EKS 1.31, eu-west-2

After upgrading from 2.8.0 to 2.10.0 the operator panics on every build. The build pod never spawns — the reconcile loop crashes and retries indefinitely.

Operator logs:

{"level":"error","msg":"Observed a panic","controller":"build-controller","Build":{"name":"kit-d7njpnevtj8s73903ip0","namespace":"camel-k"},"panic":"runtime error: invalid memory address or nil pointer dereference"}
{"level":"error","msg":"Reconciler error","error":"panic: runtime error: invalid memory address or nil pointer dereference [recovered]"}

Always the same sequence — build queues fine, then immediately panics:

INFO | Invoking action build
INFO | State transition
INFO | Build queue duration 357ms
INFO | Invoking action build
ERROR | Observed a panic

Stack trace:

github.com/apache/camel-k/v2/pkg/apis/camel/v1.(*Build).GetObjectKind
k8s.io/client-go/tools/reference.GetReference
k8s.io/client-go/tools/events.(*recorderImpl).eventf
github.com/apache/camel-k/v2/pkg/event/manager.go:210
github.com/apache/camel-k/v2/pkg/controller/build/build_controller.go:196

Root cause:

PR #6492 bumped controller-runtime to 0.23.1 and migrated from record.EventRecorder to events.EventRecorder. The new recorder calls reference.GetReference(scheme, obj) which calls obj.GetObjectKind(). Since client.Get() strips TypeMeta from returned objects (known controller-runtime behaviour — kubernetes-sigs/controller-runtime#1735), GetObjectKind() ends up dereferencing a nil pointer.

The old record.EventRecorder didn't go through GetReference so this wasn't an issue in 2.9.x.

Reproducing:

Install 2.10.0 via Helm and trigger any build. Panic happens on the first state transition event after the build queues — doesn't matter what registry or build strategy.

Works fine on 2.9.1, broken on 2.10.0.

Fix:

Populate TypeMeta on the Build object before it reaches the event recorder, e.g. in build_controller.go:

instance.TypeMeta = metav1.TypeMeta{
    Kind:       "Build",
    APIVersion: "camel.apache.org/v1",
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions