Skip to content

do not delete disabled resources#2733

Open
gazarenkov wants to merge 4 commits into
redhat-developer:mainfrom
gazarenkov:do-not-delete-local-db-resources
Open

do not delete disabled resources#2733
gazarenkov wants to merge 4 commits into
redhat-developer:mainfrom
gazarenkov:do-not-delete-local-db-resources

Conversation

@gazarenkov
Copy link
Copy Markdown
Member

Description

It excludes potential deleting the resources created when certain feature is disabled (such as local db, route, monitor)

Which issue(s) does this PR fix or relate to

https://redhat.atlassian.net/browse/RHDHBUGS-2781

PR acceptance criteria

  • Tests
  • Documentation

How to test changes / Special notes to the reviewer

For example:

  • Create empty CR (spec.database.enableLocalDb=true by default)
  • Check DB StatefulSet created
  • Modify CR with spec.database.enableLocalDb=false and apply
  • Check DB StatefulSet is still there

@gazarenkov gazarenkov requested review from rm3l April 30, 2026 06:48
Copy link
Copy Markdown
Member

@rm3l rm3l left a comment

Choose a reason for hiding this comment

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

Hmm.., it might be confusing to see that some resources are still there when the corresponding feature is purposely toggled from enabled to disabled. For example, I first create a Backstage CR on OCP (so with a Route created by default), then I set spec.application.route.enabled: false in the CR, and now the Route object is still present.
Maybe the Operator could add some uniquely identifiable labels on the resources it creates and manages, and only try to delete those to avoid conflict with user-created resources?
Or (thinking out loud) maybe just refuse to reconcile if there are conflicting resources that it does not manage, and thus avoid touching those?

@gazarenkov
Copy link
Copy Markdown
Member Author

Hmm.., it might be confusing to see that some resources are still there when the corresponding feature is purposely toggled from enabled to disabled. For example, I first create a Backstage CR on OCP (so with a Route created by default), then I set spec.application.route.enabled: false in the CR, and now the Route object is still present. Maybe the Operator could add some uniquely identifiable labels on the resources it creates and manages, and only try to delete those to avoid conflict with user-created resources? Or (thinking out loud) maybe just refuse to reconcile if there are conflicting resources that it does not manage, and thus avoid touching those?

Let's just document it for clarity and keep simple until we really need to make it complex.
Those resources, with specific names, are "special", operator manages it if certain feature is enabled and ignores otherwise.

@rm3l
Copy link
Copy Markdown
Member

rm3l commented May 12, 2026

Hmm.., it might be confusing to see that some resources are still there when the corresponding feature is purposely toggled from enabled to disabled. For example, I first create a Backstage CR on OCP (so with a Route created by default), then I set spec.application.route.enabled: false in the CR, and now the Route object is still present. Maybe the Operator could add some uniquely identifiable labels on the resources it creates and manages, and only try to delete those to avoid conflict with user-created resources? Or (thinking out loud) maybe just refuse to reconcile if there are conflicting resources that it does not manage, and thus avoid touching those?

Let's just document it for clarity and keep simple until we really need to make it complex. Those resources, with specific names, are "special", operator manages it if certain feature is enabled and ignores otherwise.

This would be kinda breaking change then, I guess.
But overall, I think that even with documentation, just leaving them as is might end up creating more confusion with orphaned resources that might still consume cluster resources. The example with the Route would be particularly confusing IMO as the route is still active (can accept external traffic) but is no longer managed by the Operator.
Since the operator already sets owner reference on the resources it creates, would it make sense to "just" check with metav1.IsControlledBy before deleting? I feel like this would be small targeted changed compared to the current PR which, IMHO, would be a behavioral change that might end up causing more confusion (in 1.10).

@rm3l
Copy link
Copy Markdown
Member

rm3l commented May 18, 2026

Hmm.., it might be confusing to see that some resources are still there when the corresponding feature is purposely toggled from enabled to disabled. For example, I first create a Backstage CR on OCP (so with a Route created by default), then I set spec.application.route.enabled: false in the CR, and now the Route object is still present. Maybe the Operator could add some uniquely identifiable labels on the resources it creates and manages, and only try to delete those to avoid conflict with user-created resources? Or (thinking out loud) maybe just refuse to reconcile if there are conflicting resources that it does not manage, and thus avoid touching those?

Let's just document it for clarity and keep simple until we really need to make it complex. Those resources, with specific names, are "special", operator manages it if certain feature is enabled and ignores otherwise.

This would be kinda breaking change then, I guess. But overall, I think that even with documentation, just leaving them as is might end up creating more confusion with orphaned resources that might still consume cluster resources. The example with the Route would be particularly confusing IMO as the route is still active (can accept external traffic) but is no longer managed by the Operator. Since the operator already sets owner reference on the resources it creates, would it make sense to "just" check with metav1.IsControlledBy before deleting? I feel like this would be small targeted changed compared to the current PR which, IMHO, would be a behavioral change that might end up causing more confusion (in 1.10).

As discussed today, let's document this here (and also consider mentioning this in the official product docs).

@rm3l
Copy link
Copy Markdown
Member

rm3l commented May 18, 2026

/cherry-pick release-1.10

@openshift-cherrypick-robot
Copy link
Copy Markdown

@rm3l: once the present PR merges, I will cherry-pick it on top of release-1.10 in a new PR and assign it to you.

Details

In response to this:

/cherry-pick release-1.10

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.

@rm3l rm3l requested a review from a team as a code owner May 18, 2026 15:32
@rm3l rm3l deployed to internal May 18, 2026 15:32 — with GitHub Actions Active
@sonarqubecloud
Copy link
Copy Markdown

@codecov
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.05%. Comparing base (0e1d1db) to head (056699b).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2733      +/-   ##
==========================================
- Coverage   61.18%   61.05%   -0.13%     
==========================================
  Files          37       37              
  Lines        2128     2098      -30     
==========================================
- Hits         1302     1281      -21     
+ Misses        692      683       -9     
  Partials      134      134              
Flag Coverage Δ
nightly ?
unittests 61.05% <100.00%> (-0.13%) ⬇️

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

Files with missing lines Coverage Δ
internal/controller/backstage_controller.go 0.00% <ø> (-10.21%) ⬇️
internal/controller/monitor.go 94.87% <100.00%> (-0.59%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

3 participants