Skip to content

remove orphaned subscribers from nats jetstream channels - #679

Merged
knative-prow[bot] merged 8 commits into
knative-extensions:mainfrom
astelmashenko:bugfix/remove-orphaned-subs
Sep 11, 2025
Merged

remove orphaned subscribers from nats jetstream channels#679
knative-prow[bot] merged 8 commits into
knative-extensions:mainfrom
astelmashenko:bugfix/remove-orphaned-subs

Conversation

@astelmashenko

Copy link
Copy Markdown
Member

There was an issues that sometime we observeved incosistency in actual subscribers CRDs and channels' list of subs. There were non-existent subs in channel.

Proposed Changes

This PR fixes that by checking list of subscription CRD against NastJetStreamChannel list of subscriptions.

Release Note

Reconclier now can remove non-existing subscriptions.

@knative-prow knative-prow Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 3, 2025
@knative-prow
knative-prow Bot requested review from creydr and dan-j September 3, 2025 10:24
@codecov

codecov Bot commented Sep 3, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 6.94444% with 67 lines in your changes missing coverage. Please review.
✅ Project coverage is 26.24%. Comparing base (fe02889) to head (eeb17b2).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
pkg/channel/jetstream/dispatcher/reconciler.go 7.69% 59 Missing and 1 partial ⚠️
pkg/channel/jetstream/dispatcher/controller.go 0.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #679      +/-   ##
==========================================
- Coverage   26.69%   26.24%   -0.46%     
==========================================
  Files          44       44              
  Lines        2772     2839      +67     
==========================================
+ Hits          740      745       +5     
- Misses       1974     2035      +61     
- Partials       58       59       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@astelmashenko

Copy link
Copy Markdown
Member Author

/cherrypick release-1.18

@knative-prow-robot

Copy link
Copy Markdown
Contributor

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

Details

In response to this:

/cherrypick release-1.18

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.

@astelmashenko
astelmashenko marked this pull request as ready for review September 3, 2025 14:52
@knative-prow knative-prow Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 3, 2025
@knative-prow
knative-prow Bot requested a review from Leo6Leo September 3, 2025 14:52
@astelmashenko

Copy link
Copy Markdown
Member Author

/assign @Cali0707

subsUids.Insert(string(s.UID))
}

orphanedSubs := subsUids.Difference(allSubsInNsUids)

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.

I think we should have some sort of check for the type of Channel the subscription is referencing, as there are scenarios where users have multiple types of Channels (e.g. In Memory + NATS)

My concern is that we would be deleting too many subscriptions in this scenario

@astelmashenko astelmashenko Sep 4, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@Cali0707 , it is difference, it works the next way:

Difference returns a set of objects that are not in s2. For example: s1 = {a1, a2, a3} s2 = {a1, a2, a4, a5} s1.Difference(s2) = {a3} s2.Difference(s1) = {a4, a5}

s1 in our case is Channel.Spec.Subscriptions, s2 is all sub in a namespace, so there is no issue if we take all subs in a namespace, making difference of UIDS we just remove all subs from s1 which are actually exist and leftovers are those do not exist. And we do not delete any CRDs, we only delete orphaned subscriptions from a Channel.Spec.Subscriptions and Channel.Status.Subscriptions.

@Cali0707 Cali0707 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

@knative-prow knative-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Sep 10, 2025
@astelmashenko

Copy link
Copy Markdown
Member Author

@creydr , could you please skip codecov for this one?

@knative-prow knative-prow Bot removed the lgtm Indicates that a PR is ready to be merged. label Sep 11, 2025

@Cali0707 Cali0707 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

@knative-prow knative-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Sep 11, 2025
@knative-prow

knative-prow Bot commented Sep 11, 2025

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: astelmashenko, Cali0707

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:
  • OWNERS [Cali0707,astelmashenko]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@astelmashenko

Copy link
Copy Markdown
Member Author

@dprotaso , could you please skip codecov for this PR?

@dprotaso

Copy link
Copy Markdown
Contributor

/override "codecov/patch"

you can adjust the settings here - https://github.com/knative-extensions/eventing-natss/blob/main/.codecov.yaml

@knative-prow

knative-prow Bot commented Sep 11, 2025

Copy link
Copy Markdown

@dprotaso: Overrode contexts on behalf of dprotaso: codecov/patch

Details

In response to this:

/override "codecov/patch"

you can adjust the settings here - https://github.com/knative-extensions/eventing-natss/blob/main/.codecov.yaml

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.

@knative-prow
knative-prow Bot merged commit 64abebf into knative-extensions:main Sep 11, 2025
21 of 22 checks passed
@knative-prow-robot

Copy link
Copy Markdown
Contributor

@astelmashenko: new pull request created: #685

Details

In response to this:

/cherrypick release-1.18

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.

@astelmashenko

Copy link
Copy Markdown
Member Author

/cherrypick release-1.18

@astelmashenko

Copy link
Copy Markdown
Member Author

/cherrypick release-1.19

@knative-prow-robot

Copy link
Copy Markdown
Contributor

@astelmashenko: new pull request could not be created: failed to create pull request against knative-extensions/eventing-natss#release-1.18 from head knative-prow-robot:cherry-pick-679-to-release-1.18: status code 422 not one of [201], body: {"message":"Validation Failed","errors":[{"resource":"PullRequest","code":"custom","message":"A pull request already exists for knative-prow-robot:cherry-pick-679-to-release-1.18."}],"documentation_url":"https://docs.github.com/rest/pulls/pulls#create-a-pull-request","status":"422"}

Details

In response to this:

/cherrypick release-1.18

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.

@knative-prow-robot

Copy link
Copy Markdown
Contributor

@astelmashenko: new pull request created: #686

Details

In response to this:

/cherrypick release-1.19

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.

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants