-
Notifications
You must be signed in to change notification settings - Fork 336
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
The virtual_domains not generated correctly with AUTO_REACHABLE_SERVICES and MeshTrafficPermission #12273
Comments
I created one PR to build the local test: #12274 The direct problem here is:
|
I read the codes and found in rules.go, we'll assemble all of the MTPs tags then we'll have subsets as:
But we'll return false due to this judgement: kuma/pkg/plugins/policies/core/rules/rules.go Lines 143 to 147 in 8659306
|
Here's my humble workaround but not sure if it's correct: // IsSubset returns true if 'other' is a subset of the current set.
// Empty set is a superset for all subsets.
func (ss Subset) IsSubset(other Subset) bool {
if len(ss) == 0 {
return true
}
if len(other) == 0 {
return false
}
otherByKeys := map[string][]Tag{}
for _, t := range other {
otherByKeys[t.Key] = append(otherByKeys[t.Key], t)
}
noMatchedCount := 0
for _, tag := range ss {
oTags, ok := otherByKeys[tag.Key]
if !ok {
noMatchedCount++
continue
//return false
}
for _, otherTag := range oTags {
if !isSubset(tag, otherTag) {
return false
}
}
}
if noMatchedCount == len(ss) {
return false
}
return true
} |
I think the method
We need to rewrite the method The semantic of set1 := map[string]string{
"key1": "value1",
"key2": "value2",
}
set2 := map[string]string{
"key1": "value1",
}
fmt.Println(set1.IsSubset(set2)) // false but set1 := map[string]string{
"key1": "value1",
"key2": "value2",
}
point := map[string]string{
"key1": "value1",
}
fmt.Println(set1.IsPointInSet(point)) // true |
fyi I think this issue is about the same thing #8155 |
|
So is this issue a dupe of #8155? |
Yeah, I think so |
…q#12340) ## Motivation 1. When I went through the policy matching subset `Intersect` method, I found the behavior is incorrect with one case 2. Rewrite the rule's `Compute` method to use the new `ContainsElement` method instead of using the old `IsSubset` method ## Implementation information Introduce one new type `type Element map[string]string` for differentiation by `IsSubset`. ## Supporting documentation <!-- Is there a MADR? An Issue? A related PR? --> Fix kumahq#12319 Fix kumahq#12273 <!-- > Changelog: skip --> <!-- Uncomment the above section to explicitly set a [`> Changelog:` entry here](https://github.com/kumahq/kuma/blob/master/CONTRIBUTING.md#submitting-a-patch)? --> --------- Signed-off-by: Icarus Wu <[email protected]> Signed-off-by: Ilya Lobkov <[email protected]> Co-authored-by: Ilya Lobkov <[email protected]>
…ort of kumahq#12340) 1. When I went through the policy matching subset `Intersect` method, I found the behavior is incorrect with one case 2. Rewrite the rule's `Compute` method to use the new `ContainsElement` method instead of using the old `IsSubset` method Introduce one new type `type Element map[string]string` for differentiation by `IsSubset`. <!-- Is there a MADR? An Issue? A related PR? --> Fix kumahq#12319 Fix kumahq#12273 <!-- > Changelog: skip --> <!-- Uncomment the above section to explicitly set a [`> Changelog:` entry here](https://github.com/kumahq/kuma/blob/master/CONTRIBUTING.md#submitting-a-patch)? --> --------- Signed-off-by: Icarus Wu <[email protected]> Signed-off-by: Ilya Lobkov <[email protected]> Co-authored-by: Ilya Lobkov <[email protected]>
…q#12340) 1. When I went through the policy matching subset `Intersect` method, I found the behavior is incorrect with one case 2. Rewrite the rule's `Compute` method to use the new `ContainsElement` method instead of using the old `IsSubset` method Introduce one new type `type Element map[string]string` for differentiation by `IsSubset`. <!-- Is there a MADR? An Issue? A related PR? --> Fix kumahq#12319 Fix kumahq#12273 <!-- > Changelog: skip --> <!-- Uncomment the above section to explicitly set a [`> Changelog:` entry here](https://github.com/kumahq/kuma/blob/master/CONTRIBUTING.md#submitting-a-patch)? --> --------- Signed-off-by: Icarus Wu <[email protected]> Signed-off-by: Ilya Lobkov <[email protected]> Co-authored-by: Ilya Lobkov <[email protected]>
…ort of kumahq#12340) 1. When I went through the policy matching subset `Intersect` method, I found the behavior is incorrect with one case 2. Rewrite the rule's `Compute` method to use the new `ContainsElement` method instead of using the old `IsSubset` method Introduce one new type `type Element map[string]string` for differentiation by `IsSubset`. <!-- Is there a MADR? An Issue? A related PR? --> Fix kumahq#12319 Fix kumahq#12273 <!-- > Changelog: skip --> <!-- Uncomment the above section to explicitly set a [`> Changelog:` entry here](https://github.com/kumahq/kuma/blob/master/CONTRIBUTING.md#submitting-a-patch)? --> --------- Signed-off-by: Icarus Wu <[email protected]> Signed-off-by: Ilya Lobkov <[email protected]> Co-authored-by: Ilya Lobkov <[email protected]>
…ort of kumahq#12340) 1. When I went through the policy matching subset `Intersect` method, I found the behavior is incorrect with one case 2. Rewrite the rule's `Compute` method to use the new `ContainsElement` method instead of using the old `IsSubset` method Introduce one new type `type Element map[string]string` for differentiation by `IsSubset`. <!-- Is there a MADR? An Issue? A related PR? --> Fix kumahq#12319 Fix kumahq#12273 <!-- > Changelog: skip --> <!-- Uncomment the above section to explicitly set a [`> Changelog:` entry here](https://github.com/kumahq/kuma/blob/master/CONTRIBUTING.md#submitting-a-patch)? --> --------- Signed-off-by: Icarus Wu <[email protected]> Signed-off-by: Ilya Lobkov <[email protected]> Co-authored-by: Ilya Lobkov <[email protected]>
What happened?
version:
2.9.2
What happened?
I eanbled the
AUTO_REACHABLE_SERVICES
feature and create 2 MTPs and found the virtual_domains was not generate correctly from the XDS configurationSteps to reproduce
2.9.2
KUMA_EXPERIMENTAL_AUTO_REACHABLE_SERVICES
Result
XDS configurations:
The text was updated successfully, but these errors were encountered: