Merge pull request #124242 from carlory/cleanup-after-NewVolumeManagerReconstruction-ga

remove unneeded func SyncReconstructedVolume from ActualStateOfWorld
This commit is contained in:
Kubernetes Prow Robot 2024-04-18 03:24:50 -07:00 committed by GitHub
commit 9c9a9b7c48
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 8 additions and 25 deletions

View File

@ -168,10 +168,6 @@ type ActualStateOfWorld interface {
// or have a mount/unmount operation pending.
GetAttachedVolumes() []AttachedVolume
// SyncReconstructedVolume check the volume.outerVolumeSpecName in asw and
// the one populated from dsw, if they do not match, update this field from the value from dsw.
SyncReconstructedVolume(volumeName v1.UniqueVolumeName, podName volumetypes.UniquePodName, outerVolumeSpecName string)
// Add the specified volume to ASW as uncertainly attached.
AddAttachUncertainReconstructedVolume(volumeName v1.UniqueVolumeName, volumeSpec *volume.Spec, nodeName types.NodeName, devicePath string) error
@ -1119,19 +1115,6 @@ func (asw *actualStateOfWorld) GetUnmountedVolumes() []AttachedVolume {
return unmountedVolumes
}
func (asw *actualStateOfWorld) SyncReconstructedVolume(volumeName v1.UniqueVolumeName, podName volumetypes.UniquePodName, outerVolumeSpecName string) {
asw.Lock()
defer asw.Unlock()
if volumeObj, volumeExists := asw.attachedVolumes[volumeName]; volumeExists {
if podObj, podExists := volumeObj.mountedPods[podName]; podExists {
if podObj.outerVolumeSpecName != outerVolumeSpecName {
podObj.outerVolumeSpecName = outerVolumeSpecName
asw.attachedVolumes[volumeName].mountedPods[podName] = podObj
}
}
}
}
func (asw *actualStateOfWorld) newAttachedVolume(
attachedVolume *attachedVolume) AttachedVolume {
seLinuxMountContext := ""

View File

@ -24,10 +24,10 @@ import (
func (rc *reconciler) Run(stopCh <-chan struct{}) {
rc.reconstructVolumes()
klog.InfoS("Reconciler: start to sync state")
wait.Until(rc.reconcileNew, rc.loopSleepDuration, stopCh)
wait.Until(rc.reconcile, rc.loopSleepDuration, stopCh)
}
func (rc *reconciler) reconcileNew() {
func (rc *reconciler) reconcile() {
readyToUnmount := rc.readyToUnmount()
if readyToUnmount {
// Unmounts are triggered before mounts so that a volume that was

View File

@ -2382,7 +2382,7 @@ func TestReconcileWithUpdateReconstructedFromAPIServer(t *testing.T) {
reconciler.volumesNeedUpdateFromNodeStatus = append(reconciler.volumesNeedUpdateFromNodeStatus, volumeName1, volumeName2)
// Act - run reconcile loop just once.
// "volumesNeedUpdateFromNodeStatus" is not empty, so no unmount will be triggered.
reconciler.reconcileNew()
reconciler.reconcile()
// Assert
assert.True(t, reconciler.StatesHasBeenSynced())

View File

@ -89,7 +89,7 @@ func (rc *reconciler) reconstructVolumes() {
if len(reconstructedVolumes) > 0 {
// Add the volumes to ASW
rc.updateStatesNew(reconstructedVolumes)
rc.updateStates(reconstructedVolumes)
// The reconstructed volumes are mounted, hence a previous kubelet must have already put it into node.status.volumesInUse.
// Remember to update DSW with this information.
@ -100,7 +100,7 @@ func (rc *reconciler) reconstructVolumes() {
klog.V(2).InfoS("Volume reconstruction finished")
}
func (rc *reconciler) updateStatesNew(reconstructedVolumes map[v1.UniqueVolumeName]*globalVolumeInfo) {
func (rc *reconciler) updateStates(reconstructedVolumes map[v1.UniqueVolumeName]*globalVolumeInfo) {
for _, gvl := range reconstructedVolumes {
err := rc.actualStateOfWorld.AddAttachUncertainReconstructedVolume(
//TODO: the devicePath might not be correct for some volume plugins: see issue #54108

View File

@ -385,8 +385,8 @@ func (rc *reconciler) reconstructVolume(volume podVolume) (rvolume *reconstructe
volumeSpec: volumeSpec,
// volume.volumeSpecName is actually InnerVolumeSpecName. It will not be used
// for volume cleanup.
// in case pod is added back to desired state, outerVolumeSpecName will be updated from dsw information.
// See issue #103143 and its fix for details.
// in case reconciler calls mountOrAttachVolumes, outerVolumeSpecName will
// be updated from dsw information in ASW.MarkVolumeAsMounted().
outerVolumeSpecName: volume.volumeSpecName,
pod: pod,
deviceMounter: deviceMounter,

View File

@ -344,7 +344,7 @@ func TestReconstructVolumesMount(t *testing.T) {
rcInstance.volumesNeedUpdateFromNodeStatus = nil
// Act 2 - reconcile once
rcInstance.reconcileNew()
rcInstance.reconcile()
// Assert 2
// MountDevice was attempted