Skip to content

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

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

Gabrielandre02 wants to merge 1 commit 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
Derive the effective strict-mode value
argocd-operator/controllers/argocd/configmap.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.
Apply and validate the controller setting
argocd-operator/controllers/argocd/applicationset.go, argocd-operator/controllers/argocd/applicationset_test.go, test/openshift/e2e/ginkgo/sequential/1-037_validate_applicationset_in_any_namespace_test.go, docs/usage/appsets-in-any-namespace.md
The controller container receives the resolved value directly as an environment variable. Unit and end-to-end tests cover defaults, overrides, and updates. 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 · previous review 75c6f

This change makes the ApplicationSet controller pick up tokenRef strict-mode changes through a rollout instead of requiring a manual restart. No merge-blocking risk was found. Existing instances get one controller rollout on upgrade, which the PR notes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the primary change: the ApplicationSet controller Deployment is rolled out when the tokenRef strict mode value changes. The changeset sets the env var from getTokenRefStrictModeValue,…
Description check Passed The description explains the bug (tokenRef strict mode read from argocd-cmd-params-cm only at startup, Deployment unchanged on ConfigMap change), the fix (env var set on the container via getTokenRefS…
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. The reviewed head of argocd-operator/…
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 primary change: the ApplicationSet controller Deployment is rolled out when the tokenRef strict mode value changes. The changeset sets the env var from getTokenRefStrictModeValue, so a value change updates the Deployment. The title is concise and specific.

Full details: Description check

Explanation

The description explains the bug (tokenRef strict mode read from argocd-cmd-params-cm only at startup, Deployment unchanged on ConfigMap change), the fix (env var set on the container via getTokenRefStrictModeValue), docs, unit and E2E tests, and testing on kind. It matches the changeset and the linked issue.

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. The reviewed head of argocd-operator/controllers/argocd/applicationset.go sets ARGOCD_APPLICATIONSET_CONTROLLER_TOKENREF_STRICT_MODE as a literal Value from getTokenRefStrictModeValue(cr) in applicationSetContainer. It no longer uses a configMapKeyRef. Because the value sits in the pod template, a change in the effective value changes the Deployment and rolls out the controller. This covers the opt-out through spec.cmdParams and its removal. The change in 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 and rollout, as the issue asks. The unit test and E2E results are author-reported; this assessment did not rerun them. The incremental diff from the previous reviewed head could not be read, so 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. applicationset_test.go updates expectations and adds coverage for the derived value, the override, and rollout on change. docs/usage/appsets-in-any-namespace.md documents the restart behavior. 1-037 E2E test verifies the rollout. The two items the author lists as left out are known effects, not added changes. The incremental diff from the previous reviewed head could not be read, so unrelated changes in that increment are not directly excluded; the head file and the whole-PR summary show no unrelated change.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ec374ee and 75c6f2c.

Files selected for processing: 2

  • argocd-operator/controllers/argocd/applicationset.go
  • argocd-operator/controllers/argocd/applicationset_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; 0 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 82.35294% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.76%. Comparing base (54e789e) to head (1ea80e8).

Files with missing lines Patch % Lines
argocd-operator/controllers/argocd/configmap.go 83.33% 2 Missing ⚠️
...gocd-operator/controllers/argocd/applicationset.go 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1561      +/-   ##
==========================================
- Coverage   70.82%   68.76%   -2.07%     
==========================================
  Files          25      118      +93     
  Lines        3873    25318   +21445     
==========================================
+ Hits         2743    17409   +14666     
- Misses       1130     7909    +6779     
Flag Coverage Δ
unit-tests 68.76% <82.35%> (-2.07%) ⬇️

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.

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