-
Notifications
You must be signed in to change notification settings - Fork 135
feat: add label intersection mode for precise pod targeting #777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…el matching for pod selection Signed-off-by: XploY04 <2004agarwalyash@gmail.com>
… modes Signed-off-by: XploY04 <2004agarwalyash@gmail.com>
…l selector for intersection matching Signed-off-by: XploY04 <2004agarwalyash@gmail.com>
|
HI @XploY04 , We need to first add the below pre-requisites changes in chaos-operator: The First we need to update the workload schema to include a new field named Based on this field, we should modify the logic to append the value after the colon ( Finally, regenerate the CRDs to reflect these schema changes by running |
|
Hey @ispeakc0de, I've created the prerequisite PR in chaos-operator as requested: litmuschaos/chaos-operator#510 This adds the I initially thought users could simply override TARGETS via env vars (which does work), but I understand now that a schema-based approach provides better UX, validation, and maintainability. Please let me know if any changes are needed! |
| data := AppDetails{ | ||
| Kind: val[0], | ||
| Namespace: val[1], | ||
| Kind: val[0], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we check for array length to avoid array index out of bound?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise an error if len(val) < 3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ispeakc0de
I have made the required changes.
… format Signed-off-by: XploY04 <2004agarwalyash@gmail.com>
What this PR does / why we need it:
This PR adds support for label intersection mode when selecting target pods for chaos experiments, enabling precise pod targeting by matching ALL specified labels (AND logic) instead of the default union behavior that matches ANY label (OR logic).
Problem: Currently, multiple labels use UNION (OR) logic - selecting pods that match ANY label. This causes unintended pod selection when precise targeting is needed (e.g., "primary role AND specific cluster"). As noted in issue #774, when working with CloudNativePG clusters that have multiple instances with different roles, the union behavior selects too many pods.
Solution: Adds optional 4th parameter to TARGETS env variable:
Where mode can be
union(default) orintersectionExample:
Changes:
LabelMatchModefield toAppDetailsstructgetPodsWithIntersectionLabels()functionGetTargets()to parse optional mode parameterBackward Compatibility: Fully compatible - defaults to union mode
Which issue this PR fixes : fixes #774
Use Cases:
Checklist:
breaking-changestag - Not applicable (backward compatible)requires-upgradetag - Not applicablepkg/types/types_test.go)