Skip to content

Commit 7c0cb10

Browse files
committed
Seed fsName to ceph-csi's node plugin
This option is now mandatory to use when there are multiple CephFS file systems in the ceph cluster. Without this, ceph won't be able to find the (sub)volume to mount. Fixes #2992 Fixes #2986
1 parent e2788e3 commit 7c0cb10

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

pkg/csi/manila/nodeserver.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ func (ns *nodeServer) buildVolumeContext(ctx context.Context, volID volumeID, sh
133133
sa := getShareAdapter(ns.d.shareProto)
134134
opts := &shareadapters.VolumeContextArgs{
135135
Locations: availableExportLocations,
136+
Share: share,
136137
Options: shareOpts,
137138
}
138139
volumeContext, err = sa.BuildVolumeContext(opts)

pkg/csi/manila/shareadapters/cephfs.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package shareadapters
1919
import (
2020
"context"
2121
"fmt"
22+
"strings"
2223
"time"
2324

2425
"github.com/gophercloud/gophercloud/v2"
@@ -133,9 +134,44 @@ func (Cephfs) BuildVolumeContext(args *VolumeContextArgs) (volumeContext map[str
133134
volCtx["fuseMountOptions"] = args.Options.CephfsFuseMountOptions
134135
}
135136

137+
// Extract fs_name from __mount_options metadata if available
138+
if fsName := extractFsNameFromMountOptions(args.Share); fsName != "" {
139+
volCtx["fsName"] = fsName
140+
klog.V(4).Infof("Found fs_name in share metadata: %s", fsName)
141+
}
142+
136143
return volCtx, err
137144
}
138145

146+
// extractFsNameFromMountOptions extracts the fs from __mount_options metadata
147+
// The __mount_options metadata contains mount options including fs for CephFS
148+
func extractFsNameFromMountOptions(share *shares.Share) string {
149+
if share == nil || share.Metadata == nil {
150+
return ""
151+
}
152+
153+
mountOptions, exists := share.Metadata["__mount_options"]
154+
if !exists {
155+
klog.V(4).Infof("No __mount_options metadata found in share %s", share.ID)
156+
return ""
157+
}
158+
159+
// Parse mount options to extract fs
160+
// Mount options are typically comma-separated key=value pairs
161+
// Example: "fs=myfs,other_option=value"
162+
options := strings.Split(mountOptions, ",")
163+
for _, option := range options {
164+
option = strings.TrimSpace(option)
165+
if strings.HasPrefix(option, "fs=") {
166+
fsName := strings.TrimPrefix(option, "fs=")
167+
return strings.TrimSpace(fsName)
168+
}
169+
}
170+
171+
klog.V(4).Infof("No fs found in __mount_options metadata for share %s: %s", share.ID, mountOptions)
172+
return ""
173+
}
174+
139175
func (Cephfs) BuildNodeStageSecret(args *SecretArgs) (secret map[string]string, err error) {
140176
return map[string]string{
141177
"userID": args.AccessRight.AccessTo,

pkg/csi/manila/shareadapters/shareadapter.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ type VolumeContextArgs struct {
3535
// an export location when building a volume context.
3636
Locations []shares.ExportLocation
3737

38+
// Share object containing metadata and other share information
39+
Share *shares.Share
40+
3841
Options *options.NodeVolumeContext
3942
}
4043

0 commit comments

Comments
 (0)