Skip to content

server/api:support offline a store with physically destroyed #3388

Merged
ti-chi-bot merged 6 commits into
tikv:masterfrom
AndreMouche:offline_store
Jan 28, 2021
Merged

server/api:support offline a store with physically destroyed #3388
ti-chi-bot merged 6 commits into
tikv:masterfrom
AndreMouche:offline_store

Conversation

@AndreMouche
Copy link
Copy Markdown
Member

@AndreMouche AndreMouche commented Jan 25, 2021

Signed-off-by: shirly AndreMouche@126.com

What problem does this PR solve?

It is part of #3076
This PR support to offline a store and set it physically destroyed which means this store can never up and we can start a new store with the same address

What is changed and how it works?

  • The API to offline a store
DELETE /store/{id}?force=${force}

force is a boolean value:

  • true: means the store shouldn't be up again and PD can remove it, also we can up a new store with the same address
  • false: means the store is offline, it can be up again.

Check List

Tests

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

Code changes

Related changes

pingcap/kvproto#711

Release note

  • No release note

…ans it can never up again

Signed-off-by: shirly <AndreMouche@126.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 25, 2021

Codecov Report

Merging #3388 (c97ec36) into master (c15cb77) will decrease coverage by 0.12%.
The diff coverage is 80.64%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3388      +/-   ##
==========================================
- Coverage   75.00%   74.87%   -0.13%     
==========================================
  Files         243      243              
  Lines       23305    23314       +9     
==========================================
- Hits        17479    17456      -23     
- Misses       4266     4285      +19     
- Partials     1560     1573      +13     
Flag Coverage Δ
unittests 74.87% <80.64%> (-0.13%) ⬇️

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

Impacted Files Coverage Δ
server/api/store.go 62.69% <58.33%> (+0.42%) ⬆️
server/cluster/cluster.go 83.69% <91.66%> (+0.18%) ⬆️
server/core/store.go 82.01% <100.00%> (+0.07%) ⬆️
server/core/store_option.go 100.00% <100.00%> (ø)
server/statistics/store.go 90.67% <100.00%> (ø)
pkg/dashboard/adapter/manager.go 80.43% <0.00%> (-11.96%) ⬇️
server/id/id.go 76.19% <0.00%> (-4.77%) ⬇️
pkg/etcdutil/etcdutil.go 84.70% <0.00%> (-3.53%) ⬇️
server/election/leadership.go 82.92% <0.00%> (-2.44%) ⬇️
server/member/member.go 66.30% <0.00%> (-2.18%) ⬇️
... and 14 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 c48910b...fac5f0c. Read the comment docs.

Signed-off-by: shirly <AndreMouche@126.com>
Copy link
Copy Markdown
Contributor

@Yisaer Yisaer left a comment

Choose a reason for hiding this comment

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

Rest LGTM

Comment thread server/cluster/cluster.go
Comment thread server/cluster/cluster.go
Comment on lines +1032 to +1034
if store.IsPhysicallyDestroyed() {
return errors.Errorf("The store is already physically destroyed")
}
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.

Maybe we can return nil here as the store is already PhysicallyDestroyed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Since physically-destroyed is not allowed from true to false.

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.

I think we should define a errorCode like ErrStoreTombstone and to explain it as The store have been force removed

Copy link
Copy Markdown
Contributor

@Yisaer Yisaer left a comment

Choose a reason for hiding this comment

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

Rest LGTM

Comment thread server/cluster/cluster.go
Comment on lines +1032 to +1034
if store.IsPhysicallyDestroyed() {
return errors.Errorf("The store is already physically destroyed")
}
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.

I think we should define a errorCode like ErrStoreTombstone and to explain it as The store have been force removed

}

// OfflineStore offline a store
func OfflineStore(physicallyDestroyed bool) StoreCreateOption {
Copy link
Copy Markdown
Member

@rleungx rleungx Jan 28, 2021

Choose a reason for hiding this comment

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

Can we just use func SetStoreState(state metapb.StoreState, destroyed ...bool) StoreCreateOption here?

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.

I think ... bool is not a good design.

Copy link
Copy Markdown
Member

@rleungx rleungx Jan 28, 2021

Choose a reason for hiding this comment

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

Or maybe an option?

Copy link
Copy Markdown
Member

@HunDunDM HunDunDM Jan 28, 2021

Choose a reason for hiding this comment

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

how about

func setStoreState(state metapb.StoreState, physicallyDestroyed bool)
func OfflineStore(physicallyDestroyed bool)
func UpStore()
func TombstoneStore()

Comment thread server/cluster/cluster.go
Comment thread server/core/store_option.go
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jan 28, 2021
Copy link
Copy Markdown
Contributor

@Yisaer Yisaer left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot
Copy link
Copy Markdown
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • HunDunDM
  • Yisaer

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.

Details

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 status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jan 28, 2021
@Yisaer
Copy link
Copy Markdown
Contributor

Yisaer commented Jan 28, 2021

/merge

@ti-chi-bot
Copy link
Copy Markdown
Member

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

/run-all-tests

Details

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
Copy link
Copy Markdown
Member

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

DetailsCommit hash: c97ec36

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jan 28, 2021
@ti-chi-bot
Copy link
Copy Markdown
Member

@AndreMouche: Your PR has out-of-dated, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

Details

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.

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

Labels

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.

5 participants