Skip to content

chore: Simplify reconcile change detection#2078

Open
olivergondza wants to merge 1 commit intoargoproj-labs:masterfrom
olivergondza:simplify-detection
Open

chore: Simplify reconcile change detection#2078
olivergondza wants to merge 1 commit intoargoproj-labs:masterfrom
olivergondza:simplify-detection

Conversation

@olivergondza
Copy link
Collaborator

@olivergondza olivergondza commented Feb 17, 2026

What type of PR is this?

/kind chore

For manifest change detection, this replaces boolean and string reason accumulation with a slice of causes. The change is then detected by existence or 1+ causes.

What does this PR do / why we need it:

  • -480L
  • The imple and apis are now cleaner

Have you updated the necessary documentation?

  • [no] Documentation update is required by this PR.
  • [no] Documentation has been updated.

Which issue(s) this PR fixes:

Fixes #?

How to test changes / Special notes to the reviewer:

Tests are passing

Summary by CodeRabbit

  • Refactor

    • Restructured change detection and logging across deployment controllers to consolidate update tracking, replacing scattered boolean flags with centralized change accumulation for improved logging consistency and code maintainability.
  • Tests

    • Updated deployment reconciliation tests to align with the refactored change tracking mechanism.

Signed-off-by: Oliver Gondža <ogondza@gmail.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 17, 2026

📝 Walkthrough

Walkthrough

This is a systematic refactoring across multiple Argo CD controller files that standardizes change tracking and logging. The changes replace boolean flags and concatenated explanation strings with slices of descriptive strings, which are then logged as comma-separated lists when updates occur. This affects how updates are reported without changing the functional behavior of the reconciliation logic.

Changes

Cohort / File(s) Summary
ConfigMap reconciliation
controllers/argocd/configmap.go
Replaced boolean changed flag and concatenated explanation string with a changes []string slice. Added strings import for joining change descriptions when logging single aggregated update messages.
Deployment reconciliation
controllers/argocd/deployment.go, controllers/argocd/deployment_test.go
Refactored updateNodePlacement function signature to return []string instead of accepting pointer parameters; updated all callers to accumulate returned changes. Consolidated per-field logging into a single joined message when changes are non-empty.
Dex controller
controllers/argocd/dex.go
Replaced boolean tracking with changes []string slice. Accumulates change descriptors for deployment fields (container image, env, resources, etc.) and logs joined changes when updates occur.
Ingress reconciliation
controllers/argocd/ingress.go
Added strings import. Replaced boolean/explanation tracking with changes []string for ingress class name, annotations, rules, and TLS. Logs updates using strings.Join(changes, ", ").
Repository Server and Role controllers
controllers/argocd/repo_server.go, controllers/argocd/role.go
Repo server: replaced boolean tracking with changes []string for container/pod-level updates. Role: updated matchAggregatedClusterRoleFields and matchDefaultClusterRoleFields to return []string instead of (bool, string). Both added strings import for consolidated logging.
Secret and Service reconciliation
controllers/argocd/secret.go, controllers/argocd/service.go
Replaced boolean/explanation tracking with changes []string. Consolidates password, TLS, and Dex secret updates (secret.go) or auto-TLS and service type changes (service.go) into single logged messages.
StatefulSet reconciliation
controllers/argocd/statefulset.go, controllers/argocd/statefulset_test.go
Refactored updateNodePlacementStateful signature to return []string instead of accepting pointer parameters. Updated multiple reconciliation paths (Redis, Application Controller) to accumulate changes and log via strings.Join.
Utility functions
controllers/argocd/util.go
Replaced deployment change tracking via deploymentChanged and explanation variables with a changes []string slice. Centralized update condition check to len(changes) > 0 for consolidated logging.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • jgwest
  • svghadi
  • nmirasch

Poem

🐰 Hops through the code with strings so bright,
No more booleans—changes unified in sight!
Slices aggregate what once scattered lay,
Cleaner logs join the reconciliation way! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.46% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'chore: Simplify reconcile change detection' accurately reflects the main refactoring objective across all modified files—replacing ad-hoc boolean/explanation change tracking with consolidated changes slices.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@controllers/argocd/statefulset.go`:
- Around line 454-456: The code updates the wrong container index when syncing
image pull policy: when comparing
existing.Spec.Template.Spec.Containers[i].ImagePullPolicy to
ss.Spec.Template.Spec.Containers[i].ImagePullPolicy it mistakenly assigns to
existing.Spec.Template.Spec.Containers[0].ImagePullPolicy; change the assignment
to use index i (existing.Spec.Template.Spec.Containers[i].ImagePullPolicy =
ss.Spec.Template.Spec.Containers[i].ImagePullPolicy) so the specific mismatched
container is corrected and keep the existing changes append("image pull policy")
logic as-is.

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 this pull request may close these issues.

1 participant