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

feature: add bs delete snapshot #2889

Merged
merged 1 commit into from
Jan 5, 2024

Conversation

ZackSoul
Copy link
Contributor

@ZackSoul ZackSoul commented Nov 10, 2023

What problem does this PR solve?

Issue Number: #2578

Problem Summary:

What is changed and how it works?

What's Changed:

add bs delete snapshot

How it Works:
delete测试

Side effects(Breaking backward compatibility? Performance regression?):

Check List

  • Relevant documentation/comments is changed or added
  • I acknowledge that all my contributions will be made under the project's license

@ZackSoul
Copy link
Contributor Author

cicheck

2 similar comments
@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck


func (sCmd *SnapShotCommand) Init(cmd *cobra.Command, args []string) error {
snapshotAddrs, err := config.GetBsSnapshotAddrSlice(sCmd.Cmd)
if err.TypeCode() != cmderror.CODE_SUCCESS || len(snapshotAddrs) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

The two cases are diff, maybe they are not suitable for processing in a statement.

snapshotutil.QueryOffset: snapshotutil.Offset,
}
if sCmd.failed {
params[snapshotutil.QueryStatus] = 5
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be better to change the hard code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What does it mean to change the hard code?

Copy link
Contributor

Choose a reason for hiding this comment

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

For example, you can use static variable to record what 5 means.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok,understand,I will modify it.

if sCmd.failed {
params[snapshotutil.QueryStatus] = 5
}
if sCmd.uuid != "*" {
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@ZackSoul
Copy link
Contributor Author

cicheck

6 similar comments
@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul ZackSoul requested a review from montaguelhz November 24, 2023 08:50
Copy link
Contributor

@montaguelhz montaguelhz left a comment

Choose a reason for hiding this comment

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

good job

Usage:

```shell
curve bs delete snapshot
Copy link
Contributor

Choose a reason for hiding this comment

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

Add example of optional parameters

)

const (
snapshotExample = `$ curve bs delete snapshot`
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

func (sCmd *SnapShotCommand) Init(cmd *cobra.Command, args []string) error {
snapshotAddrs, err := config.GetBsSnapshotAddrSlice(sCmd.Cmd)
if err.TypeCode() != cmderror.CODE_SUCCESS {
return err.ToError()
Copy link
Contributor

Choose a reason for hiding this comment

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

set a value for sCmd.Error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean setting value to this err.ToError()?

Copy link
Contributor

Choose a reason for hiding this comment

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

see #2890

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks,I got it

@ZackSoul
Copy link
Contributor Author

ZackSoul commented Dec 4, 2023

delete测试

@ZackSoul
Copy link
Contributor Author

ZackSoul commented Dec 4, 2023

cicheck

1 similar comment
@ZackSoul
Copy link
Contributor Author

ZackSoul commented Dec 4, 2023

cicheck

Copy link
Contributor

@montaguelhz montaguelhz left a comment

Choose a reason for hiding this comment

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

LGTM

@montaguelhz
Copy link
Contributor

@Cyber-SiKu PTAL~

@montaguelhz
Copy link
Contributor

However, if you want to merge the pr to master, please merge your commits into one.

@ZackSoul ZackSoul force-pushed the bs-delete-snapshot branch 2 times, most recently from ac67d2f to bcbe08f Compare December 6, 2023 06:34
@ZackSoul
Copy link
Contributor Author

ZackSoul commented Dec 6, 2023

cicheck

rows := make([]map[string]string, 0)
for _, snapshot := range snapshotsList {
row := make(map[string]string)
err := DeleteSnapShot(sCmd.snapshotAddrs, sCmd.timeout, snapshot)
Copy link
Contributor

Choose a reason for hiding this comment

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

should handle error here?

@@ -675,6 +680,10 @@ func AddBsSnapshotIDOptionFlag(cmd *cobra.Command) {
AddBsStringOptionFlag(cmd, CURVEBS_SNAPSHOT_ID, "snapshot seqId")
}

func AddBsSnapshotFailedDOptionFlag(cmd *cobra.Command) {
Copy link
Contributor

Choose a reason for hiding this comment

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

AddBsSnapshotFailedOptionFlag?

@ZackSoul ZackSoul force-pushed the bs-delete-snapshot branch 2 times, most recently from 691c708 to d2bfa24 Compare December 12, 2023 15:29
@ZackSoul
Copy link
Contributor Author

cicheck

1 similar comment
@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul ZackSoul force-pushed the bs-delete-snapshot branch 2 times, most recently from 0ed3edc to e22656f Compare December 12, 2023 17:13
@ZackSoul
Copy link
Contributor Author

cicheck

27 similar comments
@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@ZackSoul
Copy link
Contributor Author

cicheck

@montaguelhz
Copy link
Contributor

cicheck

@caoxianfei1
Copy link
Contributor

cicheck

@caoxianfei1 caoxianfei1 merged commit 3310650 into opencurve:master Jan 5, 2024
4 checks passed
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