-
Notifications
You must be signed in to change notification settings - Fork 160
Add Volume Resize support for Windows #637
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
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
Copyright 2020 The Kubernetes Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package resizefs | ||
|
||
type Resizefs interface { | ||
Resize(devicePath, deviceMountPath string) (bool, error) | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// +build windows | ||
|
||
/* | ||
Copyright 2020 The Kubernetes Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package resizefs | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
volumeapi "github.com/kubernetes-csi/csi-proxy/client/api/volume/v1beta1" | ||
"k8s.io/klog" | ||
"k8s.io/utils/mount" | ||
mounter "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/mount-manager" | ||
) | ||
|
||
var _ Resizefs = &resizeFs{} | ||
|
||
// ResizeFs Provides support for resizing file systems | ||
type resizeFs struct { | ||
mounter *mount.SafeFormatAndMount | ||
} | ||
|
||
// NewResizeFs returns new instance of resizer | ||
func NewResizeFs(mounter *mount.SafeFormatAndMount) *resizeFs { | ||
return &resizeFs{mounter: mounter} | ||
} | ||
|
||
// resize perform resize of file system | ||
func (resizefs *resizeFs) Resize(devicePath string, deviceMountPath string) (bool, error) { | ||
klog.V(3).Infof("resizeFS.Resize - Expanding mounted volume %s", deviceMountPath) | ||
|
||
proxy, ok := resizefs.mounter.Interface.(*mounter.CSIProxyMounter) | ||
if !ok { | ||
return false, fmt.Errorf("could not cast to csi proxy class") | ||
} | ||
|
||
idRequest := &volumeapi.VolumeIDFromMountRequest{ | ||
Mount: deviceMountPath, | ||
} | ||
idResponse, err := proxy.VolumeClient.GetVolumeIDFromMount(context.Background(), idRequest) | ||
if err != nil { | ||
return false, err | ||
} | ||
volumeId := idResponse.GetVolumeId() | ||
|
||
request := &volumeapi.ResizeVolumeRequest{ | ||
VolumeId: volumeId, | ||
} | ||
_, err = proxy.VolumeClient.ResizeVolume(context.Background(), request) | ||
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. Do you need to check filesystem type or does this imply ntfs? 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. It implies ntfs, no need to check fs type. 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. if there ever is a need for multiple fs support, will the csi proxy be able to automatically figure out what to do? 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. for this volumeclient API, it means ntfs volume, and all functions through volume API client assumes that. 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 thinking something like ext4 in the future, where it also belongs in the volume client. Anyway, I posed the question in slack. For this pr, this is fine. |
||
if err != nil { | ||
return false, err | ||
} | ||
return true, nil | ||
} |
Uh oh!
There was an error while loading. Please reload this page.