Skip to content

fix(applicationset): roll out the controller when tokenRef strict mode changes - #1561

Open
Gabrielandre02 wants to merge 2 commits into
redhat-developer:masterfrom
Gabrielandre02:appset-tokenref-strict-mode-rollout
Open

Gabrielandre02 wants to merge 2 commits into
redhat-developer:masterfrom
Gabrielandre02:appset-tokenref-strict-mode-rollout

Conversation

@Gabrielandre02

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #1554.

The ApplicationSet controller read tokenRef strict mode through a configMapKeyRef to argocd-cmd-params-cm. It only reads that variable when it starts, and the Deployment didn't change when the ConfigMap did, so a new value was ignored until something else restarted the Pod. The case I care most about is the one in the issue: after a temporary opt-out is removed, the CR and the ConfigMap say strict mode is on while the controller keeps reading unlabeled Secrets.

With this PR the value is set on the container, from the same function that fills the ConfigMap (getTokenRefStrictModeValue). When the value changes, the Deployment changes and the controller is rolled out.

PR acceptance criteria:

  • Documentation was updated and verified using make serve-docs
  • Unit tests were updated
  • E2E tests were updated

What type of PR is this?

/kind bug

Special notes to the reviewer:

I kept the key in argocd-cmd-params-cm, so the ConfigMap still shows the effective value, but nothing in the operator reads it from there anymore.

I went with a literal value instead of a checksum annotation of the ConfigMap on the Pod template because it's the smaller change, and it only restarts the controller when this value changes. If you'd rather have a generic mechanism for argocd-cmd-params-cm, I can rework it.

Two things I noticed and left out of this PR:

  • A namespace created later that matches a pattern in .spec.applicationSet.sourceNamespaces only flips the default on the next reconcile of the instance. The namespace mapper looks at .spec.sourceNamespaces only. That was already the case for the ConfigMap.
  • Existing instances get one rollout of the ApplicationSet controller on upgrade, because the env var changes from valueFrom to value.

How I tested it:

  • I repeated the steps from the issue on kind, with an ApplicationSet whose Pull Request generator reads an unlabeled Secret:

    Step master this PR
    default with sourceNamespaces refused refused
    opt-out, 60s later, no manual restart refused read
    opt-out removed, 60s later, no manual restart read refused
    three minutes later read refused
  • The new spec in 1-037 passes with the operator image built from this branch and fails with one built from master. I ran it on kind with NON_OLM=true, not on OpenShift.

  • make test, make lint and make gosec pass.

@openshift-ci openshift-ci Bot added the kind/bug Something isn't working label Nov 13, 2026
@openshift-ci
openshift-ci Bot requested a review from jannfis November 13, 2026 22:47
@openshift-ci

openshift-ci Bot commented Nov 13, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign trdoyle81 for approval. For more information see the Code Review Process.

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

@openshift-ci
openshift-ci Bot requested a review from olivergondza November 13, 2026 22:47
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • New Features
    • ApplicationSet token-reference strict mode defaults to enabled when source namespaces are configured and disabled when none are configured. An explicit setting takes precedence over this default.
    • The ApplicationSet controller restarts when the strict-mode value changes, including when an explicit setting is removed, so the updated behavior takes effect.
  • Documentation
    • Updated guidance to describe the default behavior and controller restarts when strict mode changes.

The operator derives ApplicationSet tokenRef strict mode from source namespaces and any explicit spec.cmdParams value. It sets the resolved value on the controller Deployment. Unit tests, an end-to-end test, and documentation cover the setting and its updates.

Changes: ApplicationSet tokenRef strict mode

Layer / File(s) Summary
Resolve the effective strict-mode value
argocd-operator/controllers/argocd/configmap.go, argocd-operator/controllers/argocd/configmap_test.go
The command-parameter ConfigMap uses a shared helper. An explicit spec.cmdParams value takes precedence. Otherwise, the value is true when source namespaces are configured and false when none are configured. Namespace-list errors are returned, and a test verifies that the existing ConfigMap value remains unchanged.
Apply and test the controller setting
argocd-operator/controllers/argocd/applicationset.go, argocd-operator/controllers/argocd/applicationset_test.go
The controller container receives the resolved value directly as an environment variable. Unit tests cover defaults, overrides, updates, and namespace-list errors.
Verify rollout and document updates
test/openshift/e2e/ginkgo/sequential/1-037_validate_applicationset_in_any_namespace_test.go, docs/usage/appsets-in-any-namespace.md
The end-to-end test checks the default value, an explicit override, and restoration of the default after clearing command parameters. The documentation states that the controller restarts when the value changes or the parameter is removed.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: nmirasch

Merge Risk: Minimal · up to ced22

The change makes ApplicationSet tokenRef strict-mode updates roll out the controller without a manual restart. Existing instances get one extra controller rollout on upgrade. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main change: the ApplicationSet controller is rolled out when tokenRef strict mode changes. The raw summary and objectives confirm the Deployment env var now uses a literal value …
Description check Passed The description explains the problem (ApplicationSet controller reads tokenRef strict mode from argocd-cmd-params-cm only at startup, and the Deployment did not change), the fix (set the value on the …
Linked Issues check Passed Issue #1554 requires that a change in the effective ApplicationSet tokenRef strict-mode value reaches the controller without a manual restart, in both directions. At the reviewed head, applicationset.…
Out of Scope Changes check Passed The whole-PR change summary lists six files, and each connects to #1554. applicationset.go sets the strict-mode env value from the shared helper. configmap.go routes the ConfigMap value through the sa…
Full details: Title check

Explanation

The title states the main change: the ApplicationSet controller is rolled out when tokenRef strict mode changes. The raw summary and objectives confirm the Deployment env var now uses a literal value from getTokenRefStrictModeValue, so a change triggers a rollout. The title uses the conventional fix(applicationset) prefix and is 78 characters, within a typical length limit.

Full details: Description check

Explanation

The description explains the problem (ApplicationSet controller reads tokenRef strict mode from argocd-cmd-params-cm only at startup, and the Deployment did not change), the fix (set the value on the container from getTokenRefStrictModeValue), and the testing done (docs, unit tests, E2E spec 1-037, kind results). It also lists known limitations. It is directly related to the changeset.

Full details: Linked Issues check

Explanation

Issue #1554 requires that a change in the effective ApplicationSet tokenRef strict-mode value reaches the controller without a manual restart, in both directions. At the reviewed head, applicationset.go sets ARGOCD_APPLICATIONSET_CONTROLLER_TOKENREF_STRICT_MODE as a literal Value from getTokenRefStrictModeValue(cr) in applicationSetContainer. It no longer uses a configMapKeyRef. The value sits in the pod template, so a change in the effective value changes the Deployment and rolls out the controller. This covers enabling the opt-out through spec.cmdParams and removing it. applicationSetContainer also returns an error when the value cannot be resolved, so reconciliation fails instead of deploying a wrong value. configmap.go uses the same helper, so the ConfigMap and the Deployment agree. The docs change and the 1-037 E2E spec cover the restart behavior. Unit test and E2E results are author-reported; this assessment did not rerun them. The diff from the merge base and the incremental diffs from previous reviewed heads could not be read because the changed blobs are missing from the checkout. This verdict relies on the head file content and the whole-PR summary.

Full details: Out of Scope Changes check

Explanation

The whole-PR change summary lists six files, and each connects to #1554. applicationset.go sets the strict-mode env value from the shared helper. configmap.go routes the ConfigMap value through the same helper and adds an error path for namespace listing. applicationset_test.go updates expectations and adds coverage for the derived value, the explicit override, and rollout on change. configmap_test.go covers the namespace-list error path. docs/usage/appsets-in-any-namespace.md documents the restart behavior. The 1-037 E2E test verifies the rollout. The two limitations the author lists are known effects, not added changes. The head file content shows no unrelated change. The incremental diffs and whole-PR diff could not be read, so this verdict relies on the summary and the head file content.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 1ea80e8 and ced22f1.

Files selected for processing: 2

  • argocd-operator/controllers/argocd/applicationset_test.go
  • argocd-operator/controllers/argocd/configmap_test.go
Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@openshift-ci

openshift-ci Bot commented Nov 13, 2026

Copy link
Copy Markdown

Hi @Gabrielandre02. Thanks for your PR.

I'm waiting for a redhat-developer member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@Gabrielandre02
Gabrielandre02 force-pushed the appset-tokenref-strict-mode-rollout branch from ec374ee to 75c6f2c Compare November 19, 2026 00:28
…e changes

The ApplicationSet controller read tokenRef strict mode through a
configMapKeyRef to argocd-cmd-params-cm. It only reads that variable when
it starts, and the Deployment did not change with the ConfigMap, so a new
value was ignored until something else restarted the Pod.

Set the value on the container, from the same function that fills the
ConfigMap.

Signed-off-by: gabriel.carmo <admin@gabrielandre.com.br>
@Gabrielandre02
Gabrielandre02 force-pushed the appset-tokenref-strict-mode-rollout branch from 75c6f2c to 1ea80e8 Compare November 27, 2026 00:54
@codecov

codecov Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.25000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.02%. Comparing base (54e789e) to head (ced22f1).
⚠️ Report is 9 commits behind head on master.

Files with missing lines Patch % Lines
...gocd-operator/controllers/argocd/applicationset.go 25.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1561      +/-   ##
==========================================
- Coverage   70.82%   69.02%   -1.81%     
==========================================
  Files          25      119      +94     
  Lines        3873    25379   +21506     
==========================================
+ Hits         2743    17517   +14774     
- Misses       1130     7862    +6732     
Flag Coverage Δ
unit-tests 69.02% <81.25%> (-1.81%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…nRef strict mode default cannot be listed

Signed-off-by: gabriel.carmo <admin@gabrielandre.com.br>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working needs-ok-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ApplicationSet tokenRef strict mode changes only apply after the controller is restarted

1 participant