-
Notifications
You must be signed in to change notification settings - Fork 527
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
[feat]tools-v2: bs clean-recycle #2401
[feat]tools-v2: bs clean-recycle #2401
Conversation
c983f10
to
f1c7b79
Compare
392c041
to
0cd94e4
Compare
Please fix the conflict |
7227f6b
to
a4fd1c9
Compare
I just merged into a PR, seems to be a bit of a conflict? |
Just some configurations in tools-v2/pkg/config/bs.go. I seem to be unable to resolve them locally (perhaps due to parentheses). Could you kindly help me resolve them? |
var _ basecmd.FinalCurveCmdFunc = (*CleanRecycleCommand)(nil) // check interface | ||
|
||
// DeleteCertainFileRpc | ||
type DeleteCertainFileRpc struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add a wrapper call to delete file, like this.
curve/tools-v2/pkg/cli/command/curvebs/query/seginfo/segment.go
Lines 143 to 160 in efcbe1c
func GetSegment(caller *cobra.Command) (*nameserver2.GetOrAllocateSegmentResponse, *cmderror.CmdError) { | |
getCmd := NewQuerySegmentCommand() | |
config.AlignFlagsValue(caller, getCmd.Cmd, []string{ | |
config.RPCRETRYTIMES, config.RPCTIMEOUT, config.CURVEBS_MDSADDR, | |
config.CURVEBS_PATH, config.CURVEBS_USER, config.CURVEBS_PASSWORD, | |
config.CURVEBS_OFFSET, | |
}) | |
getCmd.Cmd.SilenceErrors = true | |
getCmd.Cmd.SilenceUsage = true | |
getCmd.Cmd.SetArgs([]string{"--format", config.FORMAT_NOOUT}) | |
err := getCmd.Cmd.Execute() | |
if err != nil { | |
retErr := cmderror.ErrBsCreateFileOrDirectoryType() | |
retErr.Format(err.Error()) | |
return getCmd.Response, retErr | |
} | |
return getCmd.Response, cmderror.Success() | |
} |
type ListDirRpc struct { | ||
Info *basecmd.Rpc | ||
Request *nameserver2.ListDirRequest | ||
curveFSClient nameserver2.CurveFSServiceClient | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
tools-v2/pkg/config/bs.go
Outdated
VIPER_CURVEBS_OFFSET = "curvebs.offset" | ||
CURVEBS_SIZE = "size" | ||
VIPER_CURVEBS_SIZE = "curvebs.size" | ||
CURVEBS_RECYCLE_PREFIX = "recycleprefix" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add default value
tools-v2/pkg/config/bs.go
Outdated
CURVEBS_RECYCLE_PREFIX = "recycleprefix" | ||
VIPER_RECYCLE_PREFIX = "curvebs.recycleprefix" | ||
CURVE_EXPIRED_TIME = "expiredtime" | ||
VIPER_CURVE_EXPIRED_TIME = "curvebs.expiredtime" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
It is best to combine your commits into one. |
Thank you for your help! I just noticed that the error handling has changed in the master branch, and I haven't addressed that in my pr. I will take your review suggestions and refactor the code accordingly. I expect to submit the changes tomorrow and hopefully resolve the issue. |
RECYCLEBINDIRNAME = "RecycleBin" | ||
RECYCLEBINDIR = "/" + RECYCLEBINDIRNAME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merge to one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
|
||
// method of CleanRecycleCommand struct | ||
func (crCmd *CleanRecycleCommand) Init(cmd *cobra.Command, args []string) error { | ||
crCmd.recyclePrefix = config.GetBsRecyclePrefix(crCmd.Cmd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for?
Delete the files in the recycle bin that its original filename has the prefix. I'm following the code in old tool of curve.
0d0062c
to
681850b
Compare
cicheck |
// CleanRecycleCommand | ||
type CleanRecycleCommand struct { | ||
basecmd.FinalCurveCmd | ||
recyclePrefix string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for?
6c55fb1
to
426d432
Compare
CURVEBS_DIR = "dir" | ||
VIPER_CURVEBS_DIR = "curvebs.dir" | ||
CURVEBS_FORCE = "force" | ||
CURVEBS_DEFAULT_FORCE = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add VIPER_CURVEBS_FORCE
@@ -77,6 +75,10 @@ const ( | |||
CURVEBS_STRIPE_COUNT = "stripecount" | |||
VIPER_CURVEBS_STRIPE_COUNT = "curvebs.stripecount" | |||
CURVEBS_DEFAULT_STRIPE_COUNT = uint64(32) | |||
CURVEBS_RECYCLE_PREFIX = "recycleprefix" | |||
VIPER_RECYCLE_PREFIX = "curvebs.recycleprefix" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
option flag should be given default value
tools-v2/pkg/config/bs.go
Outdated
AddBsStringOptionFlag(cmd, CURVEBS_RECYCLE_PREFIX, "recycle prefix (default \"\")") | ||
} | ||
|
||
func AddBsExpireTimeFlag(cmd *cobra.Command) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func AddBsExpireTimeFlag(cmd *cobra.Command) { | |
func AddBsExpireTimeOptionFlag(cmd *cobra.Command) { |
tools-v2/pkg/config/bs.go
Outdated
@@ -400,3 +391,20 @@ func GetBsFlagInt32(cmd *cobra.Command, flagName string) int32 { | |||
} | |||
return value | |||
} | |||
|
|||
// flag for clean recycle bin | |||
func AddBsRecyclePrefixFlag(cmd *cobra.Command) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func AddBsRecyclePrefixFlag(cmd *cobra.Command) { | |
func AddBsRecyclePrefixOptionFlag(cmd *cobra.Command) { |
) | ||
|
||
const ( | ||
cleanRecycleBinExample = `$ curve bs clean-recycle --expiredtime=1h --recycleprefix=/test` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curve bs delete recycle
maybe better?
|
||
filename := RECYCLEBINDIR + "/" + fileInfo.GetFileName() | ||
crCmd.Cmd.Flags().Set(config.CURVEBS_PATH, filename) | ||
crCmd.Cmd.Flags().Set(config.CURVEBS_FORCE, "true") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a constant definition in tools-v2/internal/utils/string.go
?
} | ||
|
||
out := make(map[string]string) | ||
out[cobrautil.ROW_RESULT] = "success" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out[cobrautil.ROW_RESULT] = "success" | |
out[cobrautil.ROW_RESULT] = cobrautil.ROW_VALUE_SUCCESS |
list := cobrautil.Map2List(out, []string{cobrautil.ROW_RESULT}) | ||
crCmd.TableNew.Append(list) | ||
|
||
crCmd.Result = "success" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
crCmd.Result = "success" | |
crCmd.Result = out |
bb259c1
to
35885f0
Compare
cicheck |
1 similar comment
cicheck |
Signed-off-by: lng2020 <[email protected]>
35885f0
to
a8ee8dc
Compare
cicheck |
What problem does this PR solve?
Issue Number: #2032
Problem Summary: support clean-recycle command in curve tool
What is changed and how it works?
What's Changed: add /tools-v2/pkg/cli/command/curvebs/clean_recycle.go, modify /tools-v2/pkg/config/bs.go and /tools-v2/README.md
How it Works:
command help
command usage
Side effects(Breaking backward compatibility? Performance regression?):
Check List