Skip to content

Infinite resource updates when EnvVars are empty #2802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
afalhambra-hivemq opened this issue May 16, 2025 · 0 comments · Fixed by #2803
Closed

Infinite resource updates when EnvVars are empty #2802

afalhambra-hivemq opened this issue May 16, 2025 · 0 comments · Fixed by #2803

Comments

@afalhambra-hivemq
Copy link
Contributor

Bug Report

Empty K8s environment variables are stored as null by Kubernetes, so in a reconciliation loop, the SSA matcher will sending a mismatch between the desired and the actual resource.
This will lead to infinite resource being updated in each reconciliation.

What did you do?

For example, for a Deployment with a PodSpec field as below:

      containers:
        - name: nginx
          image: registry.k8s.io/nginx-slim:0.8
          ports:
            - containerPort: 80
              name: web
          env:
            - name: EMPTY_ENV_VAR
              value: ""

The following will be shown by running a kubectl command:

$ kubectl get deployments.apps nginx -o yaml

...
      containers:
        - name: nginx
          image: registry.k8s.io/nginx-slim:0.8
          ports:
            - containerPort: 80
              name: web
          env:
            - name: EMPTY_ENV_VAR
...

What did you expect to see?

No mismatch is triggered by the SSA matcher when an empty EnvVar is set.

What did you see instead? Under which circumstances?

Infinite mismatch and update in the resource.

Environment

Kubernetes cluster type:

Minikube v1.32.0

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

5.0.4

$ java -version

JDK 21

$ kubectl version

Client Version: v1.32.0
Kustomize Version: v5.5.0
Server Version: v1.32.0

Possible Solution

Improve ResourceRequirementsSanitizer class to keep this into account. Similar to what is done to the resource quantity and limits.

Additional context

Similar to #2509

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant