Skip to content

Conversation

mvisonneau
Copy link
Contributor

@mvisonneau mvisonneau commented Dec 13, 2019

This is a reopen of kubernetes/kubernetes#77982, necessary for #126

What this PR does / why we need it:

The current workflow of the mount on linux tries to mount the disk before assessing if a FS actually
exists onto it. This commit review this implementation. Here is what would happen now:

  • Validate that the disk is formatted
    • true : mount it
    • false : format it then mount it

This also ensures that the disk FS type is the one we are expecting before attempting to mount it.

What would be nice is to also add some tests for the format and mount functions.

What type of PR is this?

/kind bug

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 13, 2019
@k8s-ci-robot
Copy link
Contributor

Welcome @mvisonneau!

It looks like this is your first PR to kubernetes/utils 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/utils has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 13, 2019
@mvisonneau mvisonneau changed the title Validate the existence of filesystem on disk before attempting to mou… Validate the existence of filesystem before attempting to mount it Dec 13, 2019
@mvisonneau mvisonneau changed the title Validate the existence of filesystem before attempting to mount it Validate the existence of filesystem before attempting to mount it (linux) Dec 13, 2019
@mvisonneau
Copy link
Contributor Author

/assign @jingxu97

@mvisonneau mvisonneau force-pushed the format_mount branch 2 times, most recently from a202493 to b35269c Compare December 15, 2019 23:17
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 15, 2019
@mvisonneau
Copy link
Contributor Author

I added a couple of tests and fixed some others 👌

@mvisonneau
Copy link
Contributor Author

/assign @jingxu97

@27149chen
Copy link

/assign @jsafrane

@mvisonneau mvisonneau force-pushed the format_mount branch 6 times, most recently from 46d2a00 to 2bf726f Compare December 16, 2019 18:44
@jsafrane
Copy link
Member

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 17, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jsafrane, mvisonneau

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 17, 2019
@k8s-ci-robot k8s-ci-robot merged commit dcd0c90 into kubernetes:master Dec 17, 2019
@mvisonneau mvisonneau deleted the format_mount branch December 17, 2019 11:22
klog.Infof("Disk successfully formatted (mkfs): %s - %s %s", fstype, source, target)
} else if fstype != existingFormat {
// Verify that the disk is formatted with filesystem type we are expecting
klog.Warningf("Configured to mount disk %s as %s but current format is %s, things might break", source, existingFormat, fstype)
Copy link
Contributor

Choose a reason for hiding this comment

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

sorry to comment late. here if the required file system does not match the existing one, why not return error since the following mount should fail in this case?

Choose a reason for hiding this comment

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

I think the first comment of @jsafrane explained the reason:

Previously, it was possible to mount ext3 volume even if its fsType was ext4. IMO it's a valid use case and we should not break it. Just try to mount it and throw stdout / stderr at the user, similarly to the previous code.


// Use 'ext4' as the default
if len(fstype) == 0 {
fstype = "ext4"
Copy link
Contributor

Choose a reason for hiding this comment

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

here we are saying if user does not specify a fstype, by default we set it "ext4". But why not we can set it as the current existing file system?

Choose a reason for hiding this comment

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

fstype is the default value for all. means that if existing format is ext3, and fstype is empty, the device will be mounted as ext4, not ext3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants