-
Notifications
You must be signed in to change notification settings - Fork 72
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: support direct disk mounting for service container #194
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,6 @@ import ( | |
|
||
"github.com/fatih/color" | ||
"github.com/opencurve/curveadm/cli/cli" | ||
"github.com/opencurve/curveadm/internal/common" | ||
comm "github.com/opencurve/curveadm/internal/common" | ||
"github.com/opencurve/curveadm/internal/configure/disks" | ||
"github.com/opencurve/curveadm/internal/configure/topology" | ||
|
@@ -40,7 +39,8 @@ import ( | |
) | ||
|
||
const ( | ||
COMMIT_EXAMPLE = `Examples: | ||
HOST_DEVICE_SEP = ":" | ||
COMMIT_EXAMPLE = `Examples: | ||
$ curveadm disks commit /path/to/disks.yaml # Commit disks` | ||
) | ||
|
||
|
@@ -89,35 +89,43 @@ func readAndCheckDisks(curveadm *cli.CurveAdm, options commitOptions) (string, [ | |
} | ||
|
||
// 3) check disks data | ||
dcs, err = disks.ParseDisks(data, curveadm) | ||
dcs, err = disks.ParseDisks(data) | ||
return data, dcs, err | ||
} | ||
|
||
func assambleNewDiskRecords(dcs []*disks.DiskConfig, | ||
oldDiskRecords []storage.Disk) ([]storage.Disk, []storage.Disk) { | ||
keySep := ":" | ||
newDiskMap := make(map[string]bool) | ||
|
||
// "ServiceMountDevice=0" means write disk UUID into /etc/fstab for host mounting. | ||
// "ServiceMountDevice=1" means not to update /etc/fstab, the disk UUID will be wrote | ||
// into the config of service(chunkserver) container for disk automatic mounting. | ||
serviceMountDevice := 0 // 0: false, 1: true | ||
var newDiskRecords, diskRecordDeleteList []storage.Disk | ||
for _, dc := range dcs { | ||
for _, host := range dc.GetHost() { | ||
key := strings.Join([]string{host, dc.GetDevice()}, keySep) | ||
key := strings.Join([]string{host, dc.GetDevice()}, HOST_DEVICE_SEP) | ||
newDiskMap[key] = true | ||
if dc.GetServiceMount() { | ||
serviceMountDevice = 1 | ||
} | ||
newDiskRecords = append( | ||
newDiskRecords, storage.Disk{ | ||
Host: host, | ||
Device: dc.GetDevice(), | ||
Size: comm.DISK_DEFAULT_NULL_SIZE, | ||
URI: comm.DISK_DEFAULT_NULL_URI, | ||
MountPoint: dc.GetMountPoint(), | ||
FormatPercent: dc.GetFormatPercent(), | ||
ChunkServerID: comm.DISK_DEFAULT_NULL_CHUNKSERVER_ID, | ||
Host: host, | ||
Device: dc.GetDevice(), | ||
Size: comm.DISK_DEFAULT_NULL_SIZE, | ||
URI: comm.DISK_DEFAULT_NULL_URI, | ||
MountPoint: dc.GetMountPoint(), | ||
ContainerImage: dc.GetContainerImage(), | ||
FormatPercent: dc.GetFormatPercent(), | ||
ChunkServerID: comm.DISK_DEFAULT_NULL_CHUNKSERVER_ID, | ||
ServiceMountDevice: serviceMountDevice, | ||
}) | ||
} | ||
} | ||
|
||
for _, dr := range oldDiskRecords { | ||
key := strings.Join([]string{dr.Host, dr.Device}, keySep) | ||
key := strings.Join([]string{dr.Host, dr.Device}, HOST_DEVICE_SEP) | ||
if _, ok := newDiskMap[key]; !ok { | ||
diskRecordDeleteList = append(diskRecordDeleteList, dr) | ||
} | ||
|
@@ -127,19 +135,16 @@ func assambleNewDiskRecords(dcs []*disks.DiskConfig, | |
} | ||
|
||
func writeDiskRecord(dr storage.Disk, curveadm *cli.CurveAdm) error { | ||
if diskRecords, err := curveadm.Storage().GetDisk( | ||
common.DISK_FILTER_DEVICE, dr.Host, dr.Device); err != nil { | ||
if err := curveadm.Storage().SetDisk( | ||
dr.Host, | ||
dr.Device, | ||
dr.MountPoint, | ||
dr.ContainerImage, | ||
dr.FormatPercent, | ||
dr.ServiceMountDevice); err != nil { | ||
return err | ||
} else if len(diskRecords) == 0 { | ||
if err := curveadm.Storage().SetDisk( | ||
dr.Host, | ||
dr.Device, | ||
dr.MountPoint, | ||
dr.ContainerImage, | ||
dr.FormatPercent); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
|
@@ -153,15 +158,17 @@ func syncDiskRecords(data string, dcs []*disks.DiskConfig, | |
oldDiskRecordsString := tui.FormatDisks(oldDiskRecords) | ||
newDiskRecordsString := tui.FormatDisks(newDiskRecords) | ||
|
||
if !options.slient { | ||
diff := utils.Diff(oldDiskRecordsString, newDiskRecordsString) | ||
curveadm.WriteOutln(diff) | ||
} | ||
if len(newDiskRecords) != len(oldDiskRecords) { | ||
if !options.slient { | ||
diff := utils.Diff(oldDiskRecordsString, newDiskRecordsString) | ||
curveadm.WriteOutln(diff) | ||
} | ||
|
||
pass := tuicomm.ConfirmYes("Disk changes are showing above. Do you want to continue?") | ||
if !pass { | ||
curveadm.WriteOut(tuicomm.PromptCancelOpetation("commit disk table")) | ||
return errno.ERR_CANCEL_OPERATION | ||
pass := tuicomm.ConfirmYes("Disk changes are showing above. Do you want to continue?") | ||
if !pass { | ||
curveadm.WriteOut(tuicomm.PromptCancelOpetation("commit disk table")) | ||
return errno.ERR_CANCEL_OPERATION | ||
} | ||
} | ||
|
||
// write new disk records | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. code review: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Already done. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,9 +155,17 @@ func runFormat(curveadm *cli.CurveAdm, options formatOptions) error { | |
if err != nil { | ||
return err | ||
} | ||
fc.UseDiskUri = true | ||
chunkserverId := dr.ChunkServerID | ||
if len(chunkserverId) > 1 { | ||
|
||
fc.FromDiskRecord = true | ||
|
||
// "ServiceMountDevice=0" means write disk UUID into /etc/fstab for host mounting. | ||
// "ServiceMountDevice=1" means not to update /etc/fstab, the disk UUID will be wrote | ||
// into the config of service(chunkserver) container for disk automatic mounting. | ||
if dr.ServiceMountDevice != 0 { | ||
fc.ServiceMountDevice = true | ||
} | ||
|
||
if dr.ChunkServerID != comm.DISK_DEFAULT_NULL_CHUNKSERVER_ID { | ||
// skip formatting the disk with nonempty chunkserver id | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with the code review The code looks good and there are no obvious bugs. However, it would be better to add some comment in the code to provide a better explanation of why ServiceMountDevice is being set to true. Additionally, it would be helpful to add an error handling block if the ServiceMountDevice field is not valid. This can help to detect any errors at runtime and prevent any unexpected behavior. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the code review.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
continue | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with the code patch review:
legionxiong marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the code review:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with code review of the above code.
In summary, the code looks good but could be improved by adding better comments and checks for errors. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
global: | ||
format_percent: 95 | ||
container_image: opencurvedocker/curvebs:v1.2 | ||
service_mount_device: false # disk device will be mounted by service(chunkserver) container of curvebs if set "true", default "false" | ||
host: | ||
- curve-1 | ||
- curve-2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the code review
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
- curve-3 | ||
|
||
disk: | ||
- device: /dev/sdb1 | ||
mount: /data/chunkserver0 | ||
- device: /dev/sdb1 # disk device path | ||
mount: /data/chunkserver0 # mount point for disk formatting, consistent with the "data_dir" field fo topology chunkserver service | ||
- device: /dev/sdc1 | ||
mount: /data/chunkserver1 | ||
format_percent: 90 | ||
format_percent: 90 # use a different value of disk format percent | ||
- device: /dev/sdd1 | ||
mount: /data/chunkserver2 | ||
exclude: # for the use case that some hosts have not certain disk device | ||
exclude: # for the use case that disk device does not exist in some hosts | ||
- curve-3 | ||
- device: /dev/sde1 | ||
mount: /data/chunkserver3 | ||
host: | ||
host: # override global host config, for the use case tht disk device only exists in some hosts | ||
- curve-1 | ||
- curve-2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the code review: First of all, it is important to check that the syntax of the code is correct and there are no errors. Additionally, it is important to ensure that the code is understandable, efficient, and secure. In this code patch, it appears that the formatting of the code is correct and the syntax is valid. In terms of security, it is important to ensure that all user input is validated and that the code does not contain any vulnerabilities. In the code patch, it appears that all user input is taken into account, and there are no potential security vulnerabilities present. The code also appears to be efficient, as it is written in a way that allows the program to perform its functions with minimal resource usage. Finally, it is important to ensure that the code is understandable. In this code patch, the comments provided make the code easy to understand and explain the purpose of each line. Overall, it appears that the code patch is well written and does not contain any issues. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. from the code review.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with the code review
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with code review
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. . The code patch looks good, and there are no obvious bugs or issues. The new service_mount_device flag looks useful and is consistent with the rest of the configuration. The new exclude flag looks useful too, allowing users to exclude hosts from configuration. There are some minor improvements that could be made. Firstly, it would be helpful to include a brief comment explaining what each field of the configuration does. Secondly, the formatting of the code could be improved by making sure all lines are indented correctly and using spaces instead of tabs. Overall the code looks good and should be safe to use. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,8 +57,8 @@ const ( | |
DISK_FILTER_MOUNT = "mount" | ||
DISK_FILTER_SERVICE = "service" | ||
DISK_EXCLUDE_HOST = "exclude" | ||
|
||
DISK_FORMAT_PERCENT = "format_percent" | ||
DISK_SERVICE_MOUNT_DEVICE = "service_mount_device" | ||
DISK_FORMAT_PERCENT = "format_percent" | ||
|
||
DISK_FORMAT_MOUNT_POINT = "mount" | ||
DISK_FORMAT_CONTAINER_IMAGE = "container_image" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with a brief review Secondly, DISK_SERVICE_MOUNT_DEVICE has been added which seems to be related to the service and mount constants. This is fine but you should provide more information about why this is needed. Lastly, DISK_FORMAT_PERCENT has been moved from the end of the list to the middle. This could lead to some confusion in code readability as the constants are ordered in an unusual way. It would be better to put the constants into some logical order. Overall, the code patch looks good and the changes appear to be valid. However, more information should be provided to explain why the changes were made. I hope this helps! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with the code review: The patch adds a new constant DISK_SERVICE_MOUNT_DEVICE to the existing list of constants. Its purpose is unclear but it seems to be related to the existing constant DISK_FILTER_MOUNT and DISK_FILTER_SERVICE. The patch also renames the existing constant DISK_FORMAT_PERCENT to DISK_FORMAT_PERCENT. This ensures that there are no conflicting names in the list of constants. Finally, the patch also adds two new constants DISK_FORMAT_MOUNT_POINT and DISK_FORMAT_CONTAINER_IMAGE which appear to be related to disk formatting. Overall, the patch looks to be well thought out and technically sound. No obvious bugs or risks have been identified. There may be opportunities for improvement, such as adding additional documentation to explain the purpose of the new constants. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. . The patch adds two constants DISK_SERVICE_MOUNT_DEVICE and DISK_FORMAT_PERCENT to the existing list of constants. The constants have been added in the right order(alphabetical) and the formatting is in place. However, a brief code review suggests that there could be some bug risks in this patch. For example, if the constants are used in some other part of the code without proper initialization, then it can lead to bugs. Additionally, if the constants are used in comparison with other constants, then it could lead to unexpected results. Also, the naming of the constants needs to be checked. The names should be self-explanatory and should convey the purpose of the constant. Lastly, it would be better to add proper comments to the constants so that other developers can understand the purpose of the constants quickly.
legionxiong marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the code review
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,7 @@ const ( | |
REQUIRE_BOOL | ||
REQUIRE_INT | ||
REQUIRE_POSITIVE_INTEGER | ||
REQUIRE_SLICE | ||
REQUIRE_STRING_SLICE | ||
) | ||
|
||
type ( | ||
|
@@ -82,6 +82,25 @@ func (itemset *ItemSet) GetAll() []*Item { | |
return itemset.items | ||
} | ||
|
||
func convertSlice[T int | string | any](key, value any) ([]T, error) { | ||
var slice []T | ||
if !utils.IsAnySlice(value) || len(value.([]any)) == 0 { | ||
return slice, errno.ERR_CONFIGURE_VALUE_REQUIRES_NONEMPTY_SLICE | ||
} | ||
anySlice := value.([]any) | ||
switch anySlice[0].(type) { | ||
case T: | ||
for _, str := range anySlice { | ||
slice = append(slice, str.(T)) | ||
} | ||
default: | ||
return slice, errno.ERR_UNSUPPORT_CONFIGURE_VALUE_TYPE. | ||
F("%s: %v", key, value) | ||
} | ||
|
||
return slice, nil | ||
} | ||
|
||
func (itemset *ItemSet) Build(key string, value interface{}) (interface{}, error) { | ||
item := itemset.Get(key) | ||
if item == nil { | ||
|
@@ -135,34 +154,12 @@ func (itemset *ItemSet) Build(key string, value interface{}) (interface{}, error | |
return v, nil | ||
} | ||
|
||
case REQUIRE_SLICE: | ||
anySlice := value.([]any) | ||
if len(anySlice) > 0 { | ||
switch anySlice[0].(type) { | ||
case string: | ||
return convertSlice[string](value), nil | ||
case int: | ||
return convertSlice[int](value), nil | ||
case bool: | ||
return convertSlice[bool](value), nil | ||
default: | ||
return []any{}, errno.ERR_UNSUPPORT_CONFIGURE_VALUE_TYPE. | ||
F("%s: %v", key, value) | ||
} | ||
} | ||
return []any{}, nil | ||
case REQUIRE_STRING_SLICE: | ||
return convertSlice[string](key, value) | ||
|
||
default: | ||
// do nothing | ||
} | ||
|
||
return value, nil | ||
} | ||
|
||
func convertSlice[T int | string | any](value any) []T { | ||
var slice []T | ||
for _, str := range value.([]any) { | ||
slice = append(slice, str.(T)) | ||
} | ||
return slice | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,14 @@ func (dc *DiskConfig) getInt(i *comm.Item) int { | |
return v.(int) | ||
} | ||
|
||
func (hc *DiskConfig) getBool(i *comm.Item) bool { | ||
v := hc.get(i) | ||
if v == nil { | ||
return false | ||
} | ||
return v.(bool) | ||
} | ||
|
||
func (dc *DiskConfig) getStrSlice(i *comm.Item) []string { | ||
v := dc.get(i) | ||
if v == nil { | ||
|
@@ -65,6 +73,7 @@ func (dc *DiskConfig) getStrSlice(i *comm.Item) []string { | |
|
||
func (dc *DiskConfig) GetContainerImage() string { return dc.getString(CONFIG_GLOBAL_CONTAINER_IMAGE) } | ||
func (dc *DiskConfig) GetFormatPercent() int { return dc.getInt(CONFIG_GLOBAL_FORMAT_PERCENT) } | ||
func (dc *DiskConfig) GetServiceMount() bool { return dc.getBool(CONFIG_GLOBAL_SERVICE_MOUNT_DEVICE) } | ||
func (dc *DiskConfig) GetHost() []string { return dc.getStrSlice(CONFIG_GLOBAL_HOST) } | ||
func (dc *DiskConfig) GetDevice() string { return dc.getString(CONFIG_DISK_DEVICE) } | ||
func (dc *DiskConfig) GetMountPoint() string { return dc.getString(CONFIG_DISK_MOUNT_POINT) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with the code review The code looks good, but there are a few points to consider.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we need some unit tests according to the 4th suggestion There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Agree. Does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We use go built-in unit testing and testify package to testifying our codes, there are a few test code: We are so much lacking of unit tests and integration tests, it leads the curveadm often unstable. It would be a huge improvement if we had unit tests and integration tests to guarantee curveadm stability. but then again, i think the integration testing is not so easy to implement. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I noticed these test files. I thought they were just part of checker. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's true, integration test is more complicated, especially the automatic one. Some mocking mechanism need to be introduced for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ,
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Already done. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the code review: The code patch looks good. The getBool() function has been added to the DiskConfig struct, which is used to retrieve a boolean value from the given item. The GetServiceMount() function uses the new getBool() function to get the service mount device status. Additionally, the GetHost() function has been modified to use the getStrSlice() function instead of the getString() function. This ensures that the host list is retrieved as a slice of strings rather than a single string. Overall, the code looks good. However, it would be beneficial to add some more tests to ensure that the new getBool() and getStrSlice() functions are working correctly. Additionally, it would be beneficial to have a comment explaining why the changes are being made.
legionxiong marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. code review The code looks mostly correct, however there are a few points to consider:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the code review: The code patch is relatively clean and easy to understand. It is adding a new function which returns a boolean value to the existing DiskConfig class. The name of the new function is getBool, which is appropriate for what it is doing. The code is properly indented and the logic is easy to follow. There are no obvious bugs in the code. However, it would be better to add some checks to make sure that the value being returned is actually a boolean type before returning it. This could be done by using an assertion or by using type switches. Overall, the code is well written and should not have any major issues. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,12 +48,20 @@ var ( | |
DEFAULT_FORMAT_PERCENT, | ||
) | ||
|
||
CONFIG_GLOBAL_SERVICE_MOUNT_DEVICE = itemset.Insert( | ||
common.DISK_SERVICE_MOUNT_DEVICE, | ||
comm.REQUIRE_BOOL, | ||
false, | ||
false, | ||
) | ||
|
||
CONFIG_GLOBAL_HOST = itemset.Insert( | ||
common.DISK_FILTER_HOST, | ||
comm.REQUIRE_SLICE, | ||
comm.REQUIRE_STRING_SLICE, | ||
false, | ||
nil, | ||
) | ||
|
||
CONFIG_DISK_DEVICE = itemset.Insert( | ||
common.DISK_FILTER_DEVICE, | ||
comm.REQUIRE_STRING, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with the code review
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it should be a AI bug, since there are no such variable called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the code review:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code looks good. It seems that you are adding a configuration setting for the global service mount device. The code looks clean and well written. As for improvements, I suggest adding a comment above the new configuration setting to explain what it does and why it is needed. This will help make the code more readable and easier to maintain in the future. If there is any risk of bugs, it would be good to add some unit tests to cover the new code. This will ensure that the new code works as expected and will reduce the risk of introducing bugs. Overall, this looks like a good patch and I think it should work as expected.
legionxiong marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. code review:
|
||
|
@@ -70,7 +78,7 @@ var ( | |
|
||
CONFIG_DISK_HOST_EXCLUDE = itemset.Insert( | ||
common.DISK_EXCLUDE_HOST, | ||
comm.REQUIRE_SLICE, | ||
comm.REQUIRE_STRING_SLICE, | ||
false, | ||
nil, | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with Code Review:
|
||
|
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.
with the code review:
It looks like a variable
serviceMountDevice
was added in line 98, this variable should be initialized to 0 rather than an arbitrary number.In the function
writeDiskRecord
the linesif diskRecords, err := curveadm.Storage().GetDisk(common.DISK_FILTER_DEVICE, dr.Host, dr.Device); err != nil {
and} else if len(diskRecords) == 0 {
should be removed as they are redundant.In the function
syncDiskRecords
a check should be added to ensure that the number of new disk records is equal to the number of old disk records before confirming if the user wants to continue.The variable
keySep
in the functionassambleNewDiskRecords
should be declared as a constant as it has a fixed value.The code should be formatted consistently across the patch to improve readability.
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.