Merge pull request #104923 from davidkarlsen/xfsFormatIssue

mount-utils: force-format xfs-filesystems too
This commit is contained in:
Kubernetes Prow Robot 2021-09-27 02:29:36 -07:00 committed by GitHub
commit 486ca678a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -439,6 +439,11 @@ func (mounter *SafeFormatAndMount) formatAndMountSensitive(source string, target
"-m0", // Zero blocks reserved for super-user
source,
}
} else if fstype == "xfs" {
args = []string{
"-f", // force flag
source,
}
}
klog.Infof("Disk %q appears to be unformatted, attempting to format as type: %q with options: %v", source, fstype, args)

View File

@ -181,7 +181,7 @@ func TestSafeFormatAndMount(t *testing.T) {
fstype: "xfs",
execScripts: []ExecArgs{
{"blkid", []string{"-p", "-s", "TYPE", "-s", "PTTYPE", "-o", "export", "/dev/foo"}, "", &testingexec.FakeExitError{Status: 2}},
{"mkfs.xfs", []string{"/dev/foo"}, "", nil},
{"mkfs.xfs", []string{"-f", "/dev/foo"}, "", nil},
},
},
{
@ -198,7 +198,7 @@ func TestSafeFormatAndMount(t *testing.T) {
mountErrs: []error{fmt.Errorf("unknown filesystem type '(null)'"), nil},
execScripts: []ExecArgs{
{"blkid", []string{"-p", "-s", "TYPE", "-s", "PTTYPE", "-o", "export", "/dev/foo"}, "", &testingexec.FakeExitError{Status: 4}},
{"mkfs.xfs", []string{"/dev/foo"}, "", nil},
{"mkfs.xfs", []string{"-f", "/dev/foo"}, "", nil},
},
expErrorType: GetDiskFormatFailed,
},