Skip to content
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

fix(policy): use new compute for rules and fix rules intersect #12340

Merged
merged 13 commits into from
Jan 10, 2025

Conversation

Icarus9913
Copy link
Contributor

@Icarus9913 Icarus9913 commented Dec 19, 2024

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

Fix #12319
Fix #12273

Copy link
Contributor

Reviewer Checklist

🔍 Each of these sections need to be checked by the reviewer of the PR 🔍:
If something doesn't apply please check the box and add a justification if the reason is non obvious.

  • Is the PR title satisfactory? Is this part of a larger feature and should be grouped using > Changelog?
  • PR description is clear and complete. It Links to relevant issue as well as docs and UI issues
  • This will not break child repos: it doesn't hardcode values (.e.g "kumahq" as an image registry)
  • IPv6 is taken into account (.e.g: no string concatenation of host port)
  • Tests (Unit test, E2E tests, manual test on universal and k8s)
    • Don't forget ci/ labels to run additional/fewer tests
  • Does this contain a change that needs to be notified to users? In this case, UPGRADE.md should be updated.
  • Does it need to be backported according to the backporting policy? (this GH action will add "backport" label based on these file globs, if you want to prevent it from adding the "backport" label use no-backport-autolabel label)

Signed-off-by: Icarus Wu <[email protected]>
Copy link
Contributor

@lahabana lahabana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like there's a refactor/cleanup and a bug fix. Is it possible to separate both changes as it's hard to review otherwise

.golangci.yml Outdated Show resolved Hide resolved
pkg/plugins/policies/core/rules/rules.go Outdated Show resolved Hide resolved
@Icarus9913 Icarus9913 force-pushed the fix/wk/auto-reachable branch from b2c9c11 to 0516c46 Compare December 23, 2024 06:18
@Icarus9913 Icarus9913 added the ci/run-full-matrix PR: Runs all possible e2e test combination (expensive use carefully) label Dec 23, 2024
pkg/plugins/policies/core/rules/rules.go Outdated Show resolved Hide resolved
pkg/plugins/policies/core/rules/rules.go Outdated Show resolved Hide resolved
pkg/plugins/policies/core/rules/rules.go Outdated Show resolved Hide resolved
pkg/plugins/policies/core/rules/rules.go Outdated Show resolved Hide resolved
pkg/plugins/policies/meshtimeout/plugin/xds/configurer.go Outdated Show resolved Hide resolved
Signed-off-by: Icarus Wu <[email protected]>
Signed-off-by: Icarus Wu <[email protected]>
@Icarus9913 Icarus9913 marked this pull request as ready for review December 25, 2024 07:09
@Icarus9913 Icarus9913 requested a review from a team as a code owner December 25, 2024 07:09
@Icarus9913 Icarus9913 requested review from slonka and jakubdyszkiewicz and removed request for a team December 25, 2024 07:09
pkg/plugins/policies/core/rules/rules.go Outdated Show resolved Hide resolved
pkg/plugins/policies/core/rules/rules.go Outdated Show resolved Hide resolved
pkg/plugins/policies/core/rules/rules_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@lobkovilya lobkovilya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Icarus9913 Icarus9913 merged commit 3a00363 into kumahq:master Jan 10, 2025
25 checks passed
Icarus9913 added a commit to Icarus9913/kuma that referenced this pull request Jan 12, 2025
…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]>
Icarus9913 added a commit to Icarus9913/kuma that referenced this pull request Jan 12, 2025
…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]>
Icarus9913 added a commit to Icarus9913/kuma that referenced this pull request Jan 12, 2025
…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]>
Icarus9913 added a commit to Icarus9913/kuma that referenced this pull request Jan 12, 2025
…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]>
Icarus9913 added a commit to Icarus9913/kuma that referenced this pull request Jan 12, 2025
…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]>
Icarus9913 added a commit that referenced this pull request Jan 13, 2025
…ort of #12340) (#12515)

## 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`.

<!--
> 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)?
-->

## Backport

cherry-picked commit 3a00363

Signed-off-by: Icarus Wu <[email protected]>
Signed-off-by: Ilya Lobkov <[email protected]>
Co-authored-by: Ilya Lobkov <[email protected]>
Icarus9913 added a commit that referenced this pull request Jan 13, 2025
…ort of #12340) (#12516)

## 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`.

<!--
> 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)?
-->

## Backport

cherry-picked commit 3a00363

---------

Signed-off-by: Icarus Wu <[email protected]>
Signed-off-by: Ilya Lobkov <[email protected]>
Co-authored-by: Ilya Lobkov <[email protected]>
Icarus9913 added a commit that referenced this pull request Jan 13, 2025
…ort of #12340) (#12517)

## 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`.

<!--
> 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)?
-->

## Backport

cherry-picked commit 3a00363

---------

Signed-off-by: Icarus Wu <[email protected]>
Signed-off-by: Ilya Lobkov <[email protected]>
Co-authored-by: Ilya Lobkov <[email protected]>
Icarus9913 added a commit that referenced this pull request Jan 13, 2025
…ort of #12340) (#12518)

## 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`.

<!--
> 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)?
-->

## Backport

cherry-picked commit 3a00363

---------

Signed-off-by: Icarus Wu <[email protected]>
Signed-off-by: Ilya Lobkov <[email protected]>
Co-authored-by: Ilya Lobkov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport ci/run-full-matrix PR: Runs all possible e2e test combination (expensive use carefully)
Projects
None yet
4 participants