From 71c92e398f765ed1d5e840e6062b0777c1df9058 Mon Sep 17 00:00:00 2001 From: Geoffrey Israel Date: Fri, 25 Oct 2024 05:05:08 -0400 Subject: [PATCH] updated docker base image to alpine:3.15 (#85) * updated docker base image to alpine:3.15 * added devicePath to volumeContext * returned CapacityBytes after NodeExpansion * updated docker base image to alpine:3.15 * updated docker base image to ubuntu:20.04 * updated docker base image to alpine:3.18 * updated docker base image to alpine:3.8 * updated docker base image to alpine:3.18 * updated docker base image to alpine:3.18 * updated docker base image to alpine:3.18 --- deploy/image/Dockerfile | 5 +++-- pkg/spdk/nodeserver.go | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/deploy/image/Dockerfile b/deploy/image/Dockerfile index 9773a1e..d710046 100644 --- a/deploy/image/Dockerfile +++ b/deploy/image/Dockerfile @@ -4,12 +4,13 @@ # # XXX: pin alpine to 3.8 with e2fsprogs-1.44 # e2fsprogs-1.45+ crashes my test vm when running mkfs.ext4 -FROM alpine:3.8 +FROM alpine:3.18 LABEL maintainers="SPDK-CSI Authors" LABEL description="SPDK-CSI Plugin" COPY spdkcsi /usr/local/bin/spdkcsi -RUN apk add nvme-cli open-iscsi e2fsprogs xfsprogs blkid +RUN apk update && \ + apk add nvme-cli open-iscsi e2fsprogs xfsprogs blkid xfsprogs-extra e2fsprogs-extra ENTRYPOINT ["/usr/local/bin/spdkcsi"] diff --git a/pkg/spdk/nodeserver.go b/pkg/spdk/nodeserver.go index 4b1e814..569a040 100644 --- a/pkg/spdk/nodeserver.go +++ b/pkg/spdk/nodeserver.go @@ -185,6 +185,8 @@ func (ns *nodeServer) NodeStageVolume(_ context.Context, req *csi.NodeStageVolum klog.Errorf("failed to stage volume, volumeID: %s devicePath:%s err: %v", volumeID, devicePath, err) return nil, status.Error(codes.Internal, err.Error()) } + + vc["devicePath"] = devicePath // stash VolumeContext to stagingParentPath (useful during Unstage as it has no // VolumeContext passed to the RPC as per the CSI spec) err = util.StashVolumeContext(req.GetVolumeContext(), stagingParentPath) @@ -297,7 +299,41 @@ func (ns *nodeServer) NodeGetCapabilities(_ context.Context, _ *csi.NodeGetCapab func (ns *nodeServer) NodeExpandVolume(_ context.Context, req *csi.NodeExpandVolumeRequest) (*csi.NodeExpandVolumeResponse, error) { klog.Infof("NodeExpandVolume: called with args %+v", *req) - return &csi.NodeExpandVolumeResponse{}, nil + + volumeID := req.GetVolumeId() + volumeMountPath := req.GetVolumePath() + updatedSize := req.GetCapacityRange().GetRequiredBytes() + + stagingParentPath := req.GetStagingTargetPath() + volumeContext, err := util.LookupVolumeContext(stagingParentPath) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to retrieve volume context for volume %s: %v", volumeID, err) + } + + devicePath, ok := volumeContext["devicePath"] + if !ok || devicePath == "" { + return nil, status.Errorf(codes.Internal, "could not find device path for volume %s", volumeID) + } + + resizer := mount.NewResizeFs(exec.New()) + needsResize, err := resizer.NeedResize(devicePath, volumeMountPath) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to check if volume %s needs resizing: %v", volumeID, err) + } + + if needsResize { + resized, err := resizer.Resize(devicePath, volumeMountPath) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to resize volume %s: %v", volumeID, err) + } + if resized { + klog.Infof("Successfully resized volume %s (device: %s, mount path: %s)", volumeID, devicePath, volumeMountPath) + } else { + klog.Warningf("Volume %s did not require resizing", volumeID) + } + } + + return &csi.NodeExpandVolumeResponse{CapacityBytes: updatedSize}, nil } // must be idempotent