Skip to content

Commit dc10042

Browse files
kumahq[bot]lukidzilobkovilya
authored
perf(rules): add withNegation flag to simplify to policy flow (backport of #13151) (#13194)
Automatic cherry-pick of #13151 for branch release-2.9 Generated by [action](https://github.com/kumahq/kuma/actions/runs/14056954185) cherry-picked commit c3781d4 ⚠️ ⚠️ ⚠️ Conflicts happened when cherry-picking! ⚠️ ⚠️ ⚠️ ``` On branch release-2.9 Your branch is up to date with 'origin/release-2.9'. You are currently cherry-picking commit c3781d4. (fix conflicts and run "git cherry-pick --continue") (use "git cherry-pick --skip" to skip this patch) (use "git cherry-pick --abort" to cancel the cherry-pick operation) Changes to be committed: modified: pkg/api-server/testdata/resources/inspect/dataplanes/_rules/overriding_meshtimeout.golden.json modified: pkg/api-server/testdata/resources/inspect/dataplanes/_rules/resource_rule_meshtimeout_index.golden.json modified: pkg/plugins/policies/core/matchers/egress.go modified: pkg/plugins/policies/core/matchers/testdata/matchedpolicies/torules/03.golden.yaml modified: pkg/plugins/policies/core/matchers/testdata/matchedpolicies/torules/03.policies.yaml modified: pkg/plugins/policies/core/rules/testdata/rules/to/meshtimeout.golden.yaml modified: pkg/plugins/policies/core/rules/testdata/rules/to/single-to.golden.yaml Unmerged paths: (use "git add/rm <file>..." as appropriate to mark resolution) both modified: pkg/api-server/testdata/resources/inspect/dataplanes/_rules/meshhttproute.golden.json both modified: pkg/plugins/policies/core/rules/rules.go deleted by us: pkg/plugins/policies/core/rules/subsetutils/subset.go ``` --------- Signed-off-by: Ilya Lobkov <[email protected]> Signed-off-by: Lukasz Dziedziak <[email protected]> Co-authored-by: Lukasz Dziedziak <[email protected]> Co-authored-by: Ilya Lobkov <[email protected]>
1 parent 1f0bf62 commit dc10042

File tree

11 files changed

+232
-179
lines changed

11 files changed

+232
-179
lines changed

pkg/api-server/testdata/resources/inspect/dataplanes/_rules/meshhttproute.golden.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@
3939
"backendRefs": [
4040
{
4141
"kind": "MeshServiceSubset",
42-
"name": "backend_kuma-demo_svc_3001",
42+
"name": "other-svc",
43+
"tags": {
44+
"version": "1.0"
45+
}
46+
},
47+
{
48+
"kind": "MeshServiceSubset",
49+
"name": "other-svc-2",
4350
"tags": {
4451
"version": "1.0"
4552
}
@@ -53,14 +60,14 @@
5360
{
5461
"key": "kuma.io/service",
5562
"not": false,
56-
"value": "backend_kuma-demo_svc_3001"
63+
"value": "other-svc"
5764
}
5865
],
5966
"origin": [
6067
{
6168
"labels": {},
6269
"mesh": "default",
63-
"name": "the-http-route",
70+
"name": "the-other-http-route",
6471
"type": "MeshHTTPRoute"
6572
}
6673
]
@@ -81,14 +88,7 @@
8188
"backendRefs": [
8289
{
8390
"kind": "MeshServiceSubset",
84-
"name": "other-svc",
85-
"tags": {
86-
"version": "1.0"
87-
}
88-
},
89-
{
90-
"kind": "MeshServiceSubset",
91-
"name": "other-svc-2",
91+
"name": "backend_kuma-demo_svc_3001",
9292
"tags": {
9393
"version": "1.0"
9494
}
@@ -102,14 +102,14 @@
102102
{
103103
"key": "kuma.io/service",
104104
"not": false,
105-
"value": "other-svc"
105+
"value": "backend_kuma-demo_svc_3001"
106106
}
107107
],
108108
"origin": [
109109
{
110110
"labels": {},
111111
"mesh": "default",
112-
"name": "the-other-http-route",
112+
"name": "the-http-route",
113113
"type": "MeshHTTPRoute"
114114
}
115115
]

pkg/api-server/testdata/resources/inspect/dataplanes/_rules/overriding_meshtimeout.golden.json

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,18 +144,7 @@
144144
"requestTimeout": "10s"
145145
}
146146
},
147-
"matchers": [
148-
{
149-
"key": "kuma.io/service",
150-
"not": true,
151-
"value": "bar"
152-
},
153-
{
154-
"key": "kuma.io/service",
155-
"not": true,
156-
"value": "foo"
157-
}
158-
],
147+
"matchers": [],
159148
"origin": [
160149
{
161150
"labels": {},

pkg/api-server/testdata/resources/inspect/dataplanes/_rules/resource_rule_meshtimeout_index.golden.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@
4545
"toRules": [
4646
{
4747
"conf": {
48-
"connectionTimeout": "7s",
49-
"idleTimeout": "7s",
48+
"connectionTimeout": "5s",
49+
"idleTimeout": "5s",
5050
"http": {
51-
"requestTimeout": "7s"
51+
"requestTimeout": "5s"
5252
}
5353
},
5454
"matchers": [
5555
{
5656
"key": "kuma.io/service",
5757
"not": false,
58-
"value": "backend-4"
58+
"value": ""
5959
}
6060
],
6161
"origin": [
@@ -69,17 +69,17 @@
6969
},
7070
{
7171
"conf": {
72-
"connectionTimeout": "5s",
73-
"idleTimeout": "5s",
72+
"connectionTimeout": "7s",
73+
"idleTimeout": "7s",
7474
"http": {
75-
"requestTimeout": "5s"
75+
"requestTimeout": "7s"
7676
}
7777
},
7878
"matchers": [
7979
{
8080
"key": "kuma.io/service",
8181
"not": false,
82-
"value": ""
82+
"value": "backend-4"
8383
}
8484
],
8585
"origin": [

pkg/plugins/policies/core/matchers/egress.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func processToRules(tags map[string]string, policies []core_model.Resource) (cor
173173
}
174174
}
175175

176-
rules, err := core_rules.BuildRules(toList)
176+
rules, err := core_rules.BuildRules(toList, false)
177177
if err != nil {
178178
return core_rules.FromRules{}, err
179179
}

pkg/plugins/policies/core/matchers/testdata/matchedpolicies/torules/03.golden.yaml

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Rules:
88
- creationTime: "0001-01-01T00:00:00Z"
99
mesh: mesh-1
1010
modificationTime: "0001-01-01T00:00:00Z"
11-
name: mtp-2
11+
name: mtp-3
1212
type: MeshTimeout
1313
- creationTime: "0001-01-01T00:00:00Z"
1414
mesh: mesh-1
@@ -25,12 +25,12 @@ Rules:
2525
- BackendRefOriginIndex: {}
2626
Conf:
2727
http:
28-
requestTimeout: 3s
28+
requestTimeout: 2s
2929
Origin:
3030
- creationTime: "0001-01-01T00:00:00Z"
3131
mesh: mesh-1
3232
modificationTime: "0001-01-01T00:00:00Z"
33-
name: mtp-2
33+
name: mtp-3
3434
type: MeshTimeout
3535
Subset:
3636
- Key: __rule-matches-hash__
@@ -39,37 +39,3 @@ Rules:
3939
- Key: kuma.io/service
4040
Not: false
4141
Value: test-server
42-
- BackendRefOriginIndex: {}
43-
Conf:
44-
http:
45-
requestTimeout: 3s
46-
Origin:
47-
- creationTime: "0001-01-01T00:00:00Z"
48-
mesh: mesh-1
49-
modificationTime: "0001-01-01T00:00:00Z"
50-
name: mtp-2
51-
type: MeshTimeout
52-
Subset:
53-
- Key: __rule-matches-hash__
54-
Not: false
55-
Value: JNNc6//C3P17nUsOJm5f4kqG+U3v8pXhS0od9C3+oss=
56-
- Key: kuma.io/service
57-
Not: true
58-
Value: test-server
59-
- BackendRefOriginIndex: {}
60-
Conf:
61-
http:
62-
requestTimeout: 3s
63-
Origin:
64-
- creationTime: "0001-01-01T00:00:00Z"
65-
mesh: mesh-1
66-
modificationTime: "0001-01-01T00:00:00Z"
67-
name: mtp-2
68-
type: MeshTimeout
69-
Subset:
70-
- Key: __rule-matches-hash__
71-
Not: true
72-
Value: JNNc6//C3P17nUsOJm5f4kqG+U3v8pXhS0od9C3+oss=
73-
- Key: kuma.io/service
74-
Not: true
75-
Value: test-server

pkg/plugins/policies/core/matchers/testdata/matchedpolicies/torules/03.policies.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,16 @@ spec:
4343
default:
4444
http:
4545
requestTimeout: 3s
46+
type: MeshTimeout
47+
mesh: mesh-1
48+
name: mtp-3
49+
spec:
50+
targetRef:
51+
kind: Mesh
52+
to:
53+
- targetRef:
54+
kind: MeshService
55+
name: test-server
56+
default:
57+
http:
58+
requestTimeout: 2s

0 commit comments

Comments
 (0)