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
Add ability to pass format options in mount-utils #112877
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -273,7 +273,7 @@ func (mounter *Mounter) GetMountRefs(pathname string) ([]string, error) { | |
return []string{pathname}, nil | ||
} | ||
|
||
func (mounter *SafeFormatAndMount) formatAndMountSensitive(source string, target string, fstype string, options []string, sensitiveOptions []string) error { | ||
func (mounter *SafeFormatAndMount) formatAndMountSensitive(source string, target string, fstype string, options []string, sensitiveOptions []string, formatOptions []string) error { | ||
// Try to mount the disk | ||
klog.V(4).Infof("Attempting to formatAndMount disk: %s %s %s", fstype, source, target) | ||
|
||
|
@@ -288,8 +288,12 @@ func (mounter *SafeFormatAndMount) formatAndMountSensitive(source string, target | |
} | ||
|
||
// format disk if it is unformatted(raw) | ||
formatOptionsUnwrapped := "" | ||
if len(formatOptions) > 0 { | ||
formatOptionsUnwrapped = " " + strings.Join(formatOptions, " ") | ||
} | ||
cmd := fmt.Sprintf("Get-Disk -Number %s | Where partitionstyle -eq 'raw' | Initialize-Disk -PartitionStyle GPT -PassThru"+ | ||
" | New-Partition -UseMaximumSize | Format-Volume -FileSystem %s -Confirm:$false", source, fstype) | ||
" | New-Partition -UseMaximumSize | Format-Volume -FileSystem %s -Confirm:$false%s", source, fstype, formatOptionsUnwrapped) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this will work for an intree driver but not for a CSI driver that uses CSI Proxy to do the format & mount There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a way how to pass such parameters through CSI proxy? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes there's a way to pass parameters to CSI Proxy, CSI Drivers use the API exposed by CSI Proxy, currently it formats only with the volumeId https://github.com/kubernetes-csi/csi-proxy/blob/master/client/api/volume/v1/api.proto#L22 in the proto definition but as we're in the process to move to HostProcess containers this would need to go here instead: https://github.com/kubernetes-csi/csi-proxy/blob/4624937be58bfd46f5ebe6d8f213f58414275e45/pkg/volume/volume.go#L140 After reading the PR in more detail it's doing the following in Windows:
Is the expectation of the format additional options to work in Windows? I don't think they will work even in intree code, I'd suggest removing this part for Windows and only use it in Linux. To enable something similar in Windows there needs to be a mapping of a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good questions!
Yes, I would say so. The code as it's suggested in this PR moves this responsibility to the caller (= CSI driver / in-tree volume plugin / user). It must provide the right options for the right OS and the right fsType. mount-utils should be IMO small and stupid in this regard. @ConnorJC3, so... if user wants a ntfs volume that will be usable both on Windows and Linux nodes, they will need to provide both
I am not a Windows person, @ConnorJC3, does it sound right? Can you check it, update the PR as suggested and update csi-proxy? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
So as far as I know, there are 2 options here:
In case number 2, changes would have to be made to the CSI Proxy in order to support this for drivers. However, I'm not sure if it's worth doing so given that the CSI Proxy should be on its way out anyways. As There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is a huge problem, because this should already be true with mount options, and nobody's complained about those as far as I know. Also, this is more of a discussion that makes sense on the CSI Driver side,
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's my understanding too, but again, I know very little about Windows. @mauriciopoppe, is the current PR correct then? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is still up for discussion, I think it's worth talking about it with the community.
With HostProcess containers CSI Proxy is going to become a library and will be used in the CSI Drivers like mount-utils , this is tracked in this KEP kubernetes/enhancements#3641, @ddebroy and I had a discussion about it in the CSI Windows meeting, quoting some part of it: "reasons to keep CSI Proxy independent, CSI Proxy is more than mount e.g. ops for SMB, iSCSI, broader in the number of problems it solves, it's like storage utils than mount-utils." I think I should take back what I said in #112877 (comment) about it not working in Windows, I think it'll work and enable sending additional flags which is useful and it's all in the control of the caller which should have Windows/Linux variations in their mount code. /remove-hold |
||
if output, err := mounter.Exec.Command("powershell", "/c", cmd).CombinedOutput(); err != nil { | ||
return fmt.Errorf("diskMount: format disk failed, error: %v, output: %q", err, string(output)) | ||
} | ||
|
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.
Need to add the method to the interface.
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.
Which interface?
FormatAndMount
andFormatAndMountSensitive
don't seem to be on any interface.