Skip to content

fix: kmeshctl version exits 0 even when pod version fetch fails - #1872

Open
bhumikadangayach wants to merge 3 commits into
kmesh-net:mainfrom
bhumikadangayach:fix/version-exit-code
Open

bhumikadangayach wants to merge 3 commits into
kmesh-net:mainfrom
bhumikadangayach:fix/version-exit-code

Conversation

@bhumikadangayach

Copy link
Copy Markdown

Fixes #1871

kmeshctl version was exiting 0 even when the version fetch failed. getVersion() only returned version.Info with no error, so callers had no way to detect failure - they just checked if v.GitVersion was empty, which is indistinguishable from a real failure.

Added an error return to getVersion(), set it at every failure point inside the function, and updated both call sites in runVersion() to check it: the single-pod case now exits 1 on failure (matching the existing len(args) == 0 branch's behavior), and the multi-pod loop skips a pod on failure instead of silently counting it as empty.

Verified: kmeshctl version now exits 1 instead of 0.

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@kmesh-bot
kmesh-bot requested review from YaoZengzeng and nlgwcy August 4, 2026 19:54
@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 supercharge-xsy 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

@codecov

codecov Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 39.62%. Comparing base (09e96d3) to head (2bb213b).
⚠️ Report is 3 commits behind head on main.
see 2 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 60881fc...2bb213b. Read the comment docs.

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

@bhumikadangayach

Copy link
Copy Markdown
Author

Hi @LiZhenCheng9527 — this has been open a few weeks, CI is green, no outstanding comments. Could you take a look when you get a chance?

Comment thread ctl/version/version.go

if err := json.Unmarshal(body, &version); err != nil {
log.Errorf("failed to unmarshal version info: %v", err)
if uerr := json.Unmarshal(body, &version); uerr != nil {

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.

Even if the JSON is parsed correctly, there is no guarantee that the version data is valid.

Signed-off-by: Bhumika Dangayach <139267865+bhumikadangayach@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kmeshctl version exits 0 even when pod version fetch fails

3 participants