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

[curve tool]: implement create volume command #2031

Closed
cw123 opened this issue Nov 4, 2022 · 17 comments
Closed

[curve tool]: implement create volume command #2031

cw123 opened this issue Nov 4, 2022 · 17 comments
Labels
good first issue Good for newcomers tools Tool improvements

Comments

@cw123
Copy link
Contributor

cw123 commented Nov 4, 2022

Describe the feature you'd like:

we'd like to support create command in curve tool

create is one of the commands to create one volume.

  • The implementation of the old tool is here:

https://github.com/opencurve/curve/blob/master/src/tools/namespace_tool_core.cpp#L63

  • The old command input and out put:
create : create file, file length unit is GB

$ curve_ops_tool create --example
Example:
curve_ops_tool create -mdsAddr=127.0.0.1:6666 -fileName=/test -userName=test -password=123 -fileLength=20‬

  • The new command we want:
curve bs create --filename /curvebs-file-name --username username --filelength the_length_num_of_volume [--password password] 

If command sucess, print success.
If command failed, print failed, and the fail reason.

Teachability, Documentation, Adoption, Migration Strategy:

Refer to tool develop guide to get start, and paste the result of the command in pr.

Build compilation environment:https://github.com/opencurve/curve/blob/master/docs/cn/build_and_run.md

@zhanghuidinah
Copy link
Member

/assign @wangyanghack

@ilixiaocui
Copy link
Contributor

Please note that the code submission deadline for this developer activity is December 3rd :)
@wangyanghack

@wangyanghack
Copy link

ok. I'm very sorry. I'm developing.

@wuhongsong
Copy link
Contributor

@wangyanghack Are you having some trouble? If so, please let us know so that we can communicate together

@wangyanghack
Copy link

wangyanghack commented Dec 18, 2022

`[root@node2 ~]# docker exec -it 40c bash
root@40c63b12304a:/# ./curve2 bs create -h
Usage: curve bs create [flags]

create certain file in curvebs

Flags:
-c, --conf string config file (default is $HOME/.curve/curve.yaml or /etc/curve/curve.yaml)
--filelength int curve bs file length (default 20)
--filename string the full path of file[required]
--filetype string directory,pagefile,appendfile,appendecfile,snapshot_pagefile
-f, --format string output format (json|plain) (default "plain")
-h, --help print help
--mdsaddr string mds address, should be like 127.0.0.1:6700,127.0.0.1:6701,127.0.0.1:6702
--password string user password
--rpcretrytimes int32 rpc retry times (default 1)
--rpctimeout duration rpc timeout (default 10s)
--showerror display all errors in command
--user string username[required]
--verbose show some log

Examples:
curve bs create --filename /curvebs-file-name --user username --filelength the_length_num_of_volume [--password password]
root@40c63b12304a:/# ./curve1 bs create --filename /curvebs-file-name --user root --password root_password --filetype pagefile --verbose --showerror
2022/12/18 21:26:05.808029 base.go:296: 127.0.0.1:6702: start to dial
2022/12/18 21:26:05.808167 base.go:296: 127.0.0.1:6700: start to dial
2022/12/18 21:26:05.808821 base.go:296: 127.0.0.1:6701: start to dial
2022/12/18 21:26:05.810073 base.go:311: 127.0.0.1:6700: start to rpc [CreateFile]
2022/12/18 21:26:05.811767 base.go:328: 127.0.0.1:6700: get rpc[CreateFile] request successfully
{Code:90040 Message:create file fail. the error is %s}
root@40c63b12304a:/#`

yes, I am having some trouble. I don't know how to get more error information from the output.

@wuhongsong
Copy link
Contributor

`[root@node2 ~]# docker exec -it 40c bash root@40c63b12304a:/# ./curve2 bs create -h Usage: curve bs create [flags]

create certain file in curvebs

Flags: -c, --conf string config file (default is $HOME/.curve/curve.yaml or /etc/curve/curve.yaml) --filelength int curve bs file length (default 20) --filename string the full path of file[required] --filetype string directory,pagefile,appendfile,appendecfile,snapshot_pagefile -f, --format string output format (json|plain) (default "plain") -h, --help print help --mdsaddr string mds address, should be like 127.0.0.1:6700,127.0.0.1:6701,127.0.0.1:6702 --password string user password --rpcretrytimes int32 rpc retry times (default 1) --rpctimeout duration rpc timeout (default 10s) --showerror display all errors in command --user string username[required] --verbose show some log

Examples: curve bs create --filename /curvebs-file-name --user username --filelength the_length_num_of_volume [--password password] root@40c63b12304a:/# ./curve1 bs create --filename /curvebs-file-name --user root --password root_password --filetype pagefile --verbose --showerror 2022/12/18 21:26:05.808029 base.go:296: 127.0.0.1:6702: start to dial 2022/12/18 21:26:05.808167 base.go:296: 127.0.0.1:6700: start to dial 2022/12/18 21:26:05.808821 base.go:296: 127.0.0.1:6701: start to dial 2022/12/18 21:26:05.810073 base.go:311: 127.0.0.1:6700: start to rpc [CreateFile] 2022/12/18 21:26:05.811767 base.go:328: 127.0.0.1:6700: get rpc[CreateFile] request successfully {Code:90040 Message:create file fail. the error is %s} root@40c63b12304a:/#`

yes, I am having some trouble. I don't know how to get more error information from the output.

@Cyber-SiKu Can you take a look at this?

@Cyber-SiKu
Copy link
Contributor

Cyber-SiKu commented Jan 5, 2023

Please submit your code and let me have a look.
@wangyanghack

@wuhongsong
Copy link
Contributor

@wangyanghack keep on? Can you tell more about your troubles?

@wangyanghack
Copy link

@wangyanghack keep on? Can you tell more about your troubles?

I have submitted my code. But I don't know how to get more details from log.

@Cyber-SiKu
Copy link
Contributor

Cyber-SiKu commented Feb 17, 2023

@wangyanghack

createCommand.Response = result.(*nameserver2.CreateFileResponse)
if createCommand.Response.GetStatusCode() != nameserver2.StatusCode_kOK {
err = cmderror.ErrBsCreateFile()
out[cobrautil.ROW_RESULT] = "failed"
out[cobrautil.ROW_REASON] = err.Message
return nil
}

Here you create the error, and you can see that the reason for the error is: the returned status code is not ok. You can call err.Formate() to fill in the following %s.

@wangyanghack
Copy link

thanks a lot! I will try it tonight.

@wangyanghack
Copy link

image

The returned status code is kFileLengthNotSupported. But it is strange. I search all code. I find kFileLengthNotSupported is not related with curvebs.

@Cyber-SiKu
Copy link
Contributor

@wangyanghack Please update the code

@Cyber-SiKu
Copy link
Contributor

@wangyanghack Are you still going on?

@Cyber-SiKu
Copy link
Contributor

@wangyanghack If you have any questions, you can contact us in time.

@zhanghuidinah
Copy link
Member

@Cyber-SiKu
Copy link
Contributor

#2404

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers tools Tool improvements
Projects
None yet
Development

No branches or pull requests

6 participants