Skip to content

fix(status): omit waypoint in service dump when none is configured - #1915

Open
AswaniSahoo wants to merge 2 commits into
kmesh-net:mainfrom
AswaniSahoo:fix/status-waypoint-nil
Open

AswaniSahoo wants to merge 2 commits into
kmesh-net:mainfrom
AswaniSahoo:fix/status-waypoint-nil

Conversation

@AswaniSahoo

Copy link
Copy Markdown

What type of PR is this?

/kind bug

What this PR does / why we need it:

ConvertService always allocates a Waypoint, even when the service does not have one. The LoadBalancer branch three lines below already guards for the empty case, and ConvertWorkload uses omitempty for the same concept. So a service with neither currently dumps as:

"loadBalancer": null,
"waypoint": { "destination": "" }

Two optional fields, two different shapes. A client reading the dump cannot tell "no waypoint" from "a waypoint whose destination happens to be empty" without special-casing the empty string.

This guards the waypoint the same way s.LoadBalancing is guarded immediately below, so it serialises as null.

Also adds pkg/status/api_test.go, which the package did not have. It covers the three waypoint cases (absent, by address, by hostname), the resulting JSON shape, and the vips and loadBalancer conversion.

How I found it:

I was building an MCP client against /debug/config_dump/dual-engine and shaping test fixtures from the marshalled output. I wanted to list the services routed through a waypoint, checked for null, and got nothing back because every service had a waypoint object. Traced it to ConvertService.

Which issue(s) this PR fixes:

None, found while reading the code.

Special notes for your reviewer:

I could not run go test ./pkg/status/... locally. The package reaches the bpf2go packages that //go:embed the compiled .o artifacts, and those are not in the tree, so it does not build outside a full eBPF build. I checked the test's types, enum names and assertions against the real workloadapi types in a scratch harness and am relying on CI for the real run. Flagging it rather than implying I ran it.

If you would rather keep emitting the object for compatibility, I am happy to drop the api.go change and keep the tests documenting the current behaviour instead.

Does this PR introduce a user-facing change?:

The workload config dump now reports `"waypoint": null` for services that have no waypoint, instead of an object with an empty destination.

Copilot AI lite review requested due to automatic review settings August 13, 2026 02:33
@kmesh-bot kmesh-bot added the kind/bug Something isn't working label Aug 13, 2026
@kmesh-bot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign hzxuzhonghu for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kmesh-bot

Copy link
Copy Markdown
Collaborator

Welcome @AswaniSahoo! It looks like this is your first PR to kmesh-net/kmesh 🎉

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes the status API service conversion so that services with no configured waypoint marshal "waypoint": null (instead of a waypoint object with an empty destination), aligning the JSON shape with how loadBalancer is represented and avoiding ambiguous client-side interpretation.

Changes:

  • Update ConvertService to only allocate/set Service.Waypoint when a non-empty waypoint destination is present.
  • Add pkg/status/api_test.go to cover waypoint conversion cases and verify the resulting marshaled JSON shape (plus basic vips/loadBalancer conversion).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pkg/status/api.go Conditionally sets Waypoint only when a real destination is present, so JSON shows null when absent.
pkg/status/api_test.go Adds unit tests for waypoint conversion and JSON output shape for absent vs present waypoint.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/status/api_test.go
Comment on lines +99 to +101
assert.Contains(t, decoded, "waypoint")
assert.Nil(t, decoded["waypoint"])
assert.Nil(t, decoded["loadBalancer"])

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch. assert.Nil on a missing key passes for the wrong reason, so that test would have stayed green even if loadBalancer had been dropped entirely. Added the assert.Contains before it so presence is checked first, the same way the waypoint assertion above already does. Pushed in 6e45bea.

@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 39.68%. Comparing base (c6357aa) to head (21f90c1).
⚠️ Report is 14 commits behind head on main.

Files with missing lines Coverage Δ
pkg/status/api.go 91.15% <100.00%> (+6.22%) ⬆️

... and 3 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ec501a9...21f90c1. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI review requested due to automatic review settings August 15, 2026 11:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@AswaniSahoo

Copy link
Copy Markdown
Author

Saw this on a live cluster today, not just from reading ConvertService.

kind with istio in ambient mode and kmesh in dual-engine, using the published image. Three services, none of them with a waypoint or a load balancer configured:

istio-system/istiod    "waypoint": {"destination": ""}   "loadBalancer": null
kube-system/kube-dns   "waypoint": {"destination": ""}   "loadBalancer": null
default/kubernetes     "waypoint": {"destination": ""}   "loadBalancer": null

So every service on a default install carries the empty waypoint object, and a client still has to check for the empty string to know there is no waypoint.

Happy to share the setup if that is useful.

Copilot AI review requested due to automatic review settings August 24, 2026 16:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment thread pkg/status/api_test.go
Comment on lines +66 to +76
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
got := ConvertService(&workloadapi.Service{
Name: "productpage",
Namespace: "default",
Hostname: "productpage.default.svc.cluster.local",
Waypoint: tc.waypoint,
})
assert.Equal(t, tc.expect, got.Waypoint)
})
}
Comment thread pkg/status/api_test.go
// service without load balancing already serialises loadBalancer as null.
// Otherwise a consumer cannot tell "no waypoint" apart from "waypoint whose
// destination happens to be empty".
func TestConvertServiceOmitsEmptyWaypointInJSON(t *testing.T) {
Comment thread pkg/status/api_test.go
Comment on lines +93 to +97
data, err := json.Marshal(got)
assert.NoError(t, err)

var decoded map[string]interface{}
assert.NoError(t, json.Unmarshal(data, &decoded))
Signed-off-by: AswaniSahoo <aswanisahoo1012@gmail.com>
…it is null

Signed-off-by: AswaniSahoo <aswanisahoo1012@gmail.com>
@AswaniSahoo

Copy link
Copy Markdown
Author

@hzxuzhonghu @Okabe-Rintarou-0

Could you please take a look at this PR when you get a chance?

Regarding the single failing CI check (E2E Test(istio 1.28)): the failure was TestMixNsAndServiceWaypoint timing out on pod startup (container not found ("sleep")), while the same test passed cleanly on Istio 1.26, 1.27, and all IPv6 matrix runs. This PR only touches pkg/status/api.go and its unit tests to format absent waypoints as null, so the failure is unrelated.

Could you please trigger a /retest and review when convenient? Thanks!

@AswaniSahoo

Copy link
Copy Markdown
Author

@hzxuzhonghu @Okabe-Rintarou-0

Could you please take a look at this PR when you get a chance?

Regarding the single failing CI check (E2E Test(istio 1.28)): the failure was TestMixNsAndServiceWaypoint timing out on pod startup (container not found ("sleep")), while the same test passed cleanly on Istio 1.26, 1.27, and all IPv6 matrix runs. This PR only touches pkg/status/api.go and its unit tests to format absent waypoints as null, so the failure is unrelated.

Could you please trigger a /retest and review when convenient? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants