From d3dfe124dac3256d21a9d4ce7324e0d9f5bd62aa Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Thu, 24 Jun 2021 14:04:29 +0200 Subject: [PATCH] Update mounter interface in volume manager Update mounter interface in volume manager's ActualStateOfWorld every time. Otherwise kubelet uses the first mounter it gets, which may not have the latest information. This fixes set up of CSI volumes, which store information about SELinux support in their `mounter` interface implementation. With each MountVolume() retry, a new mounter is instantiated and only the final mounter that succeeds has the right info if the volume supports SELinux or not and can later return the right attributes on GetAttributes() call. --- pkg/kubelet/volumemanager/cache/actual_state_of_world.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/kubelet/volumemanager/cache/actual_state_of_world.go b/pkg/kubelet/volumemanager/cache/actual_state_of_world.go index db0ad30dc83..dbdfd319248 100644 --- a/pkg/kubelet/volumemanager/cache/actual_state_of_world.go +++ b/pkg/kubelet/volumemanager/cache/actual_state_of_world.go @@ -517,6 +517,11 @@ func (asw *actualStateOfWorld) AddPodToVolume(markVolumeOpts operationexecutor.M // If pod exists, reset remountRequired value podObj.remountRequired = false podObj.volumeMountStateForPod = markVolumeOpts.VolumeMountState + if mounter != nil { + // The mounter stored in the object may have old information, + // use the newest one. + podObj.mounter = mounter + } asw.attachedVolumes[volumeName].mountedPods[podName] = podObj return nil }