Skip to content

cmd: fix mirror clone help panic#2717

Merged
xhebox merged 1 commit into
pingcap:masterfrom
xhebox:fix-mirror-clone-help-panic
Jun 15, 2026
Merged

cmd: fix mirror clone help panic#2717
xhebox merged 1 commit into
pingcap:masterfrom
xhebox:fix-mirror-clone-help-panic

Conversation

@xhebox

@xhebox xhebox commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

What problem does this PR solve?

Issue Number: N/A

tiup mirror clone -h panics because the root command skips environment initialization for help requests. Unlike most commands, mirror clone builds part of its help output from the remote mirror index so it needs the TiUP environment even on the help path.

What is changed and how it works?

  • Special-case mirror clone -h/--help in the root command so it does not skip environment initialization.
  • Keep the existing mirror clone dynamic component flag initialization path intact, so help still includes component flags such as --tidb and --tikv.
  • Move the mirror clone initialized marker to after component flags are successfully loaded, so a failed index fetch does not prevent later retries.
  • Add a regression test for the root environment-initialization decision.
  • Fix branch-wide CI blockers exposed by this PR run:
    • update TiKV worker's UptimeByHost call for the current signature;
    • simplify the Prometheus agent-mode boolean assignment to satisfy the existing cognitive complexity threshold.

Check List

Tests

  • Unit test
  • Manual test (add detailed scripts or steps below)

Manual test:

go run . mirror clone -h
go run . mirror clone --help

Local validation:

go test ./cmd ./pkg/cluster/spec ./components/playground
make lint
git diff --check

Code changes

  • Has exported function/method change
  • Has exported variable/fields change
  • Has interface methods change
  • Has persistent data change

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation

Release notes:

NONE

@ti-chi-bot ti-chi-bot Bot requested review from kaaaaaaang and nexustar June 15, 2026 05:10
@ti-chi-bot

ti-chi-bot Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

[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 bb7133 for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

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

@ti-chi-bot ti-chi-bot Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 15, 2026
@codecov-commenter

codecov-commenter commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.58824% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.29%. Comparing base (598e27a) to head (2d91390).

Files with missing lines Patch % Lines
cmd/root.go 85.71% 1 Missing and 1 partial ⚠️
cmd/mirror.go 0.00% 1 Missing ⚠️
pkg/cluster/spec/monitoring.go 0.00% 1 Missing ⚠️
pkg/cluster/spec/tikv_worker.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2717      +/-   ##
==========================================
+ Coverage   36.22%   42.29%   +6.07%     
==========================================
  Files         329      426      +97     
  Lines       35405    47330   +11925     
==========================================
+ Hits        12823    20015    +7192     
- Misses      20754    24618    +3864     
- Partials     1828     2697     +869     

☔ 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.

@xhebox xhebox force-pushed the fix-mirror-clone-help-panic branch 2 times, most recently from e8d5a65 to b271fca Compare June 15, 2026 05:39
@ti-chi-bot ti-chi-bot Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 15, 2026
@xhebox xhebox force-pushed the fix-mirror-clone-help-panic branch from b271fca to 2d91390 Compare June 15, 2026 06:02
@ti-chi-bot ti-chi-bot Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 15, 2026
@xhebox xhebox merged commit 0ca2354 into pingcap:master Jun 15, 2026
21 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants