Skip to content

CRUDKubernetesDependentResource should update dependent resource on API version update #2644

Open
@thomasdraebing

Description

@thomasdraebing

Bug Report

What did you do?

Our operator manages multiple levels of CustomResources, i.e. CR1 will lead to creation/update of CR2 (and other resources) where both CRs are managed by different reconcilers in the same operator. CRD2's API is very stable and once configured values in CR2 rarely change. This is not the case in CR1 though. Both CRs belong to the same API group and thus have the same version, i.e. if the API in CR1 is updated, the version of both CRDs is updated.
We performed such an API version update and updated the CRDs and CR1s in our cluster.

What did you expect to see?

CR2's API version should have been updated.

What did you see instead? Under which circumstances?

While requesting CR2 from the K8s API server returns CR2 with the updated version, the resource stored in ETCD still contains the old API version. This leads to issues after multiple updates, if at one point older versions are being removed from the CRD spec. In our case, the API is still quite unstable and version updates happen frequently.

Environment

Kubernetes cluster type:

Gardener

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

4.8.3

$ java -version

From pom.xml (the image used to run the operator):

<image>gcr.io/distroless/java17-debian12</ima

$ kubectl version

Client Version: v1.31.3
Kustomize Version: v5.4.2
Server Version: v1.29.10

Possible Solution

The issue here is that the API version is not taken into account when comparing the currently applied and the wanted state in KubernetesDependentResource.match(). However, since the Reconciler in this case specifically wants to create the dependent resource with the new version, even if the spec didn't change, I believe the API version should be considered in this case.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions