Skip to content

Commit

Permalink
[csi] Add patch for fake volume expansion support (#38)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandr Stefurishin <[email protected]>
Signed-off-by: v.oleynikov <[email protected]>
Co-authored-by: v.oleynikov <[email protected]>
  • Loading branch information
astef and duckhawk authored Sep 27, 2024
1 parent fab135b commit 192b406
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
From 189c10ff76dcef64cf2816317d3c197956497453 Mon Sep 17 00:00:00 2001
From: Alexandr Stefurishin <[email protected]>
Date: Tue, 24 Sep 2024 09:56:28 +0300
Subject: [PATCH] fake-implementation-of-ControllerExpandVolume

Signed-off-by: Alexandr Stefurishin <[email protected]>
---
pkg/nfs/controllerserver.go | 18 +++++++++++++++---
pkg/nfs/identityserver.go | 14 ++++++++++++++
pkg/nfs/nfs.go | 2 ++
3 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/pkg/nfs/controllerserver.go b/pkg/nfs/controllerserver.go
index 726df875..494567de 100644
--- a/pkg/nfs/controllerserver.go
+++ b/pkg/nfs/controllerserver.go
@@ -304,7 +304,11 @@ func (cs *ControllerServer) ListVolumes(_ context.Context, _ *csi.ListVolumesReq
}

func (cs *ControllerServer) GetCapacity(_ context.Context, _ *csi.GetCapacityRequest) (*csi.GetCapacityResponse, error) {
- return nil, status.Error(codes.Unimplemented, "")
+ return &csi.GetCapacityResponse{
+ AvailableCapacity: 1000_000_000_000_000, // 1000 TB
+ MaximumVolumeSize: nil,
+ MinimumVolumeSize: nil,
+ }, nil
}

// ControllerGetCapabilities implements the default GRPC callout.
@@ -432,8 +436,16 @@ func (cs *ControllerServer) ListSnapshots(_ context.Context, _ *csi.ListSnapshot
return nil, status.Error(codes.Unimplemented, "")
}

-func (cs *ControllerServer) ControllerExpandVolume(_ context.Context, _ *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) {
- return nil, status.Error(codes.Unimplemented, "")
+func (cs *ControllerServer) ControllerExpandVolume(_ context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) {
+ // fake implementation, doesn't really resize anything
+
+ klog.V(2).Infof("[ControllerExpandVolume] received expansion request for volumeID:%s, requiredBytes: %d", req.VolumeId, req.CapacityRange.RequiredBytes)
+ klog.Warning("[ControllerExpandVolume] volume expansion is not really happenning, fake implementation is used")
+
+ return &csi.ControllerExpandVolumeResponse{
+ CapacityBytes: req.CapacityRange.RequiredBytes,
+ NodeExpansionRequired: false,
+ }, nil
}

// Mount nfs server at base-dir
diff --git a/pkg/nfs/identityserver.go b/pkg/nfs/identityserver.go
index d76fcf49..85afdb6f 100644
--- a/pkg/nfs/identityserver.go
+++ b/pkg/nfs/identityserver.go
@@ -61,6 +61,20 @@ func (ids *IdentityServer) GetPluginCapabilities(_ context.Context, _ *csi.GetPl
},
},
},
+ {
+ Type: &csi.PluginCapability_VolumeExpansion_{
+ VolumeExpansion: &csi.PluginCapability_VolumeExpansion{
+ Type: csi.PluginCapability_VolumeExpansion_ONLINE,
+ },
+ },
+ },
+ {
+ Type: &csi.PluginCapability_VolumeExpansion_{
+ VolumeExpansion: &csi.PluginCapability_VolumeExpansion{
+ Type: csi.PluginCapability_VolumeExpansion_OFFLINE,
+ },
+ },
+ },
},
}, nil
}
diff --git a/pkg/nfs/nfs.go b/pkg/nfs/nfs.go
index 7d69265e..e91093da 100644
--- a/pkg/nfs/nfs.go
+++ b/pkg/nfs/nfs.go
@@ -98,6 +98,8 @@ func NewDriver(options *DriverOptions) *Driver {
csi.ControllerServiceCapability_RPC_SINGLE_NODE_MULTI_WRITER,
csi.ControllerServiceCapability_RPC_CLONE_VOLUME,
csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT,
+ csi.ControllerServiceCapability_RPC_GET_CAPACITY,
+ csi.ControllerServiceCapability_RPC_EXPAND_VOLUME,
})

n.AddNodeServiceCapabilities([]csi.NodeServiceCapability_RPC_Type{
--
2.43.0

6 changes: 3 additions & 3 deletions images/csi-nfs/werf.inc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
image: {{ $.ImageName }}-golang-artifact
from: {{ $.BASE_GOLANG }}
final: false
fromCacheVersion: 20240924100030

git:
- add: /images/{{ $.ImageName }}
to: /
stageDependencies:
setup:
install:
- "**/*"
includePaths:
- patches
Expand All @@ -29,9 +30,8 @@ shell:
- git clone --depth 1 --branch v{{ $version }} {{ env "SOURCE_REPO" }}/kubernetes-csi/csi-driver-nfs.git /csi-driver-nfs
- cd /csi-driver-nfs
- for patchfile in /patches/*.patch ; do echo -n "Apply ${patchfile} ... "; git apply ${patchfile}; done
- cd /csi-driver-nfs/cmd/nfsplugin
- go mod vendor
- GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w" -o /nfsplugin
- GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w" -o /nfsplugin ./cmd/nfsplugin
- chmod +x /nfsplugin

---
Expand Down
2 changes: 1 addition & 1 deletion templates/csi/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
{{- $csiControllerConfig := dict }}
{{- $_ := set $csiControllerConfig "controllerImage" $csiControllerImage }}
{{- $_ := set $csiControllerConfig "snapshotterEnabled" true }}
{{- $_ := set $csiControllerConfig "resizerEnabled" false }}
{{- $_ := set $csiControllerConfig "resizerEnabled" true }}
{{- $_ := set $csiControllerConfig "provisionerTimeout" "1200s" }}
{{- $_ := set $csiControllerConfig "snapshotterTimeout" "1200s" }}
{{- $_ := set $csiControllerConfig "extraCreateMetadataEnabled" true }}
Expand Down

0 comments on commit 192b406

Please sign in to comment.