Skip to content

Feat: disable GitOps Service and default instance on xKS clusters#1172

Open
anandrkskd wants to merge 6 commits into
redhat-developer:masterfrom
anandrkskd:disable-default-instance-on-xks
Open

Feat: disable GitOps Service and default instance on xKS clusters#1172
anandrkskd wants to merge 6 commits into
redhat-developer:masterfrom
anandrkskd:disable-default-instance-on-xks

Conversation

@anandrkskd

@anandrkskd anandrkskd commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?
/kind enhancement

What does this PR do / why we need it:

The OpenShift GitOps Operator assumes an OpenShift cluster today: it registers the GitopsService controller, auto-creates a default Argo CD instance in openshift-gitops, and configures Dex/SSO against OpenShift authentication.
On xKS (non-OpenShift Kubernetes) clusters, those behaviors are not required and can cause failures.

This PR detects non-OpenShift clusters at startup by checking whether the config.openshift.io API is present (via existing InspectCluster() discovery). When it is not found, the operator:

  1. Skips ReconcileGitopsService controller registration — this controller manages OpenShift-specific resources (default Argo CD instance, console plugin backend, RBAC, namespace setup, and related reconciliation) that do not apply on xKS.
  2. Prevents default Argo CD instance provisioning — no openshift-gitops Argo CD CR is created on xKS.
  3. Skips SSO/Dex in the default Argo CD CR templategetArgoSSOSpec() returns nil on non-OpenShift clusters, so Dex is not configured when NewCR() is used.
    On OpenShift clusters, behavior is unchanged. The existing DISABLE_DEFAULT_ARGOCD_INSTANCE environment variable continues to work as before.

Have you updated the necessary documentation?

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

Which issue(s) this PR fixes:

Fixes https://redhat.atlassian.net/browse/GITOPS-9943

Test acceptance criteria:

  • Unit Test
  • E2E Test

How to test changes / Special notes to the reviewer:

On xKS (vanilla Kubernetes or cluster without config.openshift.io):

  1. Install the operator.
  2. Confirm operator logs contain: Non-OpenShift cluster detected, skipping GitopsService controller setup
  3. Confirm no Argo CD CR named openshift-gitops is created in openshift-gitops.
  4. Confirm the GitopsService controller is not running (no reconciliation of console plugin backend resources).

On OpenShift:

  1. Install the operator without DISABLE_DEFAULT_ARGOCD_INSTANCE.
  2. Confirm default Argo CD instance is still created in openshift-gitops.
  3. Confirm GitopsService controller runs and console plugin resources are reconciled as before.

@openshift-ci openshift-ci Bot added the kind/enhancement New feature or request label Jun 9, 2026
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: ecfe18ca-fca1-4c8d-bf0e-e8d96150d7bd

📥 Commits

Reviewing files that changed from the base of the PR and between aecf34c and c749948.

📒 Files selected for processing (4)
  • cmd/main.go
  • controllers/argocd/argocd.go
  • controllers/argocd/argocd_test.go
  • controllers/util/util.go
🔗 Linked repositories identified

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

  • argoproj-labs/argocd-operator (manual)
🚧 Files skipped from review as they are similar to previous changes (4)
  • cmd/main.go
  • controllers/argocd/argocd.go
  • controllers/util/util.go
  • controllers/argocd/argocd_test.go

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of non-OpenShift cluster environments by conditionally disabling GitOps controller registration and skipping SSO/Dex configuration when the OpenShift API is unavailable.
    • Enhanced external authentication detection to avoid Dex/SSO setup when external authentication is enabled.
  • Tests
    • Added coverage to verify SSO is not configured on non-OpenShift clusters.

Walkthrough

Adds an exported OpenShift detection helper and uses it to: (1) skip registering the ReconcileGitopsService controller on non-OpenShift clusters, and (2) skip ArgoCD SSO/Dex configuration when the cluster is not OpenShift or external auth is enabled. Tests updated to assert both paths.

Changes

OpenShift gating and controller/SSO behavior

Layer / File(s) Summary
Cluster inspection helpers
controllers/util/util.go
Adds exported IsOpenShiftCluster() helper delegating to IsConfigAPIFound(), and expands GoDoc for cluster API detection functions.
ArgoCD SSO gating in controller
controllers/argocd/argocd.go
Imports util package, adds package logger, and updates getArgoSSOSpec to return nil (and log) when not OpenShift or when external authentication is enabled.
Tests for OpenShift vs non-OpenShift behavior
controllers/argocd/argocd_test.go
Imports controllers/util, sets SetConfigAPIFound(true) in existing tests, and adds TestSSOSkippedOnNonOpenShift asserting Spec.SSO == nil when not OpenShift.
Controller wiring gated by OpenShift detection
cmd/main.go
Adds clarifying comment and conditions ReconcileGitopsService SetupWithManager on util.IsOpenShiftCluster(); logs and skips setup when false.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: disabling GitOps Service and default instance on non-OpenShift Kubernetes clusters, which aligns with the PR's primary objective.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, providing detailed context about why the changes are needed, what changes are made, and how to test them.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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


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.

@openshift-ci openshift-ci Bot requested review from chetan-rns and keithchong June 9, 2026 11:35
@anandrkskd anandrkskd marked this pull request as draft June 9, 2026 13:21
@anandrkskd

Copy link
Copy Markdown
Contributor Author

/retest

@anandrkskd anandrkskd force-pushed the disable-default-instance-on-xks branch from 9aafd89 to 2b77b2b Compare June 10, 2026 09:10
@anandrkskd anandrkskd changed the title disable default instance on xKS clusters disable GitOps Service and default instance on xKS clusters Jun 12, 2026
@anandrkskd anandrkskd marked this pull request as ready for review June 12, 2026 11:50
@openshift-ci openshift-ci Bot requested review from svghadi and trdoyle81 June 12, 2026 11:50
@anandrkskd anandrkskd changed the title disable GitOps Service and default instance on xKS clusters Feat: disable GitOps Service and default instance on xKS clusters Jun 12, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
controllers/argocd/argocd.go (1)

101-103: 💤 Low value

Consider passing context through instead of using context.TODO().

Using context.TODO() is not ideal for production code. Consider adding a context.Context parameter to getArgoSSOSpec and passing it through from the caller.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@controllers/argocd/argocd.go` around lines 101 - 103, The code uses
context.TODO() when calling
argoappController.IsExternalAuthenticationEnabledOnCluster; update
getArgoSSOSpec to accept a context.Context parameter, replace context.TODO()
with that ctx when calling IsExternalAuthenticationEnabledOnCluster, and
propagate the new ctx through any callers of getArgoSSOSpec (update signatures
and call sites accordingly); ensure any helper functions called within
getArgoSSOSpec that currently use context.TODO() also accept/receive the
propagated ctx.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@controllers/argocd/argocd_test.go`:
- Around line 234-249: The test TestSSOSkippedOnNonOpenShift sets
util.SetConfigAPIFound(false) but defers util.SetConfigAPIFound(true), which
mismatches the actual default (false) in util.go and other tests (TestArgoCD,
TestDexConfiguration); change the deferred call in TestSSOSkippedOnNonOpenShift
to util.SetConfigAPIFound(false) so the test restores the real default and
avoids cross-test pollution.

---

Nitpick comments:
In `@controllers/argocd/argocd.go`:
- Around line 101-103: The code uses context.TODO() when calling
argoappController.IsExternalAuthenticationEnabledOnCluster; update
getArgoSSOSpec to accept a context.Context parameter, replace context.TODO()
with that ctx when calling IsExternalAuthenticationEnabledOnCluster, and
propagate the new ctx through any callers of getArgoSSOSpec (update signatures
and call sites accordingly); ensure any helper functions called within
getArgoSSOSpec that currently use context.TODO() also accept/receive the
propagated ctx.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 77aecd47-2f3f-4e6b-8c85-f460ea8fbb30

📥 Commits

Reviewing files that changed from the base of the PR and between 9aafd89 and 00b53d8.

📒 Files selected for processing (4)
  • cmd/main.go
  • controllers/argocd/argocd.go
  • controllers/argocd/argocd_test.go
  • controllers/util/util.go

Comment thread controllers/argocd/argocd_test.go
@anandrkskd

Copy link
Copy Markdown
Contributor Author

/retest

1 similar comment
@anandrkskd

Copy link
Copy Markdown
Contributor Author

/retest

svghadi
svghadi previously approved these changes Jun 16, 2026

@svghadi svghadi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

Just had one question regarding console-plugin and backend. They are controlled by gitopsservice controller. Is it expected that even these components shouldn't run on xks env?

@anandrkskd

Copy link
Copy Markdown
Contributor Author

Console plugin and gitops-backend are OpenShift specific, and are not required to run on non-OpenShift/xKS platforms. Disabling GitOps Service should take care of this.

Comment thread cmd/main.go Outdated
Comment thread cmd/main.go Outdated
Comment thread controllers/util/util.go Outdated
Comment thread controllers/util/util.go Outdated

@anandf anandf left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Posted few nitpick comments. otherwise looks good to me.

Signed-off-by: Anand Kumar Singh <anandrkskd@gmail.com>
…shift.io API doesn't exist. Gate on config.openshift.io presence before configuring SSO.

assisted-by: claude-code
Signed-off-by: Anand Kumar Singh <anandrkskd@gmail.com>
Signed-off-by: Anand Kumar Singh <anandrkskd@gmail.com>
assisted-by: Cursor for code-review
Signed-off-by: Anand Kumar Singh <anandrkskd@gmail.com>
Signed-off-by: Anand Kumar Singh <anandrkskd@gmail.com>
Signed-off-by: Anand Kumar Singh <anandrkskd@gmail.com>
@anandrkskd anandrkskd force-pushed the disable-default-instance-on-xks branch from aecf34c to c749948 Compare June 18, 2026 09:24
@openshift-ci openshift-ci Bot removed the lgtm label Jun 18, 2026
@openshift-ci

openshift-ci Bot commented Jun 18, 2026

Copy link
Copy Markdown

New changes are detected. LGTM label has been removed.

@anandf anandf left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@openshift-ci

openshift-ci Bot commented Jun 18, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by:

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

The pull request process is described 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

@anandrkskd

Copy link
Copy Markdown
Contributor Author

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved kind/enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants