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(api-server): add format and include_eds to admin api #9814

Merged
merged 4 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
337 changes: 214 additions & 123 deletions api/mesh/v1alpha1/kds.pb.go

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions api/mesh/v1alpha1/kds.proto
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ message XDSConfigRequest {
// Mesh of the resource on which we execute config dump. Should be empty for
// ZoneIngress, ZoneEgress.
string resource_mesh = 4;
// whether we include eds or not
bool include_eds = 5;
}

// XDSConfigRequest is a response containing result of XDS Config Dump execution
Expand Down Expand Up @@ -112,6 +114,8 @@ message StatsRequest {
// Mesh of the resource on which we execute kuma-dp stats request.
// Should be empty for ZoneIngress, ZoneEgress.
string resource_mesh = 4;
// format is the format in which we return the clusters.
AdminOutputFormat format = 5;
}

// StatsResponse is a response containing result of kuma-dp stats execution on
Expand Down Expand Up @@ -143,6 +147,13 @@ message ClustersRequest {
// Mesh of the resource on which we execute kuma-dp clusters request.
// Should be empty for ZoneIngress, ZoneEgress.
string resource_mesh = 4;
// format is the format in which we return the clusters.
AdminOutputFormat format = 5;
}

enum AdminOutputFormat {
TEXT = 0;
JSON = 1;
}

// ClustersResponse is a response containing result of kuma-dp clusters
Expand Down
17 changes: 17 additions & 0 deletions docs/generated/raw/protos/ClustersRequest.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@
"resource_mesh": {
"type": "string",
"description": "Mesh of the resource on which we execute kuma-dp clusters request. Should be empty for ZoneIngress, ZoneEgress."
},
"format": {
"enum": [
"TEXT",
0,
"JSON",
1
],
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
],
"title": "Admin Output Format"
}
},
"additionalProperties": true,
Expand Down
17 changes: 17 additions & 0 deletions docs/generated/raw/protos/StatsRequest.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@
"resource_mesh": {
"type": "string",
"description": "Mesh of the resource on which we execute kuma-dp stats request. Should be empty for ZoneIngress, ZoneEgress."
},
"format": {
"enum": [
"TEXT",
0,
"JSON",
1
],
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
],
"title": "Admin Output Format"
}
},
"additionalProperties": true,
Expand Down
4 changes: 4 additions & 0 deletions docs/generated/raw/protos/XDSConfigRequest.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"resource_mesh": {
"type": "string",
"description": "Mesh of the resource on which we execute config dump. Should be empty for ZoneIngress, ZoneEgress."
},
"include_eds": {
"type": "boolean",
"description": "whether we include eds or not"
}
},
"additionalProperties": true,
Expand Down
49 changes: 46 additions & 3 deletions pkg/api-server/inspect_endpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ var _ = Describe("Inspect WS", func() {
resources []core_model.Resource
global bool
contentType string
query string
}
AfterEach(func() {
core.Now = time.Now
Expand Down Expand Up @@ -98,9 +99,10 @@ var _ = Describe("Inspect WS", func() {

// when
resp, err := http.Get((&url.URL{
Scheme: "http",
Host: apiServer.Address(),
Path: given.path,
Scheme: "http",
Host: apiServer.Address(),
Path: given.path,
RawQuery: given.query,
}).String())
Expect(err).ToNot(HaveOccurred())

Expand Down Expand Up @@ -813,6 +815,16 @@ var _ = Describe("Inspect WS", func() {
},
contentType: restful.MIME_JSON,
}),
Entry("inspect xds for dataplane with eds", testCase{
path: "/meshes/mesh-1/dataplanes/backend-1/xds",
query: "include_eds=true",
matcher: matchers.MatchGoldenJSON(path.Join("testdata", "inspect_xds_dataplane_with_eds.json")),
resources: []core_model.Resource{
builders.Mesh().WithName("mesh-1").Build(),
builders.Dataplane().WithName("backend-1").WithAddress("1.1.1.1").WithMesh("mesh-1").WithAdminPort(3301).WithServices("backend").AddOutboundsToServices("redis", "elastic", "web").Build(),
},
contentType: restful.MIME_JSON,
}),
Entry("inspect xds for local zone ingress", testCase{
path: "/zoneingresses/zi-1/xds",
matcher: matchers.MatchGoldenJSON(path.Join("testdata", "inspect_xds_local_zoneingress.json")),
Expand Down Expand Up @@ -889,6 +901,16 @@ var _ = Describe("Inspect WS", func() {
},
contentType: "text/plain",
}),
Entry("inspect stats for dataplane as json", testCase{
path: "/meshes/mesh-1/dataplanes/backend-1/stats",
query: "format=json",
matcher: matchers.MatchGoldenEqual(path.Join("testdata", "inspect_stats_dataplane.json")),
resources: []core_model.Resource{
builders.Mesh().WithName("mesh-1").Build(),
builders.Dataplane().WithName("backend-1").WithMesh("mesh-1").WithAdminPort(3301).WithServices("backend").AddOutboundsToServices("redis", "elastic", "web").Build(),
},
contentType: restful.MIME_JSON,
}),
Entry("inspect clusters for dataplane", testCase{
path: "/meshes/mesh-1/dataplanes/backend-1/clusters",
matcher: matchers.MatchGoldenEqual(path.Join("testdata", "inspect_clusters_dataplane.out")),
Expand All @@ -898,6 +920,27 @@ var _ = Describe("Inspect WS", func() {
},
contentType: "text/plain",
}),
Entry("inspect clusters for dataplane as json", testCase{
path: "/meshes/mesh-1/dataplanes/backend-1/clusters",
query: "format=json",
matcher: matchers.MatchGoldenEqual(path.Join("testdata", "inspect_clusters_dataplane.json")),
resources: []core_model.Resource{
builders.Mesh().WithName("mesh-1").Build(),
builders.Dataplane().WithName("backend-1").WithMesh("mesh-1").WithAdminPort(3301).WithServices("backend").AddOutboundsToServices("redis", "elastic", "web").Build(),
},
contentType: restful.MIME_JSON,
}),
Entry("inspect invalid admin type for dataplane", testCase{
path: "/meshes/mesh-1/dataplanes/backend-1/notAType",
query: "format=json",
matcher: matchers.MatchGoldenEqual(path.Join("testdata", "inspect_dataplanes.invalid_admin.json")),
resources: []core_model.Resource{
builders.Mesh().WithName("mesh-1").Build(),
builders.Dataplane().WithName("backend-1").WithMesh("mesh-1").WithAdminPort(3301).WithServices("backend").AddOutboundsToServices("redis", "elastic", "web").Build(),
},
contentType: restful.MIME_JSON,
}),

Entry("inspect rules empty", testCase{
path: "/meshes/default/dataplanes/web-01/rules",
matcher: matchers.MatchGoldenJSON(path.Join("testdata", "inspect_dataplane_rules_empty.golden.json")),
Expand Down
Loading
Loading