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

add curvebs volume target blocksize #161

Merged
merged 1 commit into from
Dec 1, 2022
Merged

add curvebs volume target blocksize #161

merged 1 commit into from
Dec 1, 2022

Conversation

mfordjody
Copy link
Contributor

@mfordjody mfordjody commented Nov 19, 2022

issues #150
Signed-off-by: mfordjody mfordjody@gmail.com

[root@client-host curveadm]# go run main.go target add -h
Usage:  curveadm target add USER:VOLUME [OPTIONS]

Add a target of CurveBS

Options:
      --blocksize string   Specify target volume block size (default "512byte")
  -c, --conf string        Specify client configuration file (default "client.yaml")
      --create             Create volume iff not exist
  -h, --help               Print usage
      --host string        Specify target host (default "localhost")
      --size string        Specify volume size (default "10GB")
[root@client-host curveadm]# go run main.go target add curve:/etc --host server-host1 --create --blocksize 512
---
Error-Code: 201009
Error-Description: volume block size must end with "byte" suffix
Error-Clue: blocksize: 512
How to Solve:
  * Website: https://github.com/opencurve/curveadm/wiki/errno2#201009
  * Log: /root/.curveadm/logs/curveadm-2022-11-19_04-48-02.log
  * WeChat: opencurve_bot
exit status 1

I won't solve the container error

go run main.go target add curve:/etc --host server-host1 --create --blocksize 512byte
Add Target: [ERROR]
  + host=server-host1  volume=/etc [0/1] [ERROR]
---
Error-Code: 630009
Error-Description: run a command in container failed (docker exec CONTAINER COMMAND)
Error-Clue: Process exited with status 1
How to Solve:
  * Website: https://github.com/opencurve/curveadm/wiki/errno6#630009
  * Log: /root/.curveadm/logs/curveadm-2022-11-19_04-48-26.log
  * WeChat: opencurve_bot
exit status 1

@mfordjody mfordjody closed this Nov 20, 2022
@mfordjody mfordjody reopened this Nov 20, 2022
@mfordjody
Copy link
Contributor Author

I have to enter the container to debug the code

@Cyber-SiKu
Copy link
Collaborator

It should be that you made an error executing the command in the container, and you can enter the container to execute the corresponding command. Or check whether the incoming command is wrong. The way to execute the command is: docker exec -t xxx xxx.

@mfordjody
Copy link
Contributor Author

mfordjody commented Nov 21, 2022

issues #150

Signed-off-by: mfordjody mfordjody@gmail.com

curve@client-hosts:~/curveadm/cmd/curveadm$ go run main.go target add -h
Usage:  curveadm target add USER:VOLUME [OPTIONS]

Add a target of CurveBS

Options:
      --blocksize string   Specify volume block size (default "512byte")
  -c, --conf string        Specify client configuration file (default "client.yaml")
      --create             Create volume if not exist
  -h, --help               Print usage
      --host string        Specify target host (default "localhost")
      --size string        Specify volume size (default "10GB")
curve@client-hosts:~/curveadm/cmd/curveadm$ go run main.go target add curve:/test --host server-hosts --create --blocksize 4096byte
Add Target: [OK]
  + host=server-hosts  volume=/test [1/1] [OK]

Add target (curve:/test) to server-hosts success ^_^
curve@client-hosts:~/curveadm/cmd/curveadm$ curveadm target list --host server-hosts
List Targets: [OK]
  + host=192.168.10.136 [1/1] [OK]

Tid  Host          Target Name                                                       Store                  Portal
---  ----          -----------                                                       -----                  ------
1    server-hosts  iqn.2022-11.com.opencurve:curve.5a82e0b942bc472fe1de2059b971b7bd  cbd:pool//test_curve_  192.168.10.136:3260

@@ -43,14 +45,13 @@ mkdir -p /curvebs/nebd/data/lock
touch /etc/curve/curvetab

if [ $g_create == "true" ]; then
output=$(curve_ops_tool create -userName=$g_user -fileName=$g_volume -fileLength=$g_size)
output=$(curve_ops_tool create -userName=$g_user -fileName=$g_volume -fileLength=$g_size -fileLength=$g_blocksize)
Copy link

Choose a reason for hiding this comment

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

-fileLength=$g_blocksize

这里是不是写错了?Is the logic wrong here?

two file length?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I output an error

curveadm target add curve:/test --host server-hosts --create --blocksize 4096byte

There is this -fileLength=$g_blocksize,Will print according to the size

$ cat ~/.curveadm/logs/curveadm-2022-11-21_17-45-44.log

    remoteAddr: curve@192.168.10.136:22
    command: sudo docker exec  curvebs-target-daemon /bin/bash /curvebs/tools/sbin/target.sh curve /data true 10 4096
    output:
    error: Process exited with status 1

If don't have this -fileLength=$g_blocksize

$ cat ~/.curveadm/logs/curveadm-2022-11-21_17-47-23.log

    remoteAddr: curve@192.168.10.136:22
    command: sudo docker exec  curvebs-target-daemon /bin/bash /curvebs/tools/sbin/target.sh curve /data true 10 512
    output:
    error: Process exited with status 1

@cw123
Copy link

cw123 commented Nov 22, 2022

Merge multiple commits into one.

@cw123
Copy link

cw123 commented Nov 22, 2022

blocksize 不是在curve_ops_tool create的时候指定的,curve_ops_tool没有指定blocksize的地方。

The blocksize is not specified when the curve_ops_tool create, and the curve_ops_tool does not have the blocksize param.

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

blocksize是在这里指定的,在这个命令的后面添加一个--blocksize $g_blocksize

blocksize is specified here, add a --blocksize $g_blocksize after this command

tgtadm --lld iscsi \
    --mode logicalunit \
    --op new \
    --tid ${g_tid} \
    --lun 1 \
    --bstype curve \
    --backing-store ${g_image}

为什么要这样修改,因为curvebs在一些版本需要保证下发的请求是4KB对齐的请求,如果用户下发一个非4KB对齐的请求到curvebs,就会出错。通过nbd挂载的设备可以保证,nbd给到curvebs的请求是4KB对齐的,而现在使用target的方式挂载的设备没有对这个做一个保证。在target 添加lun的时候,指定blocksize,可以保证所有的请求都是指定blocksize下来的。

希望这个值默认是4KB。添加target的时候,如果不指定这个命令,就按照4096字节作为blocksize。如果指定blocksize,就按照指定的blocksize。

Why do we want to modify it like this, because in some versions of curvebs, you need to ensure that the issued request is a 4KB-aligned request. If the user sends a non-4KB-aligned request to curvebs, an error will occur. The device mounted through nbd can guarantee that the request from nbd to curvebs is 4KB aligned, but the device mounted using the target method does not make a guarantee for this. When adding a lun to the target, specify the blocksize to ensure that all requests come from the specified blocksize.

Hopefully this value defaults to 4KB. When adding a target, if this command is not specified, 4096 bytes will be used as the blocksize. If blocksize is specified, follow the specified blocksize.

使用的地方参考文档

Reference documents

https://github.com/opencurve/curveadm/wiki/curve-tgt-deployment#%E7%AC%AC-5-%E6%AD%A5%E6%B7%BB%E5%8A%A0-target

$ curveadm target add <user>:<volume-name> --host target-host --create --size 10GB

@@ -106,11 +107,30 @@ func ParseSize(size string) (int, error) {
return n, nil
}

func ParseBlockSize(blocksize string) (int, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can use the package go-humanize to parse.

Copy link
Collaborator

Choose a reason for hiding this comment

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

image

@cw123
Copy link

cw123 commented Nov 22, 2022

如果未指定blocksize,fdisk -l 看到的可能是这样的

If blocksize is not specified, fdisk -l may see something like this

image

target 添加lun的时候指定blocksize,看到的是这样的

Target specifies the blocksize when adding lun, what you see is this

image

flags.StringVar(&options.size, "size", "10GB", "Specify volume size")
flags.StringVarP(&options.filename, "conf", "c", "client.yaml", "Specify client configuration file")

flags.StringVar(&options.blocksize, "blocksize", "512byte", "Specify volume block size")
Copy link
Collaborator

@Wine93 Wine93 Nov 22, 2022

Choose a reason for hiding this comment

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

The default unit of blocksize should be Byte, and if we want to provide more units for convenience, we can use KBMB and etc, like:

--blocksize 512  # Byte, also default unit
--blocksize 1KB  # KB
--blocksize 1MB  # MB

@Wine93
Copy link
Collaborator

Wine93 commented Nov 22, 2022

BTW: there are many commits in this PR, maybe we can rebase them into one :)

@mfordjody
Copy link
Contributor Author

mfordjody commented Nov 24, 2022

curve@client-hosts:~/curveadm/cmd/curveadm$ go run main.go target add curve:/test --host server-hosts --create --size 30GB --blocksize 512
---
Error-Code: 201009
Error-Description: volume block size must end with "B" suffix
Error-Clue: blocksize: 512
How to Solve:
  * Website: https://github.com/opencurve/curveadm/wiki/errno2#201009
  * Log: /home/curve/.curveadm/logs/curveadm-2022-11-24_10-25-10.log
  * WeChat: opencurve_bot
exit status 1
curve@client-hosts:~/curveadm/cmd/curveadm$ go run main.go target add curve:/test --host server-hosts --create --size 30GB --blocksize 1kB
---
Error-Code: 221011
Error-Description: volume block size be a multiple of 512B,like 1.024kB, 2.048kB,3.072kB...
Error-Clue: blocksize: 1.0 kB
How to Solve:
  * Website: https://github.com/opencurve/curveadm/wiki/errno2#221011
  * Log: /home/curve/.curveadm/logs/curveadm-2022-11-24_10-21-09.log
  * WeChat: opencurve_bot
exit status 1

@Cyber-SiKu Cyber-SiKu closed this Nov 24, 2022
@Cyber-SiKu Cyber-SiKu reopened this Nov 24, 2022
Comment on lines +112 to +114
if !strings.HasSuffix(blocksize, "B") {
return 0, errno.ERR_VOLUME_BLOCKSIZE_MUST_END_WITH_BYTE_SUFFIX.
F("blocksize: %s", blocksize)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is not needed here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@mfordjody
Copy link
Contributor Author

curve@client-hosts:~/curveadm/cmd/curveadm$ go run main.go target add curve:/test --host server-hosts --create --size 10GB
Add Target: [OK]
  + host=server-hosts  volume=/test [1/1] [OK]

Add target (curve:/test) to server-hosts success ^_^
curve@client-hosts:~/curveadm/cmd/curveadm$ go run main.go target add curve:/test1 --host server-hosts --create --size 10GB --blocksize 512
Add Target: [OK]
  + host=server-hosts  volume=/test1 [1/1] [OK]

Add target (curve:/test1) to server-hosts success ^_^
curve@client-hosts:~/curveadm/cmd/curveadm$ go run main.go target add curve:/test1 --host server-hosts --create --size 10GB --blocksize 1k
---
Error-Code: 221011
Error-Description: volume block size be a multiple of 512B,like 1.024kB, 2.048kB,3.072kB...
Error-Clue: blocksize: 1.0 kB
How to Solve:
  * Website: https://github.com/opencurve/curveadm/wiki/errno2#221011
  * Log: /home/curve/.curveadm/logs/curveadm-2022-11-24_11-23-51.log
  * WeChat: opencurve_bot
exit status 1
curve@client-hosts:~/curveadm/cmd/curveadm$ go run main.go target add curve:/test2 --host server-hosts --create --size 10GB --blocksize 4.096k
Add Target: [OK]
  + host=server-hosts  volume=/test2 [1/1] [OK]

Add target (curve:/test2) to server-hosts success ^_^
curve@client-hosts:~/curveadm/cmd/curveadm$ go run main.go target list --host server-hosts
List Targets: [OK]
  + host=192.168.10.143 [1/1] [OK]

Tid  Host          Target Name                                                       Store                   Portal
---  ----          -----------                                                       -----                   ------
1    server-hosts  iqn.2022-11.com.opencurve:curve.5a82e0b942bc472fe1de2059b971b7bd  cbd:pool//test_curve_   192.168.10.143:3260
2    server-hosts  iqn.2022-11.com.opencurve:curve.d97372e236558863e4ffc63dcfa7eb27  cbd:pool//test1_curve_  192.168.10.143:3260
3    server-hosts  iqn.2022-11.com.opencurve:curve.41f7dfa48ebe871dd74b2db0d88f1243  cbd:pool//test2_curve_  192.168.10.143:3260

@@ -106,11 +108,25 @@ func ParseSize(size string) (int, error) {
return n, nil
}

func ParseBlockSize(blocksize string) (uint64, error) {
blocksize = strings.TrimSuffix(blocksize, "B")
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need to remove B.

// You can edit this code!
// Click here and start typing.
package main

import (
	"fmt"

	"github.com/dustin/go-humanize"
)

func main() {
	blocksize := "1024B"
	str, _ := humanize.ParseBytes(blocksize)
	fmt.Println(str)
}

the output is:

1024

m, err := humanize.ParseBytes(blocksize)
if err != nil || m <= 0 {
return 0, errno.ERR_VOLUME_BLOCKSIZE_REQUIRES_POSITIVE_INTEGER.
F("blocksize: %s", humanize.Bytes(m))
Copy link
Collaborator

Choose a reason for hiding this comment

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

humanize.IBytes(m)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Learn the difference between Bytes and IBytes:Multiple-byte units

F("blocksize: %s", humanize.Bytes(m))
} else if m%512 != 0 {
return 0, errno.ERR_VOLUME_BLOCKSIZE_BE_MULTIPLE_OF_512.
F("blocksize: %s", humanize.Bytes(m))
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

@@ -106,11 +108,25 @@ func ParseSize(size string) (int, error) {
return n, nil
}

func ParseBlockSize(blocksize string) (uint64, error) {
blocksize = strings.TrimSuffix(blocksize, "B")
m, err := humanize.ParseBytes(blocksize)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can look at its source code

@@ -142,7 +158,7 @@ func NewMapCommand(curveadm *cli.CurveAdm) *cobra.Command {
flags.BoolVar(&options.noExclusive, "no-exclusive", false, "Map volume non exclusive")
flags.StringVar(&options.size, "size", "10GB", "Specify volume size")
Copy link
Collaborator

Choose a reason for hiding this comment

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

GiB?

@@ -84,10 +87,10 @@ func NewAddCommand(curveadm *cli.CurveAdm) *cobra.Command {

flags := cmd.Flags()
flags.StringVar(&options.host, "host", "localhost", "Specify target host")
flags.BoolVar(&options.create, "create", false, "Create volume iff not exist")
flags.BoolVar(&options.create, "create", false, "Create volume if not exist")
flags.StringVar(&options.size, "size", "10GB", "Specify volume size")
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

ERR_VOLUME_NAME_MUST_START_WITH_SLASH_PREFIX = EC(221002, "volume name must start with \"/\" prefix")
ERR_VOLUME_SIZE_MUST_END_WITH_GB_SUFFIX = EC(221003, "volume size must end with \"GB\" suffix")
ERR_VOLUME_SIZE_REQUIRES_POSITIVE_INTEGER = EC(221004, "volume size requires a positive integer")
ERR_VOLUME_SIZE_MUST_BE_MULTIPLE_OF_10_GB = EC(221005, "volume size must be a multiple of 10GB, like 10GB, 20GB, 30GB...")
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

ERR_VOLUME_NAME_CAN_NOT_CONTAIN_UNDERSCORE = EC(221008, "volume name can't contain \"_\" symbol")
ERR_VOLUME_BLOCKSIZE_MUST_END_WITH_BYTE_SUFFIX = EC(201009, "volume block size must end with \"B\" suffix")
ERR_VOLUME_BLOCKSIZE_REQUIRES_POSITIVE_INTEGER = EC(221010, "volume block size requires a positive integer")
ERR_VOLUME_BLOCKSIZE_BE_MULTIPLE_OF_512 = EC(221011, "volume block size be a multiple of 512B,like 1.024kB, 2.048kB,3.072kB...")
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

@mfordjody
Copy link
Contributor Author

mfordjody commented Nov 24, 2022

curve@client-hosts:~/curveadm/cmd/curveadm$ go run main.go target add -h
Usage:  curveadm target add USER:VOLUME [OPTIONS]

Add a target of CurveBS

Options:
      --blocksize string   Specify volume blocksize (default "512B")
  -c, --conf string        Specify client configuration file (default "client.yaml")
      --create             Create volume iff not exist
  -h, --help               Print usage
      --host string        Specify target host (default "localhost")
      --size string        Specify volume size (default "10GiB")
curve@client-hosts:~/curveadm/cmd/curveadm$ go run main.go target add curve:/test --host server-hosts --create --size 10GB
---
Error-Code: 221003
Error-Description: volume size must end with "GiB" suffix
Error-Clue: size: 10GB
How to Solve:
  * Website: https://github.com/opencurve/curveadm/wiki/errno2#221003
  * Log: /home/curve/.curveadm/logs/curveadm-2022-11-24_17-54-56.log
  * WeChat: opencurve_bot
exit status 1
curve@client-hosts:~/curveadm/cmd/curveadm$ go run main.go target add curve:/test --host server-hosts --create --size 10GiB
Add Target: [OK]
  + host=server-hosts  volume=/test [1/1] [OK]
Add target (curve:/test) to server-hosts success ^_^
curve@client-hosts:~/curveadm/cmd/curveadm$ go run main.go target add curve:/test1 --host server-hosts --create --size 10GiB --blocksize 512
---
Error-Code: 201009
Error-Description: volume block size must end with "B" suffix
Error-Clue: blocksize: 512
How to Solve:
  * Website: https://github.com/opencurve/curveadm/wiki/errno2#201009
  * Log: /home/curve/.curveadm/logs/curveadm-2022-11-24_17-50-10.log
  * WeChat: opencurve_bot
exit status 1
curve@client-hosts:~/curveadm/cmd/curveadm$ go run main.go target add curve:/test1 --host server-hosts --create --size 10GiB --blocksize 512B
Add Target: [OK]
  + host=server-hosts  volume=/test1 [1/1] [OK]

Add target (curve:/test1) to server-hosts success ^_^
curve@client-hosts:~/curveadm/cmd/curveadm$ go run main.go target add curve:/test2 --host server-hosts --create --size 10GiB --blocksize 1kiB
Add Target: [OK]
  + host=server-hosts  volume=/test2 [1/1] [OK]

Add target (curve:/test2) to server-hosts success ^_^
curve@client-hosts:~/curveadm/cmd/curveadm$ go run main.go target list --host server-hosts
List Targets: [OK]
  + host=192.168.10.143 [1/1] [OK]

Tid  Host          Target Name                                                       Store                   Portal
---  ----          -----------                                                       -----                   ------
1    server-hosts  iqn.2022-11.com.opencurve:curve.5a82e0b942bc472fe1de2059b971b7bd  cbd:pool//test_curve_   192.168.10.143:3260
2    server-hosts  iqn.2022-11.com.opencurve:curve.d97372e236558863e4ffc63dcfa7eb27  cbd:pool//test1_curve_  192.168.10.143:3260
3    server-hosts  iqn.2022-11.com.opencurve:curve.41f7dfa48ebe871dd74b2db0d88f1243  cbd:pool//test2_curve_  192.168.10.143:3260

@mfordjody
Copy link
Contributor Author

mfordjody commented Nov 24, 2022

curve@client-hosts:~/curveadm/cmd/curveadm$ go run main.go target add curve:/test --host server-hosts --create --size 30GiB --blocksize 4kiB
Add Target: [OK]
  + host=server-hosts  volume=/test [1/1] [OK]

Add target (curve:/test) to server-hosts success ^_^
curve@client-hosts:~/curveadm/cmd/curveadm$ go run main.go target add curve:/test --host server-hosts --create --size 30GiB --blocksize 4kiB
Add Target: [ERROR]
  + host=server-hosts  volume=/test [0/1] [ERROR]
---
Error-Code: 630009
Error-Description: run a command in container failed (docker exec CONTAINER COMMAND)
Error-Clue: tgtadm: this target already exists
            tgtadm target new failed
How to Solve:
  * Website: https://github.com/opencurve/curveadm/wiki/errno6#630009
  * Log: /home/curve/.curveadm/logs/curveadm-2022-11-24_17-57-32.log
  * WeChat: opencurve_bot
exit status 1
curve@client-hosts:~/curveadm/cmd/curveadm$ cat /home/curve/.curveadm/logs/curveadm-2022-11-24_17-57-32.log
2022-11-24 17:57:34     [ERR]:  (log.go:109):   Execute command
    remoteAddr: curve@192.168.10.143:22
    command: sudo docker exec  curvebs-target-daemon /bin/bash /curvebs/tools/sbin/target.sh curve /test true 30 4096
    output: tgtadm: this target already exists
tgtadm target new failed
    error: Process exited with status 1
curve@client-hosts:~/curveadm/cmd/curveadm$ go run main.go target list --host server-hosts
List Targets: [OK]
  + host=192.168.10.143 [1/1] [OK]

Tid  Host          Target Name                                                       Store                  Portal
---  ----          -----------                                                       -----                  ------
1    server-hosts  iqn.2022-11.com.opencurve:curve.5a82e0b942bc472fe1de2059b971b7bd  cbd:pool//test_curve_  192.168.10.143:3260

Copy link
Collaborator

@Cyber-SiKu Cyber-SiKu left a comment

Choose a reason for hiding this comment

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

Merge multiple commits into one.

@mfordjody
Copy link
Contributor Author

done

Cyber-SiKu
Cyber-SiKu previously approved these changes Nov 25, 2022
Copy link
Collaborator

@Cyber-SiKu Cyber-SiKu left a comment

Choose a reason for hiding this comment

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

LGTM!

flags.StringVarP(&options.filename, "conf", "c", "client.yaml", "Specify client configuration file")

flags.StringVar(&options.blocksize, "blocksize", "512B", "Specify volume blocksize")
Copy link

Choose a reason for hiding this comment

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

default 4096B

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@cw123
Copy link

cw123 commented Nov 28, 2022

看起来有两个地方都增加了blocksize的改动,一个map的时候,一个是add target的时候。

map的地方,map命令使用curve-nbd map,这个接收的参数不包含blocksize,而且这个命令没有测试结果。

另一个是add target的地方,看起主要逻辑是正确的,遗漏了一点,blocksize默认应该是4096B。

请确认一下,map.go中的逻辑是否正确。

It seems that there are two places where the changes of blocksize have been added, one for map and one for add target.

For map, the map command uses curve-nbd map, the received parameter does not include blocksize, and this command has no test results.

The other is add target. It seems that the main logic is correct. One thing is missing. The default blocksize should be 4096B.

Please confirm whether the logic in map.go is correct.

@mfordjody
Copy link
Contributor Author

mfordjody commented Nov 28, 2022

Blocksize not specified

root@client-hosts:/home/curve/curveadm/cmd/curveadm# go run main.go target add curve:/test1 --host server-hosts --create --size 30GiB
Add Target: [OK]
  + host=server-hosts  volume=/test1 [1/1] [OK]

Add target (curve:/test1) to server-hosts success ^_^
root@client-hosts:/home/curve/curveadm/cmd/curveadm# go run main.go target add curve:/test1 --host server-hosts --create --size 30GiB
Add Target: [ERROR]
  + host=server-hosts  volume=/test1 [0/1] [ERROR]
---
Error-Code: 630009
Error-Description: run a command in container failed (docker exec CONTAINER COMMAND)
Error-Clue: tgtadm: this target already exists
            tgtadm target new failed
How to Solve:
  * Website: https://github.com/opencurve/curveadm/wiki/errno6#630009
  * Log: /root/.curveadm/logs/curveadm-2022-11-28_22-48-41.log
  * WeChat: opencurve_bot
exit status 1
root@client-hosts:/home/curve/curveadm/cmd/curveadm# cat /root/.curveadm/logs/curveadm-2022-11-28_22-48-41.log
2022-11-28 22:48:42     [ERR]:  (log.go:109):   Execute command
    remoteAddr: curve@192.168.10.143:22
    command: sudo docker exec  curvebs-target-daemon /bin/bash /curvebs/tools/sbin/target.sh curve /test1 true 30 4096
    output: tgtadm: this target already exists
tgtadm target new failed
    error: Process exited with status 1

@mfordjody
Copy link
Contributor Author

mfordjody commented Nov 28, 2022

Blocksize specified

root@client-hosts:/home/curve/curveadm/cmd/curveadm# go run main.go target add curve:/test2 --host server-hosts --create --size 20GiB --blocksize 1kiB
Add Target: [OK]
  + host=server-hosts  volume=/test2 [1/1] [OK]

Add target (curve:/test2) to server-hosts success ^_^
root@client-hosts:/home/curve/curveadm/cmd/curveadm# go run main.go target add curve:/test2 --host server-hosts --create --size 20GiB --blocksize 1kiB
Add Target: [ERROR]
  + host=server-hosts  volume=/test2 [0/1] [ERROR]
---
Error-Code: 630009
Error-Description: run a command in container failed (docker exec CONTAINER COMMAND)
Error-Clue: tgtadm: this target already exists
            tgtadm target new failed
How to Solve:
  * Website: https://github.com/opencurve/curveadm/wiki/errno6#630009
  * Log: /root/.curveadm/logs/curveadm-2022-11-28_22-50-12.log
  * WeChat: opencurve_bot
exit status 1
root@client-hosts:/home/curve/curveadm/cmd/curveadm# cat /root/.curveadm/logs/curveadm-2022-11-28_22-50-12.log
2022-11-28 22:50:13     [ERR]:  (log.go:109):   Execute command
    remoteAddr: curve@192.168.10.143:22
    command: sudo docker exec  curvebs-target-daemon /bin/bash /curvebs/tools/sbin/target.sh curve /test2 true 20 1024
    output: tgtadm: this target already exists
tgtadm target new failed
    error: Process exited with status 1

@mfordjody
Copy link
Contributor Author

curve@client-hosts:~/curveadm/cmd/curveadm$ go run main.go map curve:/test --host server-hosts -c client.yaml --create --size 10GiB
Check Kernel Module: [OK]
  + host=server-hosts  module=nbd [1/1] [OK]

Start NEBD Service: [OK]
  + hostname=192.168.10.143  image=opencurvedocker/curvebs:v1.2 [1/1] [OK]

Create Volume: [OK]
  + hostname=192.168.10.143  image=opencurvedocker/curvebs:v1.2 [1/1] [OK]

Map Volume: [OK]
  + hostname=192.168.10.143  volume=curve:/test [1/1] [OK]

Map curve:/test to server-hosts nbd device success ^_^
curve@client-hosts:~/curveadm/cmd/curveadm$ go run main.go map curve:/test --host server-hosts -c client.yaml --create --size 10GiB
Check Kernel Module: [OK]
  + host=server-hosts  module=nbd [1/1] [OK]

Start NEBD Service: [ERROR]
  + hostname=192.168.10.143  image=opencurvedocker/curvebs:v1.2 [0/1] [ERROR]
---
Error-Code: 420000
Error-Description: volume already mapped
Error-Clue: volume: curve:/test
How to Solve:
  * Website: https://github.com/opencurve/curveadm/wiki/errno4#420000
  * Log: /home/curve/.curveadm/logs/curveadm-2022-11-29_16-01-15.log
  * WeChat: opencurve_bot
exit status 1
curve@client-hosts:~/curveadm/cmd/curveadm$ cat /home/curve/.curveadm/logs/curveadm-2022-11-29_16-01-15.log
curve@client-hosts:~/curveadm/cmd/curveadm$ go run main.go map curve:/test1 --host server-hosts -c client.yaml --create --size 10GiB --blocksize 4kiB
Check Kernel Module: [OK]
  + host=server-hosts  module=nbd [1/1] [OK]

Start NEBD Service: [OK]
  + hostname=192.168.10.143  image=opencurvedocker/curvebs:v1.2 [1/1] [OK]

Create Volume: [OK]
  + hostname=192.168.10.143  image=opencurvedocker/curvebs:v1.2 [1/1] [OK]

Map Volume: [OK]
  + hostname=192.168.10.143  volume=curve:/test1 [1/1] [OK]

Map curve:/test1 to server-hosts nbd device success ^_^
curve@client-hosts:~/curveadm/cmd/curveadm$ curveadm client status
Get Client Status: [OK]

Id            Kind     Host          Container Id  Status             Aux Info
--            ----     ----          ------------  ------             --------
d056f4d680dd  curvebs  server-hosts  2a7d0b491f2b  Up 25 seconds      {"user":"curve","volume":"/test1"}
b96b111a2066  curvebs  server-hosts  356ed3034de8  Up About a minute  {"user":"curve","volume":"/test"}

Signed-off-by: mfordjody <11638005@qq.com>

fix int

Signed-off-by: mfordjody <11638005@qq.com>

fix map

Signed-off-by: mfordjody <11638005@qq.com>

add target.sh

Signed-off-by: mfordjody <11638005@qq.com>

Update add.go

Signed-off-by: mfordjody <mfordjody@gmail.com>

Update add.go

Signed-off-by: mfordjody <mfordjody@gmail.com>

Update add.go

Signed-off-by: mfordjody <mfordjody@gmail.com>

Update add_target.go

Signed-off-by: mfordjody <mfordjody@gmail.com>

Update errno.go

Signed-off-by: mfordjody <mfordjody@gmail.com>

Update add.go

Signed-off-by: mfordjody <mfordjody@gmail.com>

Update add.go

Signed-off-by: mfordjody <mfordjody@gmail.com>

fix target

Signed-off-by: mfordjody <mfordjody@gmail.com>

Update target.go

Signed-off-by: mfordjody <mfordjody@gmail.com>

Update target.go

Signed-off-by: mfordjody <mfordjody@gmail.com>

Update target.go

Signed-off-by: mfordjody <mfordjody@gmail.com>

Update target.go

Signed-off-by: mfordjody <mfordjody@gmail.com>

Update add.go

Signed-off-by: mfordjody <mfordjody@gmail.com>

Update errno.go

Signed-off-by: mfordjody <mfordjody@gmail.com>

Update add_target.go

Signed-off-by: mfordjody <mfordjody@gmail.com>

Update map.go

Signed-off-by: mfordjody <mfordjody@gmail.com>

Update map.go

Signed-off-by: mfordjody <mfordjody@gmail.com>

Update map.go

Signed-off-by: mfordjody <mfordjody@gmail.com>

Update add.go

Signed-off-by: mfordjody <mfordjody@gmail.com>

Update errno.go

Signed-off-by: mfordjody <mfordjody@gmail.com>

Update map.go

Signed-off-by: mfordjody <mfordjody@gmail.com>

Update add.go

Signed-off-by: mfordjody <mfordjody@gmail.com>

delete map blocksize

Signed-off-by: mfordjody <11638005@qq.com>
@Cyber-SiKu Cyber-SiKu merged commit 9f76de0 into opencurve:master Dec 1, 2022
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.

4 participants