@@ -180,17 +180,6 @@ func (dswp *desiredStateOfWorldPopulator) populatorLoop(ctx context.Context) {
180
180
// Iterate through all pods and add to desired state of world if they don't
181
181
// exist but should
182
182
func (dswp * desiredStateOfWorldPopulator ) findAndAddNewPods (ctx context.Context ) {
183
- // Map unique pod name to outer volume name to MountedVolume.
184
- mountedVolumesForPod := make (map [volumetypes.UniquePodName ]map [string ]cache.MountedVolume )
185
- for _ , mountedVolume := range dswp .actualStateOfWorld .GetMountedVolumes () {
186
- mountedVolumes , exist := mountedVolumesForPod [mountedVolume .PodName ]
187
- if ! exist {
188
- mountedVolumes = make (map [string ]cache.MountedVolume )
189
- mountedVolumesForPod [mountedVolume .PodName ] = mountedVolumes
190
- }
191
- mountedVolumes [mountedVolume .OuterVolumeSpecName ] = mountedVolume
192
- }
193
-
194
183
for _ , pod := range dswp .podManager .GetPods () {
195
184
// Keep consistency of adding pod during reconstruction
196
185
if dswp .hasAddedPods && dswp .podStateProvider .ShouldPodContainersBeTerminating (pod .UID ) {
@@ -204,7 +193,7 @@ func (dswp *desiredStateOfWorldPopulator) findAndAddNewPods(ctx context.Context)
204
193
continue
205
194
}
206
195
207
- dswp .processPodVolumes (ctx , pod , mountedVolumesForPod )
196
+ dswp .processPodVolumes (ctx , pod )
208
197
}
209
198
}
210
199
@@ -286,10 +275,7 @@ func (dswp *desiredStateOfWorldPopulator) findAndRemoveDeletedPods() {
286
275
287
276
// processPodVolumes processes the volumes in the given pod and adds them to the
288
277
// desired state of the world.
289
- func (dswp * desiredStateOfWorldPopulator ) processPodVolumes (
290
- ctx context.Context ,
291
- pod * v1.Pod ,
292
- mountedVolumesForPod map [volumetypes.UniquePodName ]map [string ]cache.MountedVolume ) {
278
+ func (dswp * desiredStateOfWorldPopulator ) processPodVolumes (ctx context.Context , pod * v1.Pod ) {
293
279
if pod == nil {
294
280
return
295
281
}
@@ -322,17 +308,17 @@ func (dswp *desiredStateOfWorldPopulator) processPodVolumes(
322
308
}
323
309
324
310
// Add volume to desired state of world
325
- _ , err = dswp .desiredStateOfWorld .AddPodToVolume (
311
+ uniqueVolumeName , err : = dswp .desiredStateOfWorld .AddPodToVolume (
326
312
uniquePodName , pod , volumeSpec , podVolume .Name , volumeGIDValue , seLinuxContainerContexts [podVolume .Name ])
327
313
if err != nil {
328
314
logger .Error (err , "Failed to add volume to desiredStateOfWorld" , "pod" , klog .KObj (pod ), "volumeName" , podVolume .Name , "volumeSpecName" , volumeSpec .Name ())
329
315
dswp .desiredStateOfWorld .AddErrorToPod (uniquePodName , err .Error ())
330
316
allVolumesAdded = false
331
- } else {
332
- logger .V (4 ).Info ("Added volume to desired state" , "pod" , klog .KObj (pod ), "volumeName" , podVolume .Name , "volumeSpecName" , volumeSpec .Name ())
317
+ continue
333
318
}
334
319
335
- dswp .checkVolumeFSResize (pod , podVolume , pvc , volumeSpec , uniquePodName , mountedVolumesForPod )
320
+ logger .V (4 ).Info ("Added volume to desired state" , "pod" , klog .KObj (pod ), "volumeName" , podVolume .Name , "volumeSpecName" , volumeSpec .Name ())
321
+ dswp .checkVolumeFSResize (pod , podVolume , pvc , volumeSpec , uniqueVolumeName )
336
322
}
337
323
338
324
// some of the volume additions may have failed, should not mark this pod as fully processed
@@ -361,8 +347,7 @@ func (dswp *desiredStateOfWorldPopulator) checkVolumeFSResize(
361
347
podVolume v1.Volume ,
362
348
pvc * v1.PersistentVolumeClaim ,
363
349
volumeSpec * volume.Spec ,
364
- uniquePodName volumetypes.UniquePodName ,
365
- mountedVolumesForPod map [volumetypes.UniquePodName ]map [string ]cache.MountedVolume ) {
350
+ uniqueVolumeName v1.UniqueVolumeName ) {
366
351
367
352
// if a volumeSpec does not have PV or has InlineVolumeSpecForCSIMigration set or pvc is nil
368
353
// we can't resize the volume and hence resizing should be skipped.
@@ -371,13 +356,6 @@ func (dswp *desiredStateOfWorldPopulator) checkVolumeFSResize(
371
356
return
372
357
}
373
358
374
- uniqueVolumeName , exist := getUniqueVolumeName (uniquePodName , podVolume .Name , mountedVolumesForPod )
375
- if ! exist {
376
- // Volume not exist in ASW, we assume it hasn't been mounted yet. If it needs resize,
377
- // it will be handled as offline resize(if it indeed hasn't been mounted yet),
378
- // or online resize in subsequent loop(after we confirm it has been mounted).
379
- return
380
- }
381
359
// volumeSpec.ReadOnly is the value that determines if volume could be formatted when being mounted.
382
360
// This is the same flag that determines filesystem resizing behaviour for offline resizing and hence
383
361
// we should use it here. This value comes from Pod.spec.volumes.persistentVolumeClaim.readOnly.
@@ -395,21 +373,6 @@ func (dswp *desiredStateOfWorldPopulator) checkVolumeFSResize(
395
373
dswp .actualStateOfWorld .InitializeClaimSize (klog .TODO (), uniqueVolumeName , pvcStatusCap )
396
374
}
397
375
398
- func getUniqueVolumeName (
399
- podName volumetypes.UniquePodName ,
400
- outerVolumeSpecName string ,
401
- mountedVolumesForPod map [volumetypes.UniquePodName ]map [string ]cache.MountedVolume ) (v1.UniqueVolumeName , bool ) {
402
- mountedVolumes , exist := mountedVolumesForPod [podName ]
403
- if ! exist {
404
- return "" , false
405
- }
406
- mountedVolume , exist := mountedVolumes [outerVolumeSpecName ]
407
- if ! exist {
408
- return "" , false
409
- }
410
- return mountedVolume .VolumeName , true
411
- }
412
-
413
376
// podPreviouslyProcessed returns true if the volumes for this pod have already
414
377
// been processed/reprocessed by the populator. Otherwise, the volumes for this pod need to
415
378
// be reprocessed.
0 commit comments