Skip to content

ReconciliationDispatcher.handleExecution fails with io.fabric8.kubernetes.client.KubernetesClientException: namespace cannot be null for non-namespaced CRDs #1546

Closed
@eduardocorral

Description

@eduardocorral

Bug Report

What did you do?

Create a non-namespaced CRD with

public class MyCRD extends CustomResource<MySpec, MyStatus> {

Scope should be cluster

What did you expect to see?

No errors when applying a manifest like

apiVersion: "mycorp.com/v1"
kind: MyCRD
metadata:
  # note no namespace
  name: crdname

What did you see instead? Under which circumstances?

[2022-10-16 03:28:38.536][ERROR][io.javaoperatorsdk.operator.processing.event.ReconciliationDispatcher.handleExecution(ReconciliationDispatcher.java:56)] Error during event processing ExecutionScope{ resource id: ResourceID{name='mycrd', namespace='null'}, version: 10785} failed.
io.fabric8.kubernetes.client.KubernetesClientException: namespace cannot be null
	at io.fabric8.kubernetes.client.dsl.internal.BaseOperation.inNamespace(BaseOperation.java:235) ~[kubernetes-client-6.1.1.jar:?]
	at io.fabric8.kubernetes.client.dsl.internal.BaseOperation.inNamespace(BaseOperation.java:88) ~[kubernetes-client-6.1.1.jar:?]
	at io.javaoperatorsdk.operator.processing.event.ReconciliationDispatcher$CustomResourceFacade.updateResource(ReconciliationDispatcher.java:367) ~[operator-framework-core-4.0.1.jar:?]
	at io.javaoperatorsdk.operator.processing.event.ReconciliationDispatcher.updateCustomResourceWithFinalizer(ReconciliationDispatcher.java:303) ~[operator-framework-core-4.0.1.jar:?]
	at io.javaoperatorsdk.operator.processing.event.ReconciliationDispatcher.handleReconcile(ReconciliationDispatcher.java:106) ~[operator-framework-core-4.0.1.jar:?]
	at io.javaoperatorsdk.operator.processing.event.ReconciliationDispatcher.handleDispatch(ReconciliationDispatcher.java:81) ~[operator-framework-core-4.0.1.jar:?]
	at io.javaoperatorsdk.operator.processing.event.ReconciliationDispatcher.handleExecution(ReconciliationDispatcher.java:54) ~[operator-framework-core-4.0.1.jar:?]
	at io.javaoperatorsdk.operator.processing.event.EventProcessor$ReconcilerExecutor.run(EventProcessor.java:405) ~[operator-framework-core-4.0.1.jar:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[?:?]
	at java.lang.Thread.run(Thread.java:829) ~[?:?]

Environment

Kubernetes cluster type:

$ kind version
kind v0.16.0 go1.19.1 linux/amd64

$ Mention java-operator-sdk version from pom.xml file

dependency "io.javaoperatorsdk:operator-framework:4.0.1"

$ java -version

Using

gcr.io/distroless/java-debian11:11-nonroot

as base image.

$ kubectl version

$ kubectl version --short
Flag --short has been deprecated, and will be removed in the future. The --short output will become the default.
Client Version: v1.25.2
Kustomize Version: v4.5.7
Server Version: v1.25.2

Possible Solution

ReconciliationDispatcher.CustomResourceFacade should not use inNamespace if CRD doesn't implement Namespaced.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions