-
Notifications
You must be signed in to change notification settings - Fork 748
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
EventSource "Resource" label selector doesn't support "exists" operator (and possibly others) #2775
Comments
If we check the documentation for selectors here https://github.com/argoproj/argo-events/blob/master/api/event-source.md#selector. It says "Supported operations like ==, !=, <=, >= etc" But if we use a "<=" operator we will get an error. Argo uses NewRequirements under the hood: https://pkg.go.dev/k8s.io/[email protected]/pkg/labels#NewRequirement // NewRequirement is the constructor for a Requirement.
// If any of these rules is violated, an error is returned:
// (1) The operator can only be In, NotIn, Equals, DoubleEquals, Gt, Lt, NotEquals, Exists, or DoesNotExist.
// (2) If the operator is In or NotIn, the values set must be non-empty.
// (3) If the operator is Equals, DoubleEquals, or NotEquals, the values set must contain one value.
// (4) If the operator is Exists or DoesNotExist, the value set must be empty.
// (5) If the operator is Gt or Lt, the values set must contain only one value, which will be interpreted as an integer.
// (6) The key is invalid due to its length, or sequence
// of characters. See validateLabelKey for more details.
//
// The empty string is a valid value in the input values set.
// Returned error, if not nil, is guaranteed to be an aggregated field.ErrorList operators : In, NotIn etc are defined here: https://pkg.go.dev/k8s.io/[email protected]/pkg/selection#Operator Argo creates a requirement using the following line req, err := labels.NewRequirement(sel.Key, op, []string{sel.Value}) So for both: - key: workflows.argoproj.io/phase
operation: exists
- key: workflows.argoproj.io/phase
operation: exists
value: "" a list [""] is passed to NewRequirements where it is expecting an empty list [] for operators exist and !. This is throwing the error in the issue. Also only one value is used to create the requirement, this means in and notin are the same as == and != Possible fixesFor fixing exist and !:
For fixing <= and >= error:
For in and notin:
I would like to contribute to fix this issue. |
Then propose a pull request |
Before changes
After changes
|
Describe the bug
I've added the following EventSource to get events when the Workflow instances are completed:
but the event source containers crashes during startup, this the relevant log:
I believe the error is where the requirements are created: there it always initializes a string value
To Reproduce
Add the already mentioned eventsource with
kubectl apply -f eventsource.yaml
Expected behavior
To not crash and filter updates that only ave that label
Environment (please complete the following information):
Message from the maintainers:
If you wish to see this enhancement implemented please add a 👍 reaction to this issue! We often sort issues this way to know what to prioritize.
The text was updated successfully, but these errors were encountered: