You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "vortegatorres (via GitHub)" <gi...@apache.org> on 2023/09/30 14:40:37 UTC
[GitHub] [apisix-ingress-controller] vortegatorres opened a new pull request, #1994: Feature: namespace_selector support for having multiple values for the same label
vortegatorres opened a new pull request, #1994:
URL: https://github.com/apache/apisix-ingress-controller/pull/1994
<!-- Please answer these questions before submitting a pull request -->
### Type of change:
Adding `namespace_selector` support for having multiple values for the same label. Context https://github.com/apache/apisix-ingress-controller/issues/1987
<!-- Select all the options from below that matches the type your PR best -->
- [ ] Bugfix
- [X] New feature provided
- [ ] Improve performance
- [ ] Backport patches
- [ ] Documentation
- [ ] Refactor
- [ ] Chore
- [ ] CI/CD or Tests
### What this PR does / why we need it:
In the `namespace_selector` configuration, when there are multiple values for the same label, only the last one is taken into account. This happens because the label key serves as the unique identifier [in this map](https://github.com/apache/apisix-ingress-controller/blob/bca0d1da5e0d721ff7c94555821db55dd2659504/pkg/providers/k8s/namespace/namespace_provider.go#L70), and the most recent value will replace any previous ones.
For instance, if you have the following values, only "app3" would be considered in the list of watched namespaces:
```
namespace_selector:
- "kubernetes.io/metadata.name=app1"
- "kubernetes.io/metadata.name=app2"
- "kubernetes.io/metadata.name=app3"
```
### Pre-submission checklist:
<!--
Please follow the requirements:
1. Use Draft if the PR is not ready to be reviewed
2. Test is required for the feat/fix PR, unless you have a good reason
3. Doc is required for the feat PR
4. Use a new commit to resolve review instead of `push -f`
5. Use "request review" to notify the reviewer once you have resolved the review
-->
- [ ] Did you explain what problem does this PR solve? Or what new features have been added?
- [ ] Have you added corresponding test cases?
- [ ] Have you modified the corresponding document?
- [ ] Is this PR backward compatible? **If it is not backward compatible, please discuss on the [mailing list](https://github.com/apache/apisix-ingress-controller#community) first**
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature: namespace_selector support for having multiple values for the same label [apisix-ingress-controller]
Posted by "vortegatorres (via GitHub)" <gi...@apache.org>.
vortegatorres commented on PR #1994:
URL: https://github.com/apache/apisix-ingress-controller/pull/1994#issuecomment-1761116764
> please check failed jobs
Apart from the e2e tests, which, looking at other PRs, seems generally failing, the only failing job is the `unit-test-ci`. However, I am unable to replicate any of the `unit-test-ci` issues running the unit tests. Is there a way to rerun it? I don't believe there is any problem with it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature: namespace_selector support for having multiple values for the same label [apisix-ingress-controller]
Posted by "Revolyssup (via GitHub)" <gi...@apache.org>.
Revolyssup closed pull request #1994: Feature: namespace_selector support for having multiple values for the same label
URL: https://github.com/apache/apisix-ingress-controller/pull/1994
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature: namespace_selector support for having multiple values for the same label [apisix-ingress-controller]
Posted by "Revolyssup (via GitHub)" <gi...@apache.org>.
Revolyssup commented on PR #1994:
URL: https://github.com/apache/apisix-ingress-controller/pull/1994#issuecomment-1853423003
Closing this PR. I will create another one
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature: namespace_selector support for having multiple values for the same label [apisix-ingress-controller]
Posted by "tao12345666333 (via GitHub)" <gi...@apache.org>.
tao12345666333 commented on PR #1994:
URL: https://github.com/apache/apisix-ingress-controller/pull/1994#issuecomment-1758748906
please check failed jobs
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature: namespace_selector support for having multiple values for the same label [apisix-ingress-controller]
Posted by "vortegatorres (via GitHub)" <gi...@apache.org>.
vortegatorres commented on PR #1994:
URL: https://github.com/apache/apisix-ingress-controller/pull/1994#issuecomment-1754940943
@tao12345666333 What should we do next to get this pull request merged?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] vortegatorres commented on pull request #1994: Feature: namespace_selector support for having multiple values for the same label
Posted by "vortegatorres (via GitHub)" <gi...@apache.org>.
vortegatorres commented on PR #1994:
URL: https://github.com/apache/apisix-ingress-controller/pull/1994#issuecomment-1742472740
> Please add an e2e test case to cover this feature.
Where is the best place to add the test?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature: namespace_selector support for having multiple values for the same label [apisix-ingress-controller]
Posted by "AlinsRan (via GitHub)" <gi...@apache.org>.
AlinsRan commented on PR #1994:
URL: https://github.com/apache/apisix-ingress-controller/pull/1994#issuecomment-1765534249
Let me check it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] vortegatorres commented on a diff in pull request #1994: Feature: namespace_selector support for having multiple values for the same label
Posted by "vortegatorres (via GitHub)" <gi...@apache.org>.
vortegatorres commented on code in PR #1994:
URL: https://github.com/apache/apisix-ingress-controller/pull/1994#discussion_r1341970199
##########
pkg/providers/k8s/namespace/namespace_provider.go:
##########
@@ -103,7 +103,21 @@ func (c *watchingProvider) Init(ctx context.Context) error {
}
func (c *watchingProvider) initWatchingNamespacesByLabels(ctx context.Context) error {
- labelSelector := metav1.LabelSelector{MatchLabels: c.watchingLabels}
+ valuesByKey := make(map[string][]string)
+ for key, value := range c.watchingLabels {
+ valuesByKey[key] = append(valuesByKey[key], value)
+ }
+ var matchExpressions []metav1.LabelSelectorRequirement
+ for key, values := range valuesByKey {
+ requirement := metav1.LabelSelectorRequirement{
+ Key: key,
+ Operator: metav1.LabelSelectorOpIn,
+ Values: values,
+ }
+ matchExpressions = append(matchExpressions, requirement)
+ }
+
+ labelSelector := metav1.LabelSelector{MatchExpressions: matchExpressions}
Review Comment:
I opted for `MatchLabels` over `MatchExpressions` in the LabelSelector criteria. This choice enables us to select multiple label values and facilitates support for a `namespace_selector` with multiple values for the same label: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#resources-that-support-set-based-requirements
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] codecov-commenter commented on pull request #1994: Feature: namespace_selector support for having multiple values for the same label
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #1994:
URL: https://github.com/apache/apisix-ingress-controller/pull/1994#issuecomment-1741878483
## [Codecov](https://app.codecov.io/gh/apache/apisix-ingress-controller/pull/1994?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
> Merging [#1994](https://app.codecov.io/gh/apache/apisix-ingress-controller/pull/1994?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (55e7be3) into [master](https://app.codecov.io/gh/apache/apisix-ingress-controller/commit/d2b6f9325659514dd44415bb5d9c80178861f887?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (d2b6f93) will **increase** coverage by `0.06%`.
> The diff coverage is `90.00%`.
> :exclamation: Current head 55e7be3 differs from pull request most recent head 5821a0b. Consider uploading reports for the commit 5821a0b to get more accurate results
```diff
@@ Coverage Diff @@
## master #1994 +/- ##
==========================================
+ Coverage 36.87% 36.94% +0.06%
==========================================
Files 93 94 +1
Lines 7851 7861 +10
==========================================
+ Hits 2895 2904 +9
- Misses 4568 4569 +1
Partials 388 388
```
| [Files](https://app.codecov.io/gh/apache/apisix-ingress-controller/pull/1994?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [pkg/types/multi\_value\_labels.go](https://app.codecov.io/gh/apache/apisix-ingress-controller/pull/1994?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGtnL3R5cGVzL211bHRpX3ZhbHVlX2xhYmVscy5nbw==) | `90.00% <90.00%> (ø)` | |
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature: namespace_selector support for having multiple values for the same label [apisix-ingress-controller]
Posted by "vortegatorres (via GitHub)" <gi...@apache.org>.
vortegatorres commented on PR #1994:
URL: https://github.com/apache/apisix-ingress-controller/pull/1994#issuecomment-1853478154
> Closing this PR. I will create another one
@Revolyssup is it not possible to keep the same changes in this PR?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature: namespace_selector support for having multiple values for the same label [apisix-ingress-controller]
Posted by "tao12345666333 (via GitHub)" <gi...@apache.org>.
tao12345666333 commented on PR #1994:
URL: https://github.com/apache/apisix-ingress-controller/pull/1994#issuecomment-1761392513
let me re-run it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature: namespace_selector support for having multiple values for the same label [apisix-ingress-controller]
Posted by "tao12345666333 (via GitHub)" <gi...@apache.org>.
tao12345666333 commented on PR #1994:
URL: https://github.com/apache/apisix-ingress-controller/pull/1994#issuecomment-1763755014
It looks like this changes some behavior of the APISIX Ingress. I don't have time to deal with this recently, maybe @AlinsRan can take a look
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature: namespace_selector support for having multiple values for the same label [apisix-ingress-controller]
Posted by "vortegatorres (via GitHub)" <gi...@apache.org>.
vortegatorres commented on PR #1994:
URL: https://github.com/apache/apisix-ingress-controller/pull/1994#issuecomment-1743084226
> Thanks
>
> Please add an e2e test case to cover this feature.
@tao12345666333 I added the e2e test case in `test/e2e/suite-ingress/suite-ingress-features/namespace.go`. Please let me know if it looks good to you.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature: namespace_selector support for having multiple values for the same label [apisix-ingress-controller]
Posted by "vortegatorres (via GitHub)" <gi...@apache.org>.
vortegatorres commented on PR #1994:
URL: https://github.com/apache/apisix-ingress-controller/pull/1994#issuecomment-1756261172
> @vortegatorres Please merge the master branch . Let's make the CI happy first
Done!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature: namespace_selector support for having multiple values for the same label [apisix-ingress-controller]
Posted by "tao12345666333 (via GitHub)" <gi...@apache.org>.
tao12345666333 commented on PR #1994:
URL: https://github.com/apache/apisix-ingress-controller/pull/1994#issuecomment-1755758566
@vortegatorres Please merge the master branch . Let's make the CI happy first
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature: namespace_selector support for having multiple values for the same label [apisix-ingress-controller]
Posted by "lingsamuel (via GitHub)" <gi...@apache.org>.
lingsamuel commented on PR #1994:
URL: https://github.com/apache/apisix-ingress-controller/pull/1994#issuecomment-1764099183
I ran some failed tests (`suite-chore/endpoints.go`) locally and they passed normally. That's weird. I wll rerun this file to see if anything different.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org