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

Support formatting and mounting GCE PD without 'safe_format_and_mount' #8530

Merged
merged 1 commit into from Aug 26, 2015
Merged

Support formatting and mounting GCE PD without 'safe_format_and_mount' #8530

merged 1 commit into from Aug 26, 2015

Conversation

ghost
Copy link

@ghost ghost commented May 19, 2015

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.

@ghost
Copy link
Author

ghost commented May 19, 2015

@ddysher What do you think ?
@childsb with this PR plus #7847 GCE PD works out of the box on Atomic

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") {
Copy link
Contributor

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?

Copy link
Author

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.

@ghost
Copy link
Author

ghost commented May 21, 2015

@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" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

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.

@ddysher
Copy link
Contributor

ddysher commented May 26, 2015

some minor comments. make sure PD e2d passes.

@ghost
Copy link
Author

ghost commented May 26, 2015

@ddysher I have updated the patch to address your comments. PD e2e tests are passing.

@ddysher
Copy link
Contributor

ddysher commented May 27, 2015

LGTM
but need triage for code freeze

@ddysher ddysher added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 27, 2015
@thockin
Copy link
Member

thockin commented May 28, 2015

I want to have a look at this.

@thockin thockin assigned thockin and unassigned ddysher May 28, 2015
@rjnagal
Copy link
Contributor

rjnagal commented May 29, 2015

@thockin removing lgtm while you take a look and decide.

@rjnagal rjnagal removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 29, 2015
@erictune
Copy link
Member

erictune commented Jun 1, 2015

@thockin push this to post-1.0?

@erictune erictune added this to the v1.0-post milestone Jun 1, 2015
@ghost
Copy link
Author

ghost commented Jun 1, 2015

@thockin @erictune it would be great of this can patch can make it into 1.0 as it enables GCE PD on Atomic Host and other custom images uploaded by users to GCE out of the box

@thockin
Copy link
Member

thockin commented Jun 2, 2015

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.
Copy link
Member

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.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

@thockin
Copy link
Member

thockin commented Jun 2, 2015

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?

@ghost
Copy link
Author

ghost commented Jun 4, 2015

@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.
e2e PD tests are passing

@thockin
Copy link
Member

thockin commented Jun 5, 2015

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

@k8s-bot
Copy link

k8s-bot commented Jun 10, 2015

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
Copy link
Author

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 :)

@ghost
Copy link
Author

ghost commented Jun 11, 2015

@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 ?

@markturansky
Copy link
Contributor

@swagiaal we need to make sure these upstream PRs that were patched into OpenShift stay in sync downstream.

@bgrant0607 bgrant0607 removed this from the v1.0-post milestone Jul 24, 2015
@ghost
Copy link
Author

ghost commented Jul 30, 2015

@thockin Does this still have your LGTM after expansion to AWS EBS ?

@ghost
Copy link
Author

ghost commented Aug 17, 2015

@thockin could you take another look at this ?

@saad-ali
Copy link
Member

@swagiaal There have been a ton of changes since this was created, could you rebase?

@k8s-bot
Copy link

k8s-bot commented Aug 24, 2015

GCE e2e build/test failed for commit f27d5d564c4666ea7764c71e28fc555e6b261852.

@k8s-bot
Copy link

k8s-bot commented Aug 24, 2015

GCE e2e build/test passed for commit ededecf73a18032bf33b195bfe5ce0d82f43c1c9.

@ghost
Copy link
Author

ghost commented Aug 24, 2015

@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
Copy link
Member

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 #.

@saad-ali
Copy link
Member

Thanks for the clean up here @swagiaal
PR LGTM mod one minor nit

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>
@k8s-bot
Copy link

k8s-bot commented Aug 26, 2015

GCE e2e build/test passed for commit ab0258f.

@ghost
Copy link
Author

ghost commented Aug 26, 2015

@saad-ali thanks for reviewing... comment addressed

@saad-ali
Copy link
Member

Thanks @swagiaal
LGTM

@saad-ali saad-ali added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 26, 2015
yujuhong added a commit that referenced this pull request Aug 26, 2015
Support formatting and mounting GCE PD without 'safe_format_and_mount'
@yujuhong yujuhong merged commit a5fe33b into kubernetes:master Aug 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants