@@ -19,6 +19,7 @@ package shareadapters
19
19
import (
20
20
"context"
21
21
"fmt"
22
+ "strings"
22
23
"time"
23
24
24
25
"github.com/gophercloud/gophercloud/v2"
@@ -133,9 +134,44 @@ func (Cephfs) BuildVolumeContext(args *VolumeContextArgs) (volumeContext map[str
133
134
volCtx ["fuseMountOptions" ] = args .Options .CephfsFuseMountOptions
134
135
}
135
136
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
+
136
143
return volCtx , err
137
144
}
138
145
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
+
139
175
func (Cephfs ) BuildNodeStageSecret (args * SecretArgs ) (secret map [string ]string , err error ) {
140
176
return map [string ]string {
141
177
"userID" : args .AccessRight .AccessTo ,
0 commit comments