Skip to content
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

updated docker base image to alpine:3.15 #85

Merged
merged 10 commits into from
Oct 25, 2024
5 changes: 3 additions & 2 deletions deploy/image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
38 changes: 37 additions & 1 deletion pkg/spdk/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Loading