-
Notifications
You must be signed in to change notification settings - Fork 38.8k
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
Support formatting and mounting GCE PD without 'safe_format_and_mount' #8530
Conversation
glog.V(5).Infof("error running /usr/share/google/safe_format_and_mount\n%s", string(dataOut)) | ||
glog.V(5).Infof("error running %s\n%s", safeFormatAndMountPath, string(dataOut)) | ||
// if safe_format_and_mount is not available on this system use linux utilities directly. | ||
if strings.Contains(err.Error(), safeFormatAndMountPath+": no such file or directory") { |
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.
This is brittle, at least, you need to lowercase err.Error(). BTW, I think shell use upper case for error message?, i.e. No such file or directory.
Also, why not check file existence first?
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.
I have changed this to check for the existence of the file instead of trying to match the error.
@ddysher I have addressed your comments and responded to your questions. What do you think ? |
cmd := mounter.runner.Command("file", args...) | ||
dataOut, err := cmd.CombinedOutput() | ||
|
||
if err == nil && strings.TrimSpace(string(dataOut)) == disk+": data" { |
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.
The bash script uses filesystem, is it a better condition to check?
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.
Yeah that makes more sense. Done.
some minor comments. make sure PD e2d passes. |
@ddysher I have updated the patch to address your comments. PD e2e tests are passing. |
LGTM |
I want to have a look at this. |
@thockin removing lgtm while you take a look and decide. |
@thockin push this to post-1.0? |
to the goal of "custom images uploaded by users to GCE" there are a lot of things that you really want to do to in order to properly be a GCE image. https://cloud.google.com/compute/docs/tutorials/building-images |
dataOut, err := cmd.CombinedOutput() | ||
if err != nil { | ||
glog.V(5).Infof("error running /usr/share/google/safe_format_and_mount\n%s", string(dataOut)) | ||
glog.V(5).Infof("error running %s\n%s", safeFormatAndMountPath, string(dataOut)) | ||
// if safe_format_and_mount is not available on this system use linux utilities directly. |
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.
Why support both ways? If this is equivalent, then we should drop the external dependency.
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.
Done.
I am OK with this overall - it's pretty straightforward. Why not get rid of support for the old legacy script and just do it ourselves always? |
@thockin I made the changes you asked for. Dropping the use of the script made writing the test easier so I expanded the test to better cover the code. I also removed the check for the specific error message as older versions of mount have a different message. |
The chaneg looks good, but I am nervous putting this in at this point. I'd rather this wait until after 1.0 - is that going to derail anything? LGTM, hold until after 1.0 |
Can one of the admins verify that this patch is reasonable to test? (reply "ok to test", or if you trust the user, reply "add to whitelist") If this message is too spammy, please complain to ixdy. |
// safe_format_and_mount is a utility script on AWS VMs that probes a persistent disk, and if | ||
// necessary formats it before mounting it. | ||
// This eliminates the necessity to format a PD before it is used with a Pod on AWS. | ||
// TODO: port this script into Go and use it for all Linux platforms |
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.
Did not notice this TODO last time :)
@thockin So it turns out the AWS EBS plugin was using the safe_format_and_mount script as well so I moved it to the mount package and now it shared between GCE PD and AWS EBS... WDYT ? |
@swagiaal we need to make sure these upstream PRs that were patched into OpenShift stay in sync downstream. |
@thockin Does this still have your LGTM after expansion to AWS EBS ? |
@thockin could you take another look at this ? |
@swagiaal There have been a ton of changes since this was created, could you rebase? |
GCE e2e build/test failed for commit f27d5d564c4666ea7764c71e28fc555e6b261852. |
GCE e2e build/test passed for commit ededecf73a18032bf33b195bfe5ce0d82f43c1c9. |
@saad-ali rebased... thanks for taking a look! |
cmd := mounter.Runner.Command("file", args...) | ||
dataOut, err := cmd.CombinedOutput() | ||
|
||
// TODO (swagiaal): check if this disk has partitions and return false, and |
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.
Please open an issue to track this TODO and update this comment to include to issue #.
Thanks for the clean up here @swagiaal |
The GCE PD plugin uses safe_format_and_mount found on standard GCE images: https://github.com/GoogleCloudPlatform/compute-image-packages/blob/master/google-startup-scripts/usr/share/google/safe_format_and_mount On custom images where this is not available pods fail to format and mount GCE PDs. This patch uses linux utilities in a similar way to the safe_format_and_mount script to format and mount the GCE PD and AWS EBC devices. That is first attempt a mount. If mount fails try to use file to investigate the device. If 'file' fails to get any information about the device and simply returns "data" then assume the device is not formatted and format it and attempt to mount it again. Signed-off-by: Sami Wagiaalla <swagiaal@redhat.com>
GCE e2e build/test passed for commit ab0258f. |
@saad-ali thanks for reviewing... comment addressed |
Thanks @swagiaal |
Support formatting and mounting GCE PD without 'safe_format_and_mount'
The GCE PD plugin uses safe_format_and_mount found on standard GCE images:
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/master/google-startup-scripts/usr/share/google/safe_format_and_mount
On custom images where this is not available pods fail to format and mount GCE PDs.
This patch uses linux utilities in a similar way to the safe_format_and_mount
script to format and mount the GCE PD device. That is first attempt a mount.
If mount fails and detects a file system "null" try to use file to investigate
the device. If 'file' fails to get any information about the device and simply
returns "data" then assume the device is not formatted and format it and attempt
to mount it again.