Skip to content

fix: Avoid endless Deployment updates when mounting Secrets/ConfigMaps as subpath - #2227

Merged
tolusha merged 1 commit into
mainfrom
fix-deployment-sync-issues
Oct 14, 2026
Merged

tolusha merged 1 commit into
mainfrom
fix-deployment-sync-issues

Conversation

@tolusha

@tolusha tolusha commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes a reconciliation loop where Deployments (e.g. che-dashboard) are updated over and over, creating many ReplicaSets, when a Secret or ConfigMap is mounted with controller.devfile.io/mount-as: subpath and holds more than one key.

Root cause: MountSecrets / MountConfigMaps iterated over Data (a Go map) in random order, so the generated VolumeMounts order changed between reconciles. The diff then reported a change and the operator updated the Deployment each time.

Changes in pkg/deploy/deployment.go:

  • Iterate over Data keys in sorted order when mounting as subpath, so VolumeMounts are stable (main fix).
  • env mount: use the listed object directly instead of fetching it again.
  • List Secrets/ConfigMaps only in the CheCluster namespace, using ClientWrapper and cheCtx.Context.
  • OverrideContainer: keep the existing ImagePullPolicy unless the image or the pull policy is overridden. This avoids flipping the policy on every sync.
  • OverrideContainer: create nil Requests/Limits maps before applying resource overrides, so it no longer panics on a nil map.
  • Wrap errors with context.

Screenshot/screencast of this PR

N/A

What issues does this PR fix or reference?

Fixes eclipse-che/che#23988

How to test this PR?

  1. Deploy the operator:

OpenShift

oc create namespace devworkspace-controller
oc apply --server-side -f https://raw.githubusercontent.com/devfile/devworkspace-operator/refs/heads/main/deploy/deployment/openshift/combined.yaml

OPERATOR_IMAGE=<...>
sed 's|quay.io/eclipse/che-operator:next|'${OPERATOR_IMAGE}'|g' deploy/deployment/openshift/combined.yaml | oc apply --server-side -f  -
oc wait --for=condition=Ready pod -l app.kubernetes.io/component=che-operator -n eclipse-che --timeout=60s
oc apply --server-side -f deploy/deployment/openshift/org_v2_checluster.yaml
oc wait checluster eclipse-che -n eclipse-che --for=jsonpath='.status.chePhase'=Active   --timeout=120s

on Minikube

./build/scripts/minikube-tests/test-operator-from-sources.sh
  1. Create a dashboard customization Secret with several keys mounted as subpath:
kubectl apply -f - <<YAML
apiVersion: v1
kind: Secret
metadata:
  name: che-dashboard-customization
  namespace: eclipse-che
  annotations:
    che.eclipse.org/mount-as: subpath
    che.eclipse.org/mount-path: /public/dashboard/assets/branding/
  labels:
    app.kubernetes.io/component: che-dashboard-secret
    app.kubernetes.io/part-of: che.eclipse.org
type: Opaque
stringData:
  loader.svg: "<svg/>"
  che-logo.svg: "<svg/>"
  favicon.ico: "x"
YAML
  1. Wait for the reconcile, then delete the dashboard pod a few times (kubectl delete pod -n eclipse-che -l app.kubernetes.io/component=che-dashboard).
  2. Check that only one new ReplicaSet was created (kubectl get rs -n eclipse-che -l app.kubernetes.io/component=che-dashboard), and that the operator logs show no repeated VolumeMounts diffs for che-dashboard.

Unit tests: make test (adds TestMountAsSubpathShouldSortVolumeMounts, TestOverrideContainerResourcesWhenNotSet, TestOverrideContainerImagePullPolicy).

Common Test Scenarios

  • Deploy Eclipse Che
  • Start an empty workspace
  • Open terminal and build/run an image
  • Stop a workspace
  • Check operator logs for reconciliation errors or infinite reconciliation loops

PR Checklist

As the author of this Pull Request I made sure that:

Reviewers

Reviewers, please comment how you tested the PR when approving it.

🤖 Generated with Claude Code

…s as subpath

Iterate over Secret/ConfigMap data keys in sorted order when mounting them
as subpath, so the generated VolumeMounts are stable across reconciles and
do not trigger repeated Deployment rollouts.

Also:
- keep the existing ImagePullPolicy unless the image or policy is overridden
- initialize nil resource lists before applying resource overrides
- list Secrets/ConfigMaps in the CheCluster namespace via ClientWrapper
- reuse listed objects instead of re-fetching them for env mounts

Fixes eclipse-che/che#23988

Assisted-by: Claude Opus 5.5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anatolii Bazko <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 14, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 16 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7b8118e7-5dfe-4394-a61f-561f13dd212b
📥 Commits

Reviewing files that changed from the base of the PR and between 8141b56 and e2aca3e.

📒 Files selected for processing: 2
  • pkg/deploy/deployment.go
  • pkg/deploy/deployment_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

🐳 New images available:

  • quay.io/eclipse/che-operator:pr-2227-amd64
  • quay.io/eclipse/che-operator:pr-2227-arm64
  • quay.io/eclipse/eclipse-che-olm-catalog:pr-2227-amd64
  • quay.io/eclipse/eclipse-che-olm-catalog:pr-2227-arm64

@tolusha

tolusha commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Hi! I'm che-ai-assistant — I help with your pull requests.

I check for new comments every 10m0s, so there may be a short delay before I respond.

Available commands:

  • /che-ai-assistant generate-che-doc — Generate a documentation PR based on this PR's changes
  • /che-ai-assistant ok-pr-review — Run a comprehensive PR review (summary, code review, deep review, impact analysis)
  • /che-ai-assistant ok-pr-readiness — Ensure PR has validation steps
  • /che-ai-assistant check-pr-test-failures — Analyze failing CI checks, identify root causes, and suggest fixes
  • /che-ai-assistant update-che-e2e-tests — Update Eclipse Che e2e tests
  • /che-ai-assistant claude — Run a free-form instruction on this PR
  • /che-ai-assistant help — Show this help message

@openshift-ci

openshift-ci Bot commented Oct 14, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: akurinnoy, tolusha

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tolusha
tolusha merged commit 6c84368 into main Oct 14, 2026
25 checks passed
@tolusha
tolusha deleted the fix-deployment-sync-issues branch October 14, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Che-Operator] when applying a rollout on che-dashboard with an image create multiple replica

2 participants