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

Fix the issue that it may panic when user try to list expired component #1391

Merged
merged 3 commits into from
May 28, 2021

Conversation

lucklove
Copy link
Member

@lucklove lucklove commented May 28, 2021

What problem does this PR solve?

When a user try to list a component that's expired with the command tiup list <component>, it may panic if the component manifest has already been downloaded before.

tiup list doc
doc
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x68 pc=0x4977c1a]

goroutine 1 [running]:
github.com/pingcap/tiup/cmd.showComponentVersions(0xc00011d470, 0x7ffeefbff702, 0x3, 0x0, 0x0, 0x0, 0x44856c0)
        /Users/joshua/Desktop/Code/tiup/cmd/list.go:202 +0x2ba
github.com/pingcap/tiup/cmd.newListCmd.func1(0xc000232500, 0xc00011c1f0, 0x1, 0x1, 0x0, 0x0)
        /Users/joshua/Desktop/Code/tiup/cmd/list.go:63 +0xb7
github.com/spf13/cobra.(*Command).execute(0xc000232500, 0xc00011c1c0, 0x1, 0x1, 0xc000232500, 0xc00011c1c0)
        /Users/joshua/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:852 +0x472
github.com/spf13/cobra.(*Command).ExecuteC(0xc000232000, 0xbd7a4b, 0x526ed00, 0xc000541f78)
        /Users/joshua/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
        /Users/joshua/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897
github.com/pingcap/tiup/cmd.Execute()
        /Users/joshua/Desktop/Code/tiup/cmd/root.go:198 +0x67
main.main()
        /Users/joshua/Desktop/Code/tiup/main.go:21 +0x25

What is changed and how it works?

Treat the expired component as expired

Check List

Tests

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

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 requested review from july2993 and nrc May 28, 2021 06:31
@ti-chi-bot ti-chi-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label May 28, 2021
@codecov-commenter
Copy link

codecov-commenter commented May 28, 2021

Codecov Report

Merging #1391 (e1edd1e) into master (e895fa7) will decrease coverage by 9.76%.
The diff coverage is 50.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1391      +/-   ##
==========================================
- Coverage   25.27%   15.50%   -9.77%     
==========================================
  Files         266      149     -117     
  Lines       20586    12837    -7749     
==========================================
- Hits         5204     1991    -3213     
+ Misses      14582    10338    -4244     
+ Partials      800      508     -292     
Flag Coverage Δ
integrate 15.50% <50.00%> (-0.02%) ⬇️
tiup 15.50% <50.00%> (-0.02%) ⬇️
unittest ?

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

Impacted Files Coverage Δ
pkg/repository/v1_repository.go 45.30% <50.00%> (-13.45%) ⬇️
embed/embed.go 0.00% <0.00%> (-100.00%) ⬇️
pkg/utils/regexp.go 0.00% <0.00%> (-100.00%) ⬇️
pkg/cluster/spec/validate.go 0.00% <0.00%> (-89.97%) ⬇️
pkg/cluster/executor/checkpoint.go 0.00% <0.00%> (-82.61%) ⬇️
pkg/utils/semver.go 2.60% <0.00%> (-82.61%) ⬇️
pkg/utils/diff.go 0.00% <0.00%> (-82.50%) ⬇️
pkg/meta/err.go 0.00% <0.00%> (-81.25%) ⬇️
pkg/cluster/api/error.go 0.00% <0.00%> (-80.00%) ⬇️
pkg/cluster/spec/parse_topology.go 0.00% <0.00%> (-78.47%) ⬇️
... and 162 more

Continue to review full report at Codecov.

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

pkg/repository/v1_repository.go Outdated Show resolved Hide resolved
@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • AstroProfundis

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 writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label May 28, 2021
@AstroProfundis
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 4417be5

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label May 28, 2021
@AstroProfundis AstroProfundis added this to the v1.4.5 milestone May 28, 2021
@ti-chi-bot ti-chi-bot merged commit 5928416 into pingcap:master May 28, 2021
@AstroProfundis AstroProfundis modified the milestones: v1.4.5, v1.5.0 Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT1 Indicates that a PR has LGTM 1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants