diff --git a/pkg/kubelet/volumemanager/reconciler/reconciler_common.go b/pkg/kubelet/volumemanager/reconciler/reconciler_common.go index 7fb53f9ce94..512b3a30e6d 100644 --- a/pkg/kubelet/volumemanager/reconciler/reconciler_common.go +++ b/pkg/kubelet/volumemanager/reconciler/reconciler_common.go @@ -104,24 +104,24 @@ func NewReconciler( volumePluginMgr *volumepkg.VolumePluginMgr, kubeletPodsDir string) Reconciler { return &reconciler{ - kubeClient: kubeClient, - controllerAttachDetachEnabled: controllerAttachDetachEnabled, - loopSleepDuration: loopSleepDuration, - waitForAttachTimeout: waitForAttachTimeout, - nodeName: nodeName, - desiredStateOfWorld: desiredStateOfWorld, - actualStateOfWorld: actualStateOfWorld, - populatorHasAddedPods: populatorHasAddedPods, - operationExecutor: operationExecutor, - mounter: mounter, - hostutil: hostutil, - skippedDuringReconstruction: map[v1.UniqueVolumeName]*globalVolumeInfo{}, - volumePluginMgr: volumePluginMgr, - kubeletPodsDir: kubeletPodsDir, - timeOfLastSync: time.Time{}, - volumesFailedReconstruction: make([]podVolume, 0), - volumesNeedDevicePath: make([]v1.UniqueVolumeName, 0), - volumesNeedReportedInUse: make([]v1.UniqueVolumeName, 0), + kubeClient: kubeClient, + controllerAttachDetachEnabled: controllerAttachDetachEnabled, + loopSleepDuration: loopSleepDuration, + waitForAttachTimeout: waitForAttachTimeout, + nodeName: nodeName, + desiredStateOfWorld: desiredStateOfWorld, + actualStateOfWorld: actualStateOfWorld, + populatorHasAddedPods: populatorHasAddedPods, + operationExecutor: operationExecutor, + mounter: mounter, + hostutil: hostutil, + skippedDuringReconstruction: map[v1.UniqueVolumeName]*globalVolumeInfo{}, + volumePluginMgr: volumePluginMgr, + kubeletPodsDir: kubeletPodsDir, + timeOfLastSync: time.Time{}, + volumesFailedReconstruction: make([]podVolume, 0), + volumesNeedUpdateFromNodeStatus: make([]v1.UniqueVolumeName, 0), + volumesNeedReportedInUse: make([]v1.UniqueVolumeName, 0), } } @@ -141,11 +141,11 @@ type reconciler struct { skippedDuringReconstruction map[v1.UniqueVolumeName]*globalVolumeInfo kubeletPodsDir string // lock protects timeOfLastSync for updating and checking - timeOfLastSyncLock sync.Mutex - timeOfLastSync time.Time - volumesFailedReconstruction []podVolume - volumesNeedDevicePath []v1.UniqueVolumeName - volumesNeedReportedInUse []v1.UniqueVolumeName + timeOfLastSyncLock sync.Mutex + timeOfLastSync time.Time + volumesFailedReconstruction []podVolume + volumesNeedUpdateFromNodeStatus []v1.UniqueVolumeName + volumesNeedReportedInUse []v1.UniqueVolumeName } func (rc *reconciler) Run(stopCh <-chan struct{}) { diff --git a/pkg/kubelet/volumemanager/reconciler/reconciler_new.go b/pkg/kubelet/volumemanager/reconciler/reconciler_new.go index a8dfa438598..a4a4ac745f9 100644 --- a/pkg/kubelet/volumemanager/reconciler/reconciler_new.go +++ b/pkg/kubelet/volumemanager/reconciler/reconciler_new.go @@ -56,10 +56,10 @@ func (rc *reconciler) reconcileNew() { rc.cleanOrphanVolumes() } - if len(rc.volumesNeedDevicePath) != 0 { + if len(rc.volumesNeedUpdateFromNodeStatus) != 0 { rc.updateReconstructedFromAPIServer() } - if len(rc.volumesNeedDevicePath) == 0 { + if len(rc.volumesNeedUpdateFromNodeStatus) == 0 { // ASW is fully populated only after both devicePaths and uncertain volume attach-ability // were reconstructed from the API server. // This will start reconciliation of node.status.volumesInUse. diff --git a/pkg/kubelet/volumemanager/reconciler/reconciler_new_test.go b/pkg/kubelet/volumemanager/reconciler/reconciler_new_test.go index 8d02731d927..67f5bbba1cb 100644 --- a/pkg/kubelet/volumemanager/reconciler/reconciler_new_test.go +++ b/pkg/kubelet/volumemanager/reconciler/reconciler_new_test.go @@ -118,14 +118,14 @@ func TestReconcileWithUpdateReconstructedFromAPIServer(t *testing.T) { assert.False(t, reconciler.StatesHasBeenSynced()) - reconciler.volumesNeedDevicePath = append(reconciler.volumesNeedDevicePath, volumeName1, volumeName2) + reconciler.volumesNeedUpdateFromNodeStatus = append(reconciler.volumesNeedUpdateFromNodeStatus, volumeName1, volumeName2) // Act - run reconcile loop just once. - // "volumesNeedDevicePath" is not empty, so no unmount will be triggered. + // "volumesNeedUpdateFromNodeStatus" is not empty, so no unmount will be triggered. reconciler.reconcileNew() // Assert assert.True(t, reconciler.StatesHasBeenSynced()) - assert.Empty(t, reconciler.volumesNeedDevicePath) + assert.Empty(t, reconciler.volumesNeedUpdateFromNodeStatus) attachedVolumes := asw.GetAttachedVolumes() assert.Equalf(t, len(attachedVolumes), 2, "two volumes in ASW expected") diff --git a/pkg/kubelet/volumemanager/reconciler/reconstruct_new.go b/pkg/kubelet/volumemanager/reconciler/reconstruct_new.go index 4769d955d12..b051f440b4e 100644 --- a/pkg/kubelet/volumemanager/reconciler/reconstruct_new.go +++ b/pkg/kubelet/volumemanager/reconciler/reconstruct_new.go @@ -39,7 +39,7 @@ func (rc *reconciler) readyToUnmount() bool { // Allow unmount only when ASW device paths were corrected from node.status to prevent // calling unmount with a wrong devicePath. - if len(rc.volumesNeedDevicePath) != 0 { + if len(rc.volumesNeedUpdateFromNodeStatus) != 0 { return false } return true @@ -97,7 +97,7 @@ func (rc *reconciler) reconstructVolumes() { // Remember to update DSW with this information. rc.volumesNeedReportedInUse = reconstructedVolumeNames // Remember to update devicePath from node.status.volumesAttached - rc.volumesNeedDevicePath = reconstructedVolumeNames + rc.volumesNeedUpdateFromNodeStatus = reconstructedVolumeNames } klog.V(2).InfoS("Volume reconstruction finished") } @@ -183,18 +183,18 @@ func (rc *reconciler) updateReconstructedFromAPIServer() { // Skip reconstructing devicePath from node objects if kubelet is in standalone mode. // Such kubelet is not expected to mount any attachable volume or Secrets / ConfigMap. klog.V(2).InfoS("Skipped reconstruction of DevicePaths from node.status in standalone mode") - rc.volumesNeedDevicePath = nil + rc.volumesNeedUpdateFromNodeStatus = nil return } node, fetchErr := rc.kubeClient.CoreV1().Nodes().Get(context.TODO(), string(rc.nodeName), metav1.GetOptions{}) if fetchErr != nil { // This may repeat few times per second until kubelet is able to read its own status for the first time. - klog.V(2).ErrorS(fetchErr, "Failed to get Node status to reconstruct device paths") + klog.V(4).ErrorS(fetchErr, "Failed to get Node status to reconstruct device paths") return } - for _, volumeID := range rc.volumesNeedDevicePath { + for _, volumeID := range rc.volumesNeedUpdateFromNodeStatus { attachable := false for _, attachedVolume := range node.Status.VolumesAttached { if volumeID != attachedVolume.Name { @@ -208,5 +208,5 @@ func (rc *reconciler) updateReconstructedFromAPIServer() { } klog.V(2).InfoS("DevicePaths of reconstructed volumes updated") - rc.volumesNeedDevicePath = nil + rc.volumesNeedUpdateFromNodeStatus = nil } diff --git a/pkg/kubelet/volumemanager/reconciler/reconstruct_new_test.go b/pkg/kubelet/volumemanager/reconciler/reconstruct_new_test.go index 5c45acbc54a..2189d34991b 100644 --- a/pkg/kubelet/volumemanager/reconciler/reconstruct_new_test.go +++ b/pkg/kubelet/volumemanager/reconciler/reconstruct_new_test.go @@ -117,8 +117,8 @@ func TestReconstructVolumes(t *testing.T) { for i := range tc.expectedVolumesNeedDevicePath { expectedVolumes[i] = v1.UniqueVolumeName(tc.expectedVolumesNeedDevicePath[i]) } - if !reflect.DeepEqual(expectedVolumes, rcInstance.volumesNeedDevicePath) { - t.Errorf("Expected expectedVolumesNeedDevicePath:\n%v\n got:\n%v", expectedVolumes, rcInstance.volumesNeedDevicePath) + if !reflect.DeepEqual(expectedVolumes, rcInstance.volumesNeedUpdateFromNodeStatus) { + t.Errorf("Expected expectedVolumesNeedDevicePath:\n%v\n got:\n%v", expectedVolumes, rcInstance.volumesNeedUpdateFromNodeStatus) } expectedVolumes = make([]v1.UniqueVolumeName, len(tc.expectedVolumesNeedReportedInUse)) @@ -333,7 +333,7 @@ func TestReconstructVolumesMount(t *testing.T) { return true } // Mark devices paths as reconciled to allow unmounting of volumes. - rcInstance.volumesNeedDevicePath = nil + rcInstance.volumesNeedUpdateFromNodeStatus = nil // Act 2 - reconcile once rcInstance.reconcileNew()