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

Docker/entrypoint: support disk mounting in service container #2285

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

legionxiong
Copy link

@legionxiong legionxiong commented Mar 3, 2023

What problem does this PR solve?

Issue Number: #2283

Problem Summary:

What is changed and how it works?

What's Changed: docker/debian9/entrypoint.sh

How it Works: disk device will be mounted by entrypoint.sh if --disk parameter was injected when deploy curvebs.

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

[[ ! -d $disk_mount_point ]] && die "disk mount point $disk_mount_point does not exist.\n"
mount -o rw,errors=remount-ro $g_disk $disk_mount_point
[[ $? -ne 0 ]] && die "mount disk device $g_disk to $disk_mount_point failed.\n"
fi
g_binary="$g_prefix/sbin/curvebs-chunkserver"
g_start_args="--conf=$conf_path"
;;
Copy link

Choose a reason for hiding this comment

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

from the code structure,

The code structure looks good with comments and syntax highlighting to make it easier for readers to understand. There are several global variables declared at the beginning, followed by the function definitions and finally the main logic.

In terms of potential bugs, it looks like the code is missing some validation and error-handling. For example, the -d or --disk argument is not being validated and it is not clear what is expected as an input here. Additionally, the code is not checking if the provided device is mounted correctly before using it. It would be a good idea to add some validations and error handling around these parts of the code.

It would also be helpful to add some logging statements to the code to help with debugging. This could include log statements for the disk mount process, for any errors encountered, and for other important events in the program's execution.

Overall, the code looks good and is easy to read. However, it can be improved with some validations and error-handling. Additionally, adding some logging statements would be helpful for debugging purposes.

[[ ! -d $disk_mount_point ]] && die "disk mount point $disk_mount_point does not exist.\n"
mount -o rw,errors=remount-ro $g_disk $disk_mount_point
[[ $? -ne 0 ]] && die "mount disk device $g_disk to $disk_mount_point failed.\n"
fi
g_binary="$g_prefix/sbin/curvebs-chunkserver"
g_start_args="--conf=$conf_path"
;;
Copy link

Choose a reason for hiding this comment

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

the code review.

From the patch, it seems that you have added some lines of code for role chunkserver, to mount the disk device to a mount point.

The code looks good but there are a few improvement suggestions that can be made.

  1. Check if the mount point already exists before trying to remount it
  2. Check if the disk device is already mounted before attempting to mount it
  3. Add a timeout to the mount command
  4. Add a force flag to the mount command in case of any errors
  5. Add a logging statement to track the mount command execution status and any errors
  6. Add a check to make sure the mount command executed successfully

Copy link
Author

Choose a reason for hiding this comment

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

  1. Done.
  2. The disk device will be mounted in container, and umounted from host by curveadm. It is guaranteed by curveadm.
  3. Unnecessary for local disk device.
  4. The service(chunkserver) container should exit if any errors encounted during disk mounting.
  5. The is tracked by container's log.
  6. Cannot make sure the mount command to be executed successfully, it may fail.

[[ ! -d $disk_mount_point ]] && die "disk mount point $disk_mount_point does not exist.\n"
mount -o rw,errors=remount-ro $g_disk $disk_mount_point
[[ $? -ne 0 ]] && die "mount disk device $g_disk to $disk_mount_point failed.\n"
fi
g_binary="$g_prefix/sbin/curvebs-chunkserver"
g_start_args="--conf=$conf_path"
;;
Copy link

Choose a reason for hiding this comment

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

with a brief overview:
This patch adds a new command line parameter, --disk, to the entrypoint.sh script. This parameter is used for chunkserver role and allows for mounting a disk device to a specified mount point. It also adds a global variable, disk_mount_point, which specifies the mount point for the device.

Now let's look at the code review:

  1. The code checks if the --disk parameter is present and exits with an error message if not.
  2. The global variable, disk_mount_point, is properly set.
  3. The code checks if the mount point exists and exits with an error message if it doesn't.
  4. The code uses the mount command to mount the device.
  5. The code checks the return value of the mount command and exits with an error message if necessary.

Overall, this patch looks good. There are no obvious bugs in the code, and it should work as intended. However, there are a few areas that could be improved:

  1. The code does not check if the device being mounted is valid. It should check if the device is accessible and if it is a valid block device before attempting to mount it.
  2. The code does not check the return value of the mount command to determine if the mount was successful. It should check the return value and print an appropriate error message if the mount fails.
  3. The code should log all mount operations, including failed attempts. This will help with debugging any issues that may arise.

@Cyber-SiKu
Copy link
Contributor

cicheck

@wuhongsong
Copy link
Contributor

@legionxiong continue?

@Cyber-SiKu
Copy link
Contributor

@legionxiong continue?

@legionxiong
Copy link
Author

@legionxiong continue?

Resubmitted.

1 similar comment
@legionxiong
Copy link
Author

@legionxiong continue?

Resubmitted.

@legionxiong
Copy link
Author

cicheck

@wuhongsong
Copy link
Contributor

@Cyber-SiKu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants