Skip to content

fix(cmd): add stop subcommand to check preflight, trim volume, and get replica - #583

Open
kiusys-mstreitenberger wants to merge 2 commits into
longhorn:masterfrom
kiusys-mstreitenberger:9311-stop-subcommands
Open

kiusys-mstreitenberger wants to merge 2 commits into
longhorn:masterfrom
kiusys-mstreitenberger:9311-stop-subcommands

Conversation

@kiusys-mstreitenberger

Copy link
Copy Markdown

Which issue(s) this PR fixes:

Issue longhorn/longhorn#9311

What this PR does / why we need it:

A stop command has been added to check preflight, trim volume, and get replica.
checksum was deliberately excluded: its Cleanup() is a no-op, as it merely
updates the Volume CR directly and does not create any cluster resources that
could become orphaned.

Special notes for your reviewer:

  • Each stop command follows the exact pattern of export replica stop.
  • None of the three new commands requires a parent flag to remain visible in stop
  • Manually validated: I interrupted each parent command mid-execution, confirmed that the DaemonSet/RBAC resources were left orphaned, and then verified that the new stop command removes them.

Additional documentation or context

…t replica

Mirrors the existing install preflight stop / export replica stop
pattern. If one of these commands is interrupted before its PostRun
cleanup runs, the DaemonSet (and RBAC, for check preflight) it
created is left behind in the cluster. stop lets the user clean
those up manually.

checksum is intentionally left out: its Cleanup() is a no-op since
it only patches the Volume CR directly and creates no cluster
resources that could be orphaned.

Issue longhorn/longhorn#9311

Signed-off-by: Nicolás Streitenberger <mnstreitenberger@gmail.com>
@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions Bot added the stale label Oct 28, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

This PR was closed because it has been stalled for 5 days with no activity.

@github-actions github-actions Bot closed this Nov 3, 2026
@derekbit derekbit removed the stale label Nov 15, 2026
@derekbit derekbit reopened this Nov 15, 2026
@mergify

mergify Bot commented Nov 15, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The hidden --enable-spdk flag is incorrectly registered as a string rather than a boolean, causing cleanup via appended stop to fail when the flag is supplied without a value.

1 open issue
What changed in this PR

Adds explicit cleanup commands for interrupted remote operations, allowing users to remove orphaned cluster resources without rerunning the parent operation.

Changes:

  • Adds stop subcommands to check preflight, trim volume, and get replica.
  • Initializes each operation and calls its existing cleanup method.
  • Registers hidden parent options to support reusing command invocations with stop appended.
File Description
cmd/​remote/​subcmd/​trim.go Adds volume-trimmer stop and cleanup handling.
cmd/​remote/​subcmd/​get.go Adds replica-getter stop and cleanup handling.
cmd/​remote/​subcmd/​check.go Adds preflight-checker stop and cleanup handling.

Review effort: Balanced

utils.SetGlobalOptionsRemote(cmd, globalOpts)

// Hidden, not removed, so `stop` can be appended to the parent command as-is.
utils.SetFlagHidden(cmd, consts.CmdOptEnableSpdk)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@kiusys-mstreitenberger Could you address the comment? Thanks.

@codecov

codecov Bot commented Nov 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 70 lines in your changes missing coverage. Please review.
✅ Project coverage is 6.80%. Comparing base (6598d56) to head (4a92507).
⚠️ Report is 32 commits behind head on master.

Files with missing lines Patch % Lines
cmd/remote/subcmd/check.go 0.00% 24 Missing ⚠️
cmd/remote/subcmd/get.go 0.00% 24 Missing ⚠️
cmd/remote/subcmd/trim.go 0.00% 22 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           master    #583      +/-   ##
=========================================
+ Coverage    3.15%   6.80%   +3.65%     
=========================================
  Files          53      57       +4     
  Lines        4597    4510      -87     
=========================================
+ Hits          145     307     +162     
+ Misses       4449    4203     -246     
+ Partials        3       0       -3     
Flag Coverage Δ
unittests 6.80% <0.00%> (+3.65%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants