Skip to content

fix: Do not error out when trying to delete resource whose CRD does not exist [RHDHBUGS-1990] - #1552

Merged
rm3l merged 2 commits into
redhat-developer:mainfrom
rm3l:rhdhbugs-1990-operator-unable-to-reconcile-backstage-cr-in-a-vanilla-k8s-cluster-no-matches-for-kind-servicemonitor-in-version-monitoring.coreos.com-v1
Aug 26, 2025
Merged

fix: Do not error out when trying to delete resource whose CRD does not exist [RHDHBUGS-1990]#1552
rm3l merged 2 commits into
redhat-developer:mainfrom
rm3l:rhdhbugs-1990-operator-unable-to-reconcile-backstage-cr-in-a-vanilla-k8s-cluster-no-matches-for-kind-servicemonitor-in-version-monitoring.coreos.com-v1

Conversation

@rm3l

@rm3l rm3l commented Aug 26, 2025

Copy link
Copy Markdown
Member

Description

This fixes an issue when trying to reconcile a Backstage CR in a vanilla K8s.
Reconciliation would fail with the following error:

failed to apply ServiceMonitor failed to delete metrics-bs1: no matches
for kind "ServiceMonitor" in version "monitoring.coreos.com/v1"

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

PR acceptance criteria

  • Tests
  • Documentation

How to test changes / Special notes to the reviewer

See repro steps in https://issues.redhat.com/browse/RHDHBUGS-1990

Summary by Sourcery

Ignore missing CRD errors when deleting resources during reconciliation to prevent failures in vanilla Kubernetes clusters

Bug Fixes:

  • Prevent reconciliation from failing when deleting a resource whose CRD is not installed by treating meta.NoMatchError as non-fatal

Enhancements:

  • Extend tryToDelete to suppress NoMatchError alongside NotFound errors

Tests:

  • Add unit tests for tryToDelete covering success, NotFound, NoMatchError, and other error scenarios

rm3l added 2 commits August 26, 2025 11:25
…t exist

This fixes an issue when trying to reconcile a Backstage CR in a vanilla K8s.
Reconciliation would fail with the following error:

```
failed to apply ServiceMonitor failed to delete metrics-bs1: no matches
for kind "ServiceMonitor" in version "monitoring.coreos.com/v1"
```

ref: RHDHBUGS-1990
@rm3l
rm3l force-pushed the rhdhbugs-1990-operator-unable-to-reconcile-backstage-cr-in-a-vanilla-k8s-cluster-no-matches-for-kind-servicemonitor-in-version-monitoring.coreos.com-v1 branch from e1b715f to 667d191 Compare August 26, 2025 09:25
@rm3l
rm3l marked this pull request as ready for review August 26, 2025 09:35
@rm3l

rm3l commented Aug 26, 2025

Copy link
Copy Markdown
Member Author

/cc @gazarenkov @Fortune-Ndlovu

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@rm3l rm3l changed the title fix: Do not error out when trying to delete resource when CRD does not exist [RHDHBUGS-1990] fix: Do not error out when trying to delete resource whose CRD does not exist [RHDHBUGS-1990] Aug 26, 2025

@Fortune-Ndlovu Fortune-Ndlovu 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 Thanks Armel.

@openshift-ci

openshift-ci Bot commented Aug 26, 2025

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Fortune-Ndlovu, gazarenkov

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

@rm3l
rm3l merged commit 84af8b5 into redhat-developer:main Aug 26, 2025
10 of 11 checks passed
@rm3l
rm3l deleted the rhdhbugs-1990-operator-unable-to-reconcile-backstage-cr-in-a-vanilla-k8s-cluster-no-matches-for-kind-servicemonitor-in-version-monitoring.coreos.com-v1 branch August 26, 2025 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants