Skip to content

feat: prevent openshift-gitops namespace creation when DISABLE_DEFAULT_ARGOCD_INSTANCE=true#1206

Open
Rizwana777 wants to merge 1 commit into
redhat-developer:masterfrom
Rizwana777:issue-10435-do-not-create-namespace
Open

feat: prevent openshift-gitops namespace creation when DISABLE_DEFAULT_ARGOCD_INSTANCE=true#1206
Rizwana777 wants to merge 1 commit into
redhat-developer:masterfrom
Rizwana777:issue-10435-do-not-create-namespace

Conversation

@Rizwana777

@Rizwana777 Rizwana777 commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

What type of PR is this?
/kind enhancement

What does this PR do / why we need it:
This PR prevents the openshift-gitops namespace from being created when DISABLE_DEFAULT_ARGOCD_INSTANCE=true is set. Previously, the flag only prevented the ArgoCD instance creation but still created the namespace.

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-10435

Test acceptance criteria:

  • Unit Test
  • E2E Test

How to test changes / Special notes to the reviewer:
Fresh install with flag enabled
Set environment variable in operator Subscription
DISABLE_DEFAULT_ARGOCD_INSTANCE=true

verify
oc get namespace openshift-gitops
Expected: Error from server (NotFound)

test with make

make install
export DISABLE_DEFAULT_ARGOCD_INSTANCE=true
make run

verify
oc get namespace openshift-gitops
Expected: Error from server (NotFound)

@openshift-ci openshift-ci Bot added the kind/enhancement New feature or request label Jul 8, 2026
@openshift-ci openshift-ci Bot requested review from jannfis and trdoyle81 July 8, 2026 12:31
@openshift-ci

openshift-ci Bot commented Jul 8, 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 varshab1210 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

@coderabbitai

coderabbitai Bot commented Jul 8, 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: 50419fd1-e916-4aba-a536-d3b2d01aab4a

📥 Commits

Reviewing files that changed from the base of the PR and between 6b7a2f6 and 55084fa.

📒 Files selected for processing (7)
  • controllers/gitopsservice_controller.go
  • controllers/gitopsservice_controller_test.go
  • docs/Migration_Guide.md
  • docs/OpenShift GitOps Usage Guide.md
  • hack/non-olm-install/README.md
  • test/nondefaulte2e/gitops_service_nondefault_test.go
  • test/openshift/e2e/ginkgo/sequential/1-018_validate_disable_default_instance_test.go
🔗 Linked repositories identified

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

  • argoproj-labs/argocd-operator (manual)
✅ Files skipped from review due to trivial changes (3)
  • hack/non-olm-install/README.md
  • docs/Migration_Guide.md
  • docs/OpenShift GitOps Usage Guide.md
🚧 Files skipped from review as they are similar to previous changes (4)
  • test/nondefaulte2e/gitops_service_nondefault_test.go
  • controllers/gitopsservice_controller_test.go
  • test/openshift/e2e/ginkgo/sequential/1-018_validate_disable_default_instance_test.go
  • controllers/gitopsservice_controller.go

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of the “disable default install” option so the default Argo CD setup and its namespace are fully removed when requested.
    • Skips backend setup when the target namespace is missing or being deleted, and avoids console plugin reconciliation in this mode.
    • Tightened version checks so plugin setup only runs when cluster version compatibility can be reliably determined.
  • Documentation

    • Clarified the behavior of the disable-default-install setting across migration, usage, and install guides.

Walkthrough

The reconcile flow now deletes the default Argo CD namespace when default install is disabled, skips namespace-backed work when the backend namespace is missing or terminating, and keeps plugin reconciliation gated in the enabled path. Tests and docs were updated to match the namespace-removal behavior.

Changes

Disable default install deletes namespace

Layer / File(s) Summary
Reconcile control flow and namespace deletion
controllers/gitopsservice_controller.go
Namespace creation and metadata updates now run only when default install is enabled; the disabled path deletes the default Argo CD namespace, reconciles backend only when the backend namespace exists and is not terminating, and the enabled path keeps version-gated plugin reconciliation.
Unit tests, e2e tests, and documentation updates
controllers/gitopsservice_controller_test.go, test/nondefaulte2e/gitops_service_nondefault_test.go, test/openshift/e2e/ginkgo/sequential/1-018_validate_disable_default_instance_test.go, docs/Migration_Guide.md, docs/OpenShift GitOps Usage Guide.md, hack/non-olm-install/README.md
Tests now assert namespace absence/deletion and skipped backend deployment when default install is disabled, the e2e recovery flow checks namespace removal and recreation, and the docs describe deletion of both the namespace and default instance.

Estimated code review effort: 4 (Complex) | ~40 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: skipping openshift-gitops namespace creation when the disable flag is enabled.
Description check ✅ Passed The description matches the changeset and explains the namespace-creation behavior change and its motivation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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.

@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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/Migration_Guide.md (1)

68-68: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Update the DISABLE_DEFAULT_ARGOCD_INSTANCE description at line 68 for consistency

Line 9 was updated to mention namespace deletion, but line 68 still reads "Disables the installation of default instance in openshift-gitops namespace" without mentioning that the namespace itself is also deleted. This is inconsistent with the updated docs in the Usage Guide (line 225) and the non-olm README (line 84).

📝 Proposed fix
-`DISABLE_DEFAULT_ARGOCD_INSTANCE`: Disables the installation of default instance in openshift-gitops namespace.
+`DISABLE_DEFAULT_ARGOCD_INSTANCE`: Disables the installation of the default instance and deletes the `openshift-gitops` namespace if it exists.
🤖 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 `@docs/Migration_Guide.md` at line 68, Update the
DISABLE_DEFAULT_ARGOCD_INSTANCE description in Migration_Guide.md to match the
other docs by stating that it disables installation of the default instance in
the openshift-gitops namespace and also deletes the namespace itself. Keep the
wording consistent with the updated Usage Guide and non-olm README entries, and
make the change in the documentation text that references this flag.
🤖 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/gitopsservice_controller.go`:
- Around line 329-343: Skip backend reconciliation when the namespace is already
marked for deletion, because ensureDefaultArgoCDInstanceDoesntExist may leave it
in Terminating and the later Client.Get can still succeed. In the reconcile path
that calls ensureDefaultArgoCDInstanceDoesntExist, inspect the Namespace object
returned by Client.Get and only call reconcileBackend when it exists and has no
DeletionTimestamp; otherwise return without reconciling. Use the existing
symbols ensureDefaultArgoCDInstanceDoesntExist, Client.Get, and reconcileBackend
to keep the fix localized.
- Around line 309-319: Guard the version parsing in gitopsservice_controller.go
before indexing Segments() in the OCP version comparison logic. In the code
around realVersion/startVersion and the
version.NewVersion(dynamicPluginStartOCPVersion) path, check that each slice has
at least 2 elements before reading index 1, and handle shorter versions safely
by returning early or skipping the comparison. This prevents an
index-out-of-range panic when dynamicPluginStartOCPVersion is a single-segment
version like "4".

---

Outside diff comments:
In `@docs/Migration_Guide.md`:
- Line 68: Update the DISABLE_DEFAULT_ARGOCD_INSTANCE description in
Migration_Guide.md to match the other docs by stating that it disables
installation of the default instance in the openshift-gitops namespace and also
deletes the namespace itself. Keep the wording consistent with the updated Usage
Guide and non-olm README entries, and make the change in the documentation text
that references this flag.
🪄 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: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 6a8f4a18-d3cf-422c-8289-8219321517c2

📥 Commits

Reviewing files that changed from the base of the PR and between 9c713d1 and c93704a.

📒 Files selected for processing (6)
  • controllers/gitopsservice_controller.go
  • controllers/gitopsservice_controller_test.go
  • docs/Migration_Guide.md
  • docs/OpenShift GitOps Usage Guide.md
  • hack/non-olm-install/README.md
  • test/openshift/e2e/ginkgo/sequential/1-018_validate_disable_default_instance_test.go
🔗 Linked repositories identified

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

  • argoproj-labs/argocd-operator (manual)

Comment thread controllers/gitopsservice_controller.go
Comment thread controllers/gitopsservice_controller.go
@Rizwana777 Rizwana777 force-pushed the issue-10435-do-not-create-namespace branch 2 times, most recently from 8a43107 to 6b7a2f6 Compare July 9, 2026 08:44
…T_ARGOCD_INSTANCE=true

Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com>
Assisted-by: Claude
@Rizwana777 Rizwana777 force-pushed the issue-10435-do-not-create-namespace branch from 6b7a2f6 to 55084fa Compare July 9, 2026 11:31
@Rizwana777

Copy link
Copy Markdown
Collaborator Author

/retest

@svghadi

svghadi commented Jul 10, 2026

Copy link
Copy Markdown
Member

This will also disable console-plugin deployment, is that expected ?

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

Labels

kind/enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants