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

feat(kuma-cp): top-level MeshHTTPRoute targetRef for MeshTimeout #7016

Merged
merged 27 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ec34735
feat(kuma-cp): add new MeshHTTPRoute kind for TargetRef
lobkovilya Jun 6, 2023
3538803
chore(kuma-cp): move Rules/Merge code out of the 'core_xds'
lobkovilya Jun 6, 2023
517730f
chore(kuma-cp): fix imports in tests
lobkovilya Jun 6, 2023
7c6fff4
chore(kuma-cp): cleanup generate.mk
lobkovilya Jun 6, 2023
023b599
Merge branch 'master' into chore/move-dirs-around
lobkovilya Jun 6, 2023
a4df668
fix imports
lobkovilya Jun 6, 2023
27fd2d5
make check
lobkovilya Jun 6, 2023
1603ce1
Merge branch 'chore/move-dirs-around' into feat/target-mhr-in-top-level
lobkovilya Jun 7, 2023
f213057
feat(kuma-cp): optimize BuildRules algo
lobkovilya Jun 8, 2023
6fe7e97
make check
lobkovilya Jun 8, 2023
e155186
use Intersect method
lobkovilya Jun 8, 2023
d9e54b9
fix sorting
lobkovilya Jun 8, 2023
550bdfa
Merge branch 'feat/improve-rules-algo' into feat/target-mhr-in-top-level
lobkovilya Jun 8, 2023
662cebf
rule aglo to support MeshHTTPRoute
lobkovilya Jun 9, 2023
4f3304c
make check
lobkovilya Jun 9, 2023
b1da534
update golden files
lobkovilya Jun 9, 2023
4018bce
remove kind MeshGatewayRoute from crds
lobkovilya Jun 9, 2023
80765cd
replace encoding/gob with encoding/json
lobkovilya Jun 9, 2023
4477ac8
Merge branch 'master' into feat/target-mhr-in-top-level
lobkovilya Jun 12, 2023
9861dda
update golden files
lobkovilya Jun 12, 2023
710e1ca
update golden files
lobkovilya Jun 12, 2023
015db8e
Merge branch 'master' into feat/target-mhr-in-top-level
lobkovilya Jun 13, 2023
6ae055f
update golden files
lobkovilya Jun 13, 2023
a7872f6
move MeshTimeout configuration to another PR
lobkovilya Jun 13, 2023
883af2f
feat(kuma-cp): support MeshHTTPRoute top-level TR for MeshTimeout
lobkovilya Jun 13, 2023
0ee9472
Merge branch 'master' into feat/mhr-tf-for-meshtimeout
lobkovilya Jun 14, 2023
ca184f0
sort nodes in each graph's component
lobkovilya Jun 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions pkg/plugins/policies/core/matchers/dataplane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,39 @@ var _ = Describe("MatchedPolicies", func() {
generateTableEntries(filepath.Join("testdata", "matchedpolicies", "fromrules")),
)

DescribeTable("should return ToRules",
func(given testCase) {
// given DPP resource
dpp := readDPP(given.dppFile)

// given policies
resources, resTypes := readPolicies(given.policiesFile)

// we're expecting all policies in the file to have the same type or to be mixed with MeshHTTPRoutes
Expect(resTypes).To(Or(HaveLen(1), HaveLen(2)))

var resType core_model.ResourceType
switch {
case len(resTypes) == 1:
resType = resTypes[0]
case len(resTypes) == 2 && resTypes[1] == v1alpha1.MeshHTTPRouteType:
resType = resTypes[0]
case len(resTypes) == 2 && resTypes[0] == v1alpha1.MeshHTTPRouteType:
resType = resTypes[1]
}

// when
policies, err := matchers.MatchedPolicies(resType, dpp, resources)
Expect(err).ToNot(HaveOccurred())

// then
bytes, err := yaml.Marshal(policies.ToRules)
Expect(err).ToNot(HaveOccurred())
Expect(bytes).To(test_matchers.MatchGoldenYAML(given.goldenFile))
},
generateTableEntries(filepath.Join("testdata", "matchedpolicies", "torules")),
)

DescribeTable("should match MeshGateways",
func(given testCase) {
dpp := readDPP(given.dppFile)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
type: Dataplane
mesh: mesh-1
name: dp-1
networking:
address: 1.1.1.1
inbound:
- port: 8080
tags:
kuma.io/service: web
version: v1
team: mesh
- port: 8081
tags:
kuma.io/service: web-api
version: v1
team: mesh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
items:
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: mtp-1
spec:
targetRef:
kind: MeshHTTPRoute
name: http-route-1
to:
- default:
http:
requestTimeout: 3s
targetRef:
kind: Mesh
type: MeshTimeout
next: null
total: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# mtp-1 should select DPP because it targets MeshHTTPRoute that selects the DPP
type: MeshTimeout
mesh: mesh-1
name: mtp-1
spec:
targetRef:
kind: MeshHTTPRoute
name: http-route-1
to:
- targetRef:
kind: Mesh
default:
http:
requestTimeout: 3s
---
type: MeshHTTPRoute
mesh: mesh-1
name: http-route-1
spec:
targetRef:
kind: MeshService
name: web-api
to:
- targetRef:
kind: MeshService
name: test-server
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
type: Dataplane
mesh: mesh-1
name: dp-1
networking:
address: 1.1.1.1
inbound:
- port: 8080
tags:
kuma.io/service: web
version: v1
team: mesh
- port: 8081
tags:
kuma.io/service: web-api
version: v1
team: mesh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Rules:
- Conf:
http:
requestTimeout: 3s
Origin:
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: mtp-1
type: MeshTimeout
Subset:
- Key: __rule-matches-hash__
Not: false
Value: OTqJZOueoDIMeYnpSETLYoaD2htefPQ7CcHHRBgrODk=
- Key: kuma.io/service
Not: false
Value: another-test-server
- Conf:
http:
requestTimeout: 3s
Origin:
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: mtp-1
type: MeshTimeout
Subset:
- Key: __rule-matches-hash__
Not: false
Value: JNNc6//C3P17nUsOJm5f4kqG+U3v8pXhS0od9C3+oss=
- Key: kuma.io/service
Not: false
Value: test-server
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
type: MeshHTTPRoute
mesh: mesh-1
name: http-route-1
spec:
targetRef:
kind: MeshService
name: web-api
to:
- targetRef:
kind: MeshService
name: test-server
rules:
- matches:
- path:
type: Exact
value: /
default: {}
- targetRef:
kind: MeshService
name: another-test-server
rules:
- matches:
- path:
type: PathPrefix
value: /v1
- method: POST
default: {}
---
# mtp-1 should select DPP because it targets MeshHTTPRoute that selects the DPP
type: MeshTimeout
mesh: mesh-1
name: mtp-1
spec:
targetRef:
kind: MeshHTTPRoute
name: http-route-1
to:
- targetRef:
kind: Mesh
default:
http:
requestTimeout: 3s

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
type: Dataplane
mesh: mesh-1
name: dp-1
networking:
address: 1.1.1.1
inbound:
- port: 8080
tags:
kuma.io/service: web
version: v1
team: mesh
- port: 8081
tags:
kuma.io/service: web-api
version: v1
team: mesh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Rules:
- Conf:
http:
requestTimeout: 1s
Origin:
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: mtp-1
type: MeshTimeout
Subset:
- Key: __rule-matches-hash__
Not: false
Value: OTqJZOueoDIMeYnpSETLYoaD2htefPQ7CcHHRBgrODk=
- Key: kuma.io/service
Not: false
Value: another-test-server
- Conf:
http:
requestTimeout: 3s
Origin:
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: mtp-1
type: MeshTimeout
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: mtp-2
type: MeshTimeout
Subset:
- Key: __rule-matches-hash__
Not: false
Value: JNNc6//C3P17nUsOJm5f4kqG+U3v8pXhS0od9C3+oss=
- Key: kuma.io/service
Not: false
Value: test-server
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
type: MeshHTTPRoute
mesh: mesh-1
name: http-route-1
spec:
targetRef:
kind: MeshService
name: web-api
to:
- targetRef:
kind: MeshService
name: test-server
rules:
- matches:
- path:
type: Exact
value: /
default: {}
- targetRef:
kind: MeshService
name: another-test-server
rules:
- matches:
- path:
type: PathPrefix
value: /v1
- method: POST
default: {}
---
type: MeshHTTPRoute
mesh: mesh-1
name: http-route-2
spec:
targetRef:
kind: MeshService
name: web-api
to:
- targetRef:
kind: MeshService
name: test-server
rules:
- matches:
- path:
type: Exact
value: /
default: {}
---
# mtp-1 should select DPP because it targets MeshHTTPRoute that selects the DPP
type: MeshTimeout
mesh: mesh-1
name: mtp-1
spec:
targetRef:
kind: MeshHTTPRoute
name: http-route-1
to:
- targetRef:
kind: Mesh
default:
http:
requestTimeout: 1s
---
type: MeshTimeout
mesh: mesh-1
name: mtp-2
spec:
targetRef:
kind: MeshHTTPRoute
name: http-route-2
to:
- targetRef:
kind: Mesh
default:
http:
requestTimeout: 3s
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
type: Dataplane
mesh: mesh-1
name: dp-1
networking:
address: 1.1.1.1
inbound:
- port: 8080
tags:
kuma.io/service: web
version: v1
team: mesh
- port: 8081
tags:
kuma.io/service: web-api
version: v1
team: mesh
Loading