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
ListOptions step on each other, HasLabels and MatchingLabels compete #2098
Comments
We have found that using HasLabels and MatchingLabels in the same Kubernetes List call leads to only one of them being applied. See kubernetes-sigs/controller-runtime#2098 This patch fixes one occurrence of this double usage in the operator code, avoiding some unneeded reconciliation cycles. Signed-off-by: Jaime Silvela <jaime.silvela@enterprisedb.com>
We have found that using HasLabels and MatchingLabels in the same Kubernetes List call leads to only one of them being applied. See kubernetes-sigs/controller-runtime#2098 This patch fixes one occurrence of this double usage in the operator code, avoiding some unneeded reconciliation cycles. Signed-off-by: Jaime Silvela <jaime.silvela@enterprisedb.com> (cherry picked from commit 2aaa31c)
/kind bug Feel free to contribute a fix |
We have found that using HasLabels and MatchingLabels in the same Kubernetes List call leads to only one of them being applied. See kubernetes-sigs/controller-runtime#2098 This patch fixes one occurrence of this double usage in the operator code, avoiding some unneeded reconciliation cycles. Signed-off-by: Jaime Silvela <jaime.silvela@enterprisedb.com>
We have found that using HasLabels and MatchingLabels in the same Kubernetes List call leads to only one of them being applied. See kubernetes-sigs/controller-runtime#2098 This patch fixes one occurrence of this double usage in the operator code, avoiding some unneeded reconciliation cycles. Signed-off-by: Jaime Silvela <jaime.silvela@enterprisedb.com>
Yep @alvaroaleman would like to, going to try to make time for this |
I posted in Slack, but will add my question here, I think it may be relevant: I am working on a PR for this Issue. I have a fix that is passing all the tests for |
I.e. I have this for MatchingLabels
I saw that unit test is your work @alvaroaleman , I see it was fixing a previous bug. I'm assuming my way above won't work, because it would not produce any selector given invalid input. |
@jsilvela the original problem was that invalid input to At the end of the day, multiple requirements in a labelselector are anded by joining them comma-separated. So how about we make the two I'd also rather have us construct a string label selector in |
Ah, I see. Great information, thank you. I will start working on that direction today if I can. |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close not-planned |
@k8s-triage-robot: Closing this issue, marking it as "Not Planned". In response to this:
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/test-infra repository. |
For reference this has been fixed via #2363 /close |
@sbueringer: Closing this issue. In response to this:
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/test-infra repository. |
When trying to get a List using the variadic ListOptions argument, I ran to unexpected behavior if applying both HasLabels and MatchingLabels.
When watching the code in action, more pods than expected were being returned.
It seemed as if the ListOptions were being OR'ed rather than AND'ed.
Looking into the implementation of
MatchingLabels
andHasLabels
, in theirApplyToList(opts *ListOptions)
,both will overwrite whatever values the
LabelSelector
had before.This means, likely, that if we apply both HasLabels and MatchingLabels, the last one applied will "win".
This is rather un-intuitive behavior.
If it is so by design, I think it should be documented.
If possible, I would think a logical AND would be the intuitive expectation.
The text was updated successfully, but these errors were encountered: