Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
closes: #1187
! honest information : The fix and the PR message was written by AI (useful sometime :D). I understand the result, build it and it work as expected. Also all tests seems to work. This fix only fix the category selector, I don't know if this should be fix also for other selectors ...
Feel free to request change, or take it yourself :)
Result log :
Fix category selector to include all versions, not just preferred ones
Problem
When using category selectors (e.g.,
category=test), only CRDs with the preferred version were being selected, even though all CRDs with that category should be included.For example, with these CRDs:
Only
rsmultis/v1beta2was selected when usingcategory=test, instead of both resources.Root Cause
The issue was in the
checkmethod of theSelectorclass inkopf/_cogs/structs/references.pyat line 361:This logic meant that when
self.versionwasNone(which it is for category selectors), only resources whereresource.preferredwasTruewould be selected. In Kubernetes, only one version per API group can be preferred, causing non-preferred versions to be filtered out.Solution
Modified the version matching logic to specifically handle category selectors differently:
Changes
Testing
Files Changed
kopf/_cogs/structs/references.py: Fixed the version matching logic inSelector.check()tests/references/test_category_selector_fix.py: Added comprehensive regression testsThis fix is minimal, targeted, and maintains backward compatibility while resolving the specific issue with category-based resource selection.