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

cmd, server: check the release version before starting the pd-server #7981

Merged
merged 2 commits into from
Mar 27, 2024

Conversation

JmPotato
Copy link
Member

What problem does this PR solve?

Issue Number: Close #7978.

What is changed and how does it work?

Move the release version check before the startup to ensure we can know it as soon as possible.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
> GOEXPERIMENT= CGO_ENABLED=1 go build  -gcflags '' -ldflags '-X "github.com/tikv/pd/pkg/versioninfo.PDReleaseVersion=g39108f7be" -X "github.com/tikv/pd/pkg/versioninfo.PDBuildTS=2024-03-26 06:12:55" -X "github.com/tikv/pd/pkg/versioninfo.PDGitHash=39108f7be343368ed7487848d81d4528734dc02a" -X "github.com/tikv/pd/pkg/versioninfo.PDGitBranch=fix_release_version_check" -X "github.com/tikv/pd/pkg/versioninfo.PDEdition=Community" -X "github.com/pingcap/tidb-dashboard/pkg/utils/version.InternalVersion=8.0.0-ab48e09f" -X "github.com/pingcap/tidb-dashboard/pkg/utils/version.Standalone=No" -X "github.com/pingcap/tidb-dashboard/pkg/utils/version.PDVersion=v8.0.0-alpha-114-g39108f7be-dirty" -X "github.com/pingcap/tidb-dashboard/pkg/utils/version.BuildTime=2024-03-26 06:12:56" -X "github.com/pingcap/tidb-dashboard/pkg/utils/version.BuildGitHash=ab48e09f7762"' -tags "" -o /Users/jmpotato/go/src/github.com/JmPotato/pd/bin/pd-server cmd/pd-server/main.go
> ./bin/pd-server
[2024/03/26 14:13:47.423 +08:00] [FATAL] [versioninfo.go:70] ["version string is illegal"] [error="[PD:semver:ErrSemverNewVersion]g39108f7be is not in dotted-tri format: g39108f7be is not in dotted-tri format"] [errorVerbose="[PD:semver:ErrSemverNewVersion]g39108f7be is not in dotted-tri format: g39108f7be is not in dotted-tri format\ngithub.com/pingcap/errors.AddStack\n\t/Users/jmpotato/go/pkg/mod/github.com/pingcap/[email protected]/errors.go:174\ngithub.com/pingcap/errors.(*Error).GenWithStackByCause\n\t/Users/jmpotato/go/pkg/mod/github.com/pingcap/[email protected]/normalize.go:307\ngithub.com/tikv/pd/pkg/versioninfo.ParseVersion\n\t/Users/jmpotato/go/src/github.com/JmPotato/pd/pkg/versioninfo/versioninfo.go:61\ngithub.com/tikv/pd/pkg/versioninfo.MustParseVersion\n\t/Users/jmpotato/go/src/github.com/JmPotato/pd/pkg/versioninfo/versioninfo.go:68\ngithub.com/tikv/pd/server.CheckAndGetPDVersion\n\t/Users/jmpotato/go/src/github.com/JmPotato/pd/server/util.go:41\nmain.start\n\t/Users/jmpotato/go/src/github.com/JmPotato/pd/cmd/pd-server/main.go:225\nmain.createServerWrapper\n\t/Users/jmpotato/go/src/github.com/JmPotato/pd/cmd/pd-server/main.go:191\ngithub.com/spf13/cobra.(*Command).execute\n\t/Users/jmpotato/go/pkg/mod/github.com/spf13/[email protected]/command.go:846\ngithub.com/spf13/cobra.(*Command).ExecuteC\n\t/Users/jmpotato/go/pkg/mod/github.com/spf13/[email protected]/command.go:950\ngithub.com/spf13/cobra.(*Command).Execute\n\t/Users/jmpotato/go/pkg/mod/github.com/spf13/[email protected]/command.go:887\nmain.main\n\t/Users/jmpotato/go/src/github.com/JmPotato/pd/cmd/pd-server/main.go:71\nruntime.main\n\t/opt/homebrew/Cellar/go/1.22.1/libexec/src/runtime/proc.go:271\nruntime.goexit\n\t/opt/homebrew/Cellar/go/1.22.1/libexec/src/runtime/asm_arm64.s:1222"] [stack="github.com/tikv/pd/pkg/versioninfo.MustParseVersion\n\t/Users/jmpotato/go/src/github.com/JmPotato/pd/pkg/versioninfo/versioninfo.go:70\ngithub.com/tikv/pd/server.CheckAndGetPDVersion\n\t/Users/jmpotato/go/src/github.com/JmPotato/pd/server/util.go:41\nmain.start\n\t/Users/jmpotato/go/src/github.com/JmPotato/pd/cmd/pd-server/main.go:225\nmain.createServerWrapper\n\t/Users/jmpotato/go/src/github.com/JmPotato/pd/cmd/pd-server/main.go:191\ngithub.com/spf13/cobra.(*Command).execute\n\t/Users/jmpotato/go/pkg/mod/github.com/spf13/[email protected]/command.go:846\ngithub.com/spf13/cobra.(*Command).ExecuteC\n\t/Users/jmpotato/go/pkg/mod/github.com/spf13/[email protected]/command.go:950\ngithub.com/spf13/cobra.(*Command).Execute\n\t/Users/jmpotato/go/pkg/mod/github.com/spf13/[email protected]/command.go:887\nmain.main\n\t/Users/jmpotato/go/src/github.com/JmPotato/pd/cmd/pd-server/main.go:71\nruntime.main\n\t/opt/homebrew/Cellar/go/1.22.1/libexec/src/runtime/proc.go:271"]

Release note

None.

Copy link
Contributor

ti-chi-bot bot commented Mar 26, 2024

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • CabinfeverB
  • HuSharp

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot bot added the release-note-none Denotes a PR that doesn't merit a release note. label Mar 26, 2024
@ti-chi-bot ti-chi-bot bot requested review from HunDunDM and rleungx March 26, 2024 06:17
@ti-chi-bot ti-chi-bot bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 26, 2024
@JmPotato JmPotato changed the title Check the release version before starting the pd-server cmd, server: check the release version before starting the pd-server Mar 26, 2024
@JmPotato JmPotato requested review from lhy1024 and HuSharp and removed request for HunDunDM and rleungx March 26, 2024 06:20
Copy link

codecov bot commented Mar 26, 2024

Codecov Report

Merging #7981 (e43bc16) into master (39108f7) will decrease coverage by 0.03%.
Report is 3 commits behind head on master.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7981      +/-   ##
==========================================
- Coverage   73.58%   73.56%   -0.03%     
==========================================
  Files         436      436              
  Lines       48461    48464       +3     
==========================================
- Hits        35660    35651       -9     
- Misses       9743     9752       +9     
- Partials     3058     3061       +3     
Flag Coverage Δ
unittests 73.56% <100.00%> (-0.03%) ⬇️

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

@ti-chi-bot ti-chi-bot bot added the status/LGT1 Indicates that a PR has LGTM 1. label Mar 26, 2024
@@ -221,6 +221,8 @@ func start(cmd *cobra.Command, args []string, services ...string) {
exit(0)
}

// Check the PD version first before running.
server.CheckAndGetPDVersion()
Copy link
Member

Choose a reason for hiding this comment

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

Is the purpose of the modification to print warning logs to help debug?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it should directly panic here.

Copy link
Member

Choose a reason for hiding this comment

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

Will panic in MustParseVersion ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, otherwise it will panic during the leader campaign which might be too late to let the user be aware of the problem.

@ti-chi-bot ti-chi-bot bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Mar 27, 2024
@JmPotato
Copy link
Member Author

/merge

Copy link
Contributor

ti-chi-bot bot commented Mar 27, 2024

@JmPotato: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

Copy link
Contributor

ti-chi-bot bot commented Mar 27, 2024

This pull request has been accepted and is ready to merge.

Commit hash: e43bc16

@ti-chi-bot ti-chi-bot bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 27, 2024
Copy link
Contributor

ti-chi-bot bot commented Mar 27, 2024

@JmPotato: Your PR was out of date, I have automatically updated it for you.

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot bot merged commit 5c58ddd into tikv:master Mar 27, 2024
22 checks passed
@JmPotato JmPotato deleted the fix_release_version_check branch March 27, 2024 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

move the version check from leader campaign to startup
3 participants