@@ -57,8 +57,7 @@ type bindMountSyscall func(source, target string) error
5757// - S3 buckets are mounted to a "source" directory first (shared mount point)
5858// - Individual containers get bind mounts from the source to their target paths
5959// - This enables multiple containers to share the same S3 mount efficiently
60- // - During CSI upgrade, existing workloads continue with direct mounts (backward compatibility)
61- // - New/restarted workloads use CRD-based coordination for mount sharing
60+ // - All workloads use CRD-based coordination for mount sharing
6261type PodMounter struct {
6362 podWatcher * watcher.Watcher
6463 mount mount.Interface
@@ -79,11 +78,7 @@ type PodMounter struct {
7978// - mountSyscall: Custom mount syscall function (nil uses default)
8079// - bindMountSyscall: Custom bind mount function (nil uses default)
8180// - kubernetesVersion: K8s version for compatibility checks
82- // - k8sClient: Client for CRD operations (nil enables backward compatibility mode)
83- //
84- // When k8sClient is nil, the mounter operates in backward compatibility mode,
85- // creating Mountpoint Pods directly without CRD coordination. This supports
86- // existing workloads during CSI driver upgrades.
81+ // - k8sClient: Client for CRD operations (required)
8782func NewPodMounter (podWatcher * watcher.Watcher , credProvider * credentialprovider.Provider , mount mount.Interface , mountSyscall mountSyscall , bindMountSyscall bindMountSyscall , kubernetesVersion string , k8sClient client.Client ) (* PodMounter , error ) {
8883 kubeletPath := os .Getenv ("KUBELET_PATH" )
8984 if kubeletPath == "" {
@@ -114,16 +109,9 @@ func NewPodMounter(podWatcher *watcher.Watcher, credProvider *credentialprovider
114109// - Controller to determine optimal Mountpoint Pod placement
115110// - Sharing of Mountpoint Pods across multiple workload pods
116111// - Better resource utilization and scheduling decisions
117- //
118- // In backward compatibility mode (k8sClient == nil), it returns a deterministic
119- // pod name without waiting for CRD, maintaining existing behavior for workloads
120- // that haven't been restarted after the CSI upgrade.
121112func (pm * PodMounter ) waitForMountpointPodAttachment (ctx context.Context , podID , volumeName , volumeID string , credentialCtx credentialprovider.ProvideContext , fsGroup string ) (string , error ) {
122113 if pm .k8sClient == nil {
123- // Backward compatibility mode: Direct pod creation without CRD coordination
124- // Used for existing workloads during CSI upgrade until they restart
125- klog .Warningf ("k8sClient is nil, operating in backward compatibility mode" )
126- return mppod .MountpointPodNameFor (podID , volumeName ), nil
114+ return "" , fmt .Errorf ("k8sClient is required for pod mounter operations" )
127115 }
128116
129117 ctx , cancel := context .WithTimeout (ctx , 2 * time .Minute )
@@ -181,7 +169,7 @@ func (pm *PodMounter) helpMessageForGettingControllerLogs() string {
181169// Mount mounts the given `bucketName` at the `target` path using provided credential context and Mountpoint arguments.
182170//
183171// Source/Bind Mount Architecture:
184- // 1. Wait for controller to assign a Mountpoint Pod via CRD (or use direct creation in backward compatibility mode)
172+ // 1. Wait for controller to assign a Mountpoint Pod via CRD
185173// 2. Mount S3 bucket to a "source" directory: /var/lib/kubelet/plugins/s3.csi.scality.com/mnt/<pod-name>
186174// 3. Create bind mount from source to target path requested by the container
187175// 4. Multiple containers can share the same source mount via different bind mounts
@@ -243,14 +231,15 @@ func (pm *PodMounter) Mount(ctx context.Context, bucketName string, target strin
243231 podID := credentialCtx .PodID
244232 volumeID := credentialCtx .VolumeID
245233
246- // Step 1: Determine which Mountpoint Pod to use
247- // In CRD mode: Controller assigns optimal pod via MountpointS3PodAttachment
248- // In backward compatibility: Use deterministic pod name
234+ // Step 1: Determine which Mountpoint Pod to use via MountpointS3PodAttachment CRD
235+ // Controller assigns optimal pod based on scheduling and resource constraints
236+ klog . V ( 4 ). Infof ( "Looking for pod with podID=%s, volumeName=%s, volumeID=%s" , podID , volumeName , volumeID )
249237 mpPodName , err := pm .waitForMountpointPodAttachment (ctx , podID , volumeName , volumeID , credentialCtx , fsGroup )
250238 if err != nil {
251239 klog .Errorf ("failed to wait for MountpointS3PodAttachment for %q: %v. %s" , target , err , pm .helpMessageForGettingControllerLogs ())
252240 return fmt .Errorf ("failed to wait for MountpointS3PodAttachment for %q: %w. %s" , target , err , pm .helpMessageForGettingControllerLogs ())
253241 }
242+ klog .V (4 ).Infof ("Using Mountpoint Pod name: %s" , mpPodName )
254243
255244 // Step 2: Setup source mount directory
256245 // Source path: /var/lib/kubelet/plugins/s3.csi.scality.com/mnt/<mp-pod-name>
@@ -424,10 +413,29 @@ func (pm *PodMounter) Unmount(ctx context.Context, target string, credentialCtx
424413 return nil
425414}
426415
427- // IsMountPoint returns whether given `target` is a `mount-s3` mount.
416+ // IsMountPoint returns whether given `target` is a mount point.
417+ // It checks for both mountpoint-s3 mounts and bind mounts.
428418func (pm * PodMounter ) IsMountPoint (target string ) (bool , error ) {
429- // TODO: Can we just use regular `IsMountPoint` check from `mounter` with containerization?
430- return mpmounter .CheckMountpoint (pm .mount , target )
419+ // First check if it's a mountpoint-s3 mount
420+ isMpMount , err := mpmounter .CheckMountpoint (pm .mount , target )
421+ if err != nil {
422+ return false , err
423+ }
424+ if isMpMount {
425+ return true , nil
426+ }
427+
428+ // Also check if it's any other kind of mount (e.g., bind mount)
429+ // This is important because targets are typically bind mounts from source
430+ notMnt , err := pm .mount .IsLikelyNotMountPoint (target )
431+ if err != nil {
432+ // If the path doesn't exist, return false without error
433+ if os .IsNotExist (err ) {
434+ return false , nil
435+ }
436+ return false , err
437+ }
438+ return ! notMnt , nil
431439}
432440
433441// waitForMountpointPod waints until Mountpoint Pod for given `podID` and `volumeName` is in `Running` state.
@@ -470,7 +478,9 @@ func (pm *PodMounter) waitForMount(parentCtx context.Context, target, podName, p
470478 // Poll for `IsMountPoint` check
471479 go func () {
472480 err := wait .PollUntilContextCancel (ctx , 1 * time .Second , true , func (ctx context.Context ) (done bool , err error ) {
473- return pm .IsMountPoint (target )
481+ isMounted , err := pm .IsMountPoint (target )
482+ klog .V (5 ).Infof ("Checking if %s is mount point: isMounted=%v, err=%v" , target , isMounted , err )
483+ return isMounted , err
474484 })
475485
476486 if err != nil {
0 commit comments