diff --git a/CHANGELOG.md b/CHANGELOG.md index 4942cae..54eef75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Set the FS type during mount operations based on the FS type stored in LINSTOR. + ## [1.7.0] - 2025-02-13 ### Added diff --git a/pkg/driver/driver.go b/pkg/driver/driver.go index b4fc9ef..ae4ad14 100644 --- a/pkg/driver/driver.go +++ b/pkg/driver/driver.go @@ -342,13 +342,31 @@ func (d Driver) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolum volCtx.MountOptions = append(volCtx.MountOptions, "_netdev") + publishCtx := PublishContextFromMap(req.GetPublishContext()) + if publishCtx == nil { + assignment, err := d.Assignments.FindAssignmentOnNode(ctx, req.GetVolumeId(), d.nodeID) + if err != nil { + return nil, status.Errorf(codes.Internal, "NodePublishVolume failed for %s: %v", req.GetVolumeId(), err) + } + + if assignment == nil { + return nil, status.Errorf(codes.NotFound, "NodePublishVolume failed for %s: assignment not found", req.GetVolumeId()) + } + + publishCtx = &PublishContext{ + DevicePath: assignment.Path, + } + } + var fsType string if block := req.GetVolumeCapability().GetBlock(); block != nil { volCtx.MountOptions = []string{"bind"} } - if mnt := req.GetVolumeCapability().GetMount(); mnt != nil { + if publishCtx.FsType != "" { + fsType = publishCtx.FsType + } else if mnt := req.GetVolumeCapability().GetMount(); mnt != nil { volCtx.MountOptions = append(volCtx.MountOptions, mnt.GetMountFlags()...) fsType = "ext4" if mnt.FsType != "" { @@ -362,22 +380,6 @@ func (d Driver) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolum volCtx.MountOptions = append(volCtx.MountOptions, "nouuid") } - publishCtx := PublishContextFromMap(req.GetPublishContext()) - if publishCtx == nil { - assignment, err := d.Assignments.FindAssignmentOnNode(ctx, req.GetVolumeId(), d.nodeID) - if err != nil { - return nil, status.Errorf(codes.Internal, "NodePublishVolume failed for %s: %v", req.GetVolumeId(), err) - } - - if assignment == nil { - return nil, status.Errorf(codes.NotFound, "NodePublishVolume failed for %s: assignment not found", req.GetVolumeId()) - } - - publishCtx = &PublishContext{ - DevicePath: assignment.Path, - } - } - ro := req.GetReadonly() || req.GetVolumeCapability().GetAccessMode().GetMode() == csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY err = d.Mounter.Mount(ctx, publishCtx.DevicePath, req.GetTargetPath(), fsType, ro, volCtx.MountOptions) @@ -683,6 +685,7 @@ func (d Driver) ControllerPublishVolume(ctx context.Context, req *csi.Controller return &csi.ControllerPublishVolumeResponse{ PublishContext: (&PublishContext{ DevicePath: devPath, + FsType: existingVolume.FsType, }).ToMap(), }, nil } diff --git a/pkg/driver/publish_context.go b/pkg/driver/publish_context.go index f48583d..2bb1e4e 100644 --- a/pkg/driver/publish_context.go +++ b/pkg/driver/publish_context.go @@ -7,9 +7,11 @@ import ( const ( PublishContextMarker = linstor.ParameterNamespace + "/uses-publish-context" DevicePath = linstor.ParameterNamespace + "/device-path" + FsType = linstor.ParameterNamespace + "/fs-type" ) type PublishContext struct { + FsType string DevicePath string } @@ -21,6 +23,7 @@ func PublishContextFromMap(ctx map[string]string) *PublishContext { return &PublishContext{ DevicePath: ctx[DevicePath], + FsType: ctx[FsType], } } @@ -28,5 +31,6 @@ func (p *PublishContext) ToMap() map[string]string { return map[string]string{ PublishContextMarker: "true", DevicePath: p.DevicePath, + FsType: p.FsType, } }