Add more detailed error output when disk formatting fails

This commit is contained in:
David Zhu 2020-01-23 18:59:01 -08:00 committed by Srini Brahmaroutu
parent 0f9a3f756b
commit 99f567aa7a

View File

@ -345,10 +345,11 @@ func (mounter *SafeFormatAndMount) formatAndMount(source string, target string,
}
klog.Infof("Disk %q appears to be unformatted, attempting to format as type: %q with options: %v", source, fstype, args)
_, err := mounter.Exec.Command("mkfs."+fstype, args...).CombinedOutput()
output, err := mounter.Exec.Command("mkfs."+fstype, args...).CombinedOutput()
if err != nil {
klog.Errorf("format of disk %q failed: type:(%q) target:(%q) options:(%q)error:(%v)", source, fstype, target, options, err)
return NewMountError(FormatFailed, err.Error())
detailedErr := fmt.Sprintf("format of disk %q failed: type:(%q) target:(%q) options:(%q) errcode:(%v) output:(%v) ", source, fstype, target, options, err, string(output))
klog.Error(detailedErr)
return NewMountError(FormatFailed, detailedErr)
}
klog.Infof("Disk successfully formatted (mkfs): %s - %s %s", fstype, source, target)