Repository: kubernetes/kubernetes (language: go)

Issue:
[Flaky test] k8s.io/kubernetes/pkg/kubelet/volumemanager TestWaitForAllPodsUnmount
### Which jobs are flaking?

https://prow.k8s.io/job-history/gs/ppc64le-kubernetes/logs/periodic-kubernetes-unit-test-ppc64le

### Which tests are flaking?

k8s.io/kubernetes/pkg/kubelet/volumemanager TestWaitForAllPodsUnmount

### Since when has it been flaking?

We saw the first flake on October 2nd aroudn6:31am IST. 
https://prow.k8s.io/view/gs/ppc64le-kubernetes/logs/periodic-kubernetes-unit-test-ppc64le/1841282068785401856 is teh first job flake observed

### Testgrid link

https://testgrid.k8s.io/ibm-k8s-unit-tests-ppc64le#periodic-k8s-unit-tests-ppc64le

### Reason for failure (if possible)

```
WARNING: DATA RACE
Read at 0x00c00051d818 by goroutine 210:
  k8s.io/kubernetes/pkg/kubelet/volumemanager/cache.(*desiredStateOfWorld).GetVolumesToMount()
      /home/prow/go/src/github.com/kubernetes/kubernetes/pkg/kubelet/volumemanager/cache/desired_state_of_world.go:614 +0x4c0
  k8s.io/kubernetes/pkg/kubelet/volumemanager/reconciler.(*reconciler).mountOrAttachVolumes()
      /home/prow/go/src/github.com/kubernetes/kubernetes/pkg/kubelet/volumemanager/reconciler/reconciler_common.go:167 +0x60
  k8s.io/kubernetes/pkg/kubelet/volumemanager/reconciler.(*reconciler).reconcile()
      /home/prow/go/src/github.com/kubernetes/kubernetes/pkg/kubelet/volumemanager/reconciler/reconciler.go:44 +0xa8
  k8s.io/kubernetes/pkg/kubelet/volumemanager/reconciler.(*reconciler).reconcile-fm()
      <autogenerated>:1 +0x58
  k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1()
      /home/prow/go/src/github.com/kubernetes/kubernetes/staging/src/k8s.io/apimachinery/pkg/util/wait/backoff.go:226 +0x5c
  k8s.io/apimachinery/pkg/util/wait.BackoffUntil()
      /home/prow/go/src/github.com/kubernetes/kubernetes/staging/src/k8s.io/apimachinery/pkg/util/wait/backoff.go:227 +0xd0
  k8s.io/apimachinery/pkg/util/wait.JitterUntil()
      /home/prow/go/src/github.com/kubernetes/kubernetes/staging/src/k8s.io/apimachinery/pkg/util/wait/backoff.go:204 +0x124
  k8s.io/apimachinery/pkg/util/wait.Until()
      /home/prow/go/src/github.com/kubernetes/kubernetes/staging/src/k8s.io/apimachinery/pkg/util/wait/backoff.go:161 +0xfc
  k8s.io/kubernetes/pkg/kubelet/volumemanager/reconciler.(*reconciler).Run()
      /home/prow/go/src/github.com/kubernetes/kubernetes/pkg/kubelet/volumemanager/reconciler/reconciler.go:27 +0xac
  k8s.io/kubernetes/pkg/kubelet/volumemanager.(*volumeManager).Run.gowrap4()
      /home/prow/go/src/github.com/kubernetes/kubernetes/pkg/kubelet/volumemanager/volume_manager.go:298 +0x78

Previous write at 0x00c00051d818 by goroutine 209:
  k8s.io/apimachinery/pkg/api/resource.(*Quantity).String()
      /home/prow/go/src/github.com/kubernetes/kubernetes/staging/src/k8s.io/apimachinery/pkg/api/resource/quantity.go:687 +0x110
  k8s.io/kubernetes/pkg/kubelet/volumemanager/populator.(*desiredStateOfWorldPopulator).checkVolumeFSResize()
      /home/prow/go/src/github.com/kubernetes/kubernetes/pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go:390 +0x8e0
  k8s.io/kubernetes/pkg/kubelet/volumemanager/populator.(*desiredStateOfWorldPopulator).processPodVolumes()
      /home/prow/go/src/github.com/kubernetes/kubernetes/pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go:332 +0xeb8
  k8s.io/kubernetes/pkg/kubelet/volumemanager/populator.(*desiredStateOfWorldPopulator).findAndAddNewPods()
      /home/prow/go/src/github.com/kubernetes/kubernetes/pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go:205 +0x478
  k8s.io/kubernetes/pkg/kubelet/volumemanager/populator.(*desiredStateOfWorldPopulator).populatorLoop()
      /home/prow/go/src/github.com/kubernetes/kubernetes/pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go:174 +0x58
  k8s.io/kubernetes/pkg/kubelet/volumemanager/populator.(*desiredStateOfWorldPopulator).populatorLoop-fm()
      <autogenerated>:1 +0x78
  k8s.io/apimachinery/pkg/util/wait.JitterUntilWithContext.func1()
      /home/prow/go/src/github.com/kubernetes/kubernetes/staging/src/k8s.io/apimachinery/pkg/util/wait/backoff.go:259 +0x54
  k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1()
      /home/prow/go/src/github.com/kubernetes/kubernetes/staging/src/k8s.io/apimachinery/pkg/util/wait/backoff.go:226 +0x5c
  k8s.io/apimachinery/pkg/util/wait.BackoffUntil()
      /home/prow/go/src/github.com/kubernetes/kubernetes/staging/src/k8s.io/apimachinery/pkg/util/wait/backoff.go:227 +0xd0
  k8s.io/apimachinery/pkg/util/wait.JitterUntil()
      /home/prow/go/src/github.com/kubernetes/kubernetes/staging/src/k8s.io/apimachinery/pkg/util/wait/backoff.go:204 +0x124
  k8s.io/apimachinery/pkg/util/wait.JitterUntilWithContext()
      /home/prow/go/src/github.com/kubernetes/kubernetes/staging/src/k8s.io/apimachinery/pkg/util/wait/backoff.go:259 +0xe8
  k8s.io/apimachinery/pkg/util/wait.UntilWithContext()
      /home/prow/go/src/github.com/kubernetes/kubernetes/staging/src/k8s.io/apimachinery/pkg/util/wait/backoff.go:170 +0x1d8
  k8s.io/kubernetes/pkg/kubelet/volumemanager/populator.(*desiredStateOfWorldPopulator).Run()
      /home/prow/go/src/github.com/kubernetes/kubernetes/pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go:159 +0x188
  k8s.io/kubernetes/pkg/kubelet/volumemanager.(*volumeManager).Run.gowrap3()
      /home/prow/go/src/github.com/kubernetes/kubernetes/pkg/kubelet/volumemanager/volume_manager.go:294 +0x9c

Goroutine 210 (running) created at:
  k8s.io/kubernetes/pkg/kubelet/volumemanager.(*volumeManager).Run()
      /home/prow/go/src/github.com/kubernetes/kubernetes/pkg/kubelet/volumemanager/volume_manager.go:298 +0x45c
  k8s.io/kubernetes/pkg/kubelet/volumemanager.TestWaitForAllPodsUnmount.func2.gowrap1()
      /home/prow/go/src/github.com/kubernetes/kubernetes/pkg/kubelet/volumemanager/volume_manager_test.go:592 +0x9c

Goroutine 209 (running) created at:
  k8s.io/kubernetes/pkg/kubelet/volumemanager.(*volumeManager).Run()
      /home/prow/go/src/github.com/kubernetes/kubernetes/pkg/kubelet/volumemanager/volume_manager.go:294 +0x2a4
  k8s.io/kubernetes/pkg/kubelet/volumemanager.TestWaitForAllPodsUnmount.func2.gowrap1()
      /home/prow/go/src/github.com/kubernetes/kubernetes/pkg/kubelet/volumemanager/volume_manager_test.go:592 +0x9c
==================
I1002 01:18:51.528490   48828 volume_manager.go:303] "Shutting down Kubelet Volume Manager"
    testing.go:1399: race detected during execution of test
--- FAIL: TestWaitForAllPodsUnmount/timeout_waiting_for_unmount (1.00s)
;=== RUN   TestWaitForAllPodsUnmount
--- FAIL: TestWaitForAllPodsUnmount (1.00s)
;}
```

### Anything else we need to know?

The trace in this test failure has similar lines as in 
https://github.com/kubernetes/kubernetes/issues/127349
https://github.com/kubernetes/kubernetes/issues/127520

### Relevant SIG(s)
/sig storage

Steps to Reproduce Flake:
(Environment must have stable Golang required for k8s UT ro run)
1. git clone https://github.com/kubernetes/kubernetes/
2. cd kubernetes/
3.  export CGO_ENABLED=1
4. go test ./pkg/kubelet/volumemanager -c -count=1 -race
5. go install golang.org/x/tools/cmd/stress@latest
6. /root/go/bin/stress ./volumemanager.test -test.run TestWaitForAllPodsUnmount

Please find the attached file with the test output from stress tool.
[go-stress-20241004T034530-2916714152.txt](https://github.com/user-attachments/files/17257353/go-stress-20241004T034530-2916714152.txt)

Note: This flake is observed in x86 as well inspite of seeing it in CI on ppc64le.



Discussion / hints:
This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the `triage/accepted` label and provide further guidance.

The `triage/accepted` label can be added by org members by writing `/triage accepted` in a comment.


<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
</details>
This test was added recently couple of weeks back by https://github.com/kubernetes/kubernetes/commit/b4a21a3e43ced6c573d8b16086bd5bbe1c70123d
@torredil ^^
A few observations:
- As I understand the trace, the data race is happening between the goroutines started within volume manager's `Run` func.
- This has nothing to do with the traces referenced above (#127349, #127520).
- The data race is not introduced by https://github.com/kubernetes/kubernetes/commit/b4a21a3e43ced6c573d8b16086bd5bbe1c70123d and can be reproduced even with this simple test in the `release-1.30` branch:

```
stress ./volumemanager.test -test.run VolumeManagerDataRace
```
```
func VolumeManagerDataRace(t *testing.T) {
	tmpDir, _ := utiltesting.MkTmpdir("volumeManagerTest")
	defer func() {
		if err := os.RemoveAll(tmpDir); err != nil {
			t.Errorf("Failed to remove temp directory: %v", err)
		}
	}()
	t.Run("test", func(t *testing.T) {
		podManager := kubepod.NewBasicPodManager()
		node, pod, pv, claim := createObjects("", "")
		kubeClient := fake.NewSimpleClientset(node, pod, pv, claim)
		
		manager := newTestVolumeManager(t, tmpDir, podManager, kubeClient, node)
		runVolumeManager(manager)
	})
}

```
- Seems to be extremely rare, on average it takes at least several thousand runs to observe the failure:
```
17m20s: 3876 runs so far, 1 failures (0.03%), 8 active
```

Fix patch:
diff --git a/pkg/controller/volume/attachdetach/cache/actual_state_of_world.go b/pkg/controller/volume/attachdetach/cache/actual_state_of_world.go
index b5188e0c01d72..045f4c45b19fc 100644
--- a/pkg/controller/volume/attachdetach/cache/actual_state_of_world.go
+++ b/pkg/controller/volume/attachdetach/cache/actual_state_of_world.go
@@ -584,13 +584,13 @@ func (asw *actualStateOfWorld) GetAttachState(
 }
 
 // SetVolumeClaimSize sets size of the volume. But this function should not be used from attach_detach controller.
-func (asw *actualStateOfWorld) InitializeClaimSize(logger klog.Logger, volumeName v1.UniqueVolumeName, claimSize *resource.Quantity) {
+func (asw *actualStateOfWorld) InitializeClaimSize(logger klog.Logger, volumeName v1.UniqueVolumeName, claimSize resource.Quantity) {
 	logger.V(5).Info("no-op InitializeClaimSize call in attach-detach controller")
 }
 
-func (asw *actualStateOfWorld) GetClaimSize(volumeName v1.UniqueVolumeName) *resource.Quantity {
+func (asw *actualStateOfWorld) GetClaimSize(volumeName v1.UniqueVolumeName) resource.Quantity {
 	// not needed in attach-detach controller
-	return nil
+	return resource.Quantity{}
 }
 
 func (asw *actualStateOfWorld) GetAttachedVolumes() []AttachedVolume {
diff --git a/pkg/kubelet/volumemanager/cache/actual_state_of_world.go b/pkg/kubelet/volumemanager/cache/actual_state_of_world.go
index 6f3aab66569a9..78f8523be436f 100644
--- a/pkg/kubelet/volumemanager/cache/actual_state_of_world.go
+++ b/pkg/kubelet/volumemanager/cache/actual_state_of_world.go
@@ -321,7 +321,7 @@ type attachedVolume struct {
 
 	// persistentVolumeSize records size of the volume when pod was started or
 	// size after successful completion of volume expansion operation.
-	persistentVolumeSize *resource.Quantity
+	persistentVolumeSize resource.Quantity
 
 	// seLinuxMountContext is the context with that the volume is mounted to global directory
 	// (via -o context=XYZ mount option). If nil, the volume is not mounted. If "", the volume is
@@ -788,7 +788,7 @@ func (asw *actualStateOfWorld) AddPodToVolume(markVolumeOpts operationexecutor.M
 	return nil
 }
 
-func (asw *actualStateOfWorld) MarkVolumeAsResized(volumeName v1.UniqueVolumeName, claimSize *resource.Quantity) bool {
+func (asw *actualStateOfWorld) MarkVolumeAsResized(volumeName v1.UniqueVolumeName, claimSize resource.Quantity) bool {
 	asw.Lock()
 	defer asw.Unlock()
 
@@ -850,28 +850,28 @@ func (asw *actualStateOfWorld) SetDeviceMountState(
 	return nil
 }
 
-func (asw *actualStateOfWorld) InitializeClaimSize(logger klog.Logger, volumeName v1.UniqueVolumeName, claimSize *resource.Quantity) {
+func (asw *actualStateOfWorld) InitializeClaimSize(logger klog.Logger, volumeName v1.UniqueVolumeName, claimSize resource.Quantity) {
 	asw.Lock()
 	defer asw.Unlock()
 
 	volumeObj, ok := asw.attachedVolumes[volumeName]
 	// only set volume claim size if claimStatusSize is zero
 	// this can happen when volume was rebuilt after kubelet startup
-	if ok && volumeObj.persistentVolumeSize == nil {
+	if ok && volumeObj.persistentVolumeSize.IsZero() {
 		volumeObj.persistentVolumeSize = claimSize
 		asw.attachedVolumes[volumeName] = volumeObj
 	}
 }
 
-func (asw *actualStateOfWorld) GetClaimSize(volumeName v1.UniqueVolumeName) *resource.Quantity {
+func (asw *actualStateOfWorld) GetClaimSize(volumeName v1.UniqueVolumeName) resource.Quantity {
 	asw.RLock()
 	defer asw.RUnlock()
 
 	volumeObj, ok := asw.attachedVolumes[volumeName]
 	if ok {
-		return volumeObj.persistentVolumeSize
+		return volumeObj.persistentVolumeSize.DeepCopy()
 	}
-	return nil
+	return resource.Quantity{}
 }
 
 func (asw *actualStateOfWorld) DeletePodFromVolume(
@@ -970,20 +970,17 @@ func (asw *actualStateOfWorld) PodHasMountedVolumes(podName volumetypes.UniquePo
 }
 
 func (asw *actualStateOfWorld) volumeNeedsExpansion(volumeObj attachedVolume, desiredVolumeSize resource.Quantity) (resource.Quantity, bool) {
-	currentSize := resource.Quantity{}
-	if volumeObj.persistentVolumeSize != nil {
-		currentSize = volumeObj.persistentVolumeSize.DeepCopy()
-	}
+	currentSize := volumeObj.persistentVolumeSize.DeepCopy()
 	if volumeObj.volumeInUseErrorForExpansion {
 		return currentSize, false
 	}
-	if volumeObj.persistentVolumeSize == nil || desiredVolumeSize.IsZero() {
+	if volumeObj.persistentVolumeSize.IsZero() || desiredVolumeSize.IsZero() {
 		return currentSize, false
 	}
 
 	klog.V(5).InfoS("NodeExpandVolume checking size", "actualSize", volumeObj.persistentVolumeSize.String(), "desiredSize", desiredVolumeSize.String(), "volume", volumeObj.volumeName)
 
-	if desiredVolumeSize.Cmp(*volumeObj.persistentVolumeSize) > 0 {
+	if desiredVolumeSize.Cmp(volumeObj.persistentVolumeSize) > 0 {
 		volumePlugin, err := asw.volumePluginMgr.FindNodeExpandablePluginBySpec(volumeObj.spec)
 		if err != nil || volumePlugin == nil {
 			// Log and continue processing
diff --git a/pkg/kubelet/volumemanager/cache/desired_state_of_world.go b/pkg/kubelet/volumemanager/cache/desired_state_of_world.go
index 0702016818b23..81a2240ad3813 100644
--- a/pkg/kubelet/volumemanager/cache/desired_state_of_world.go
+++ b/pkg/kubelet/volumemanager/cache/desired_state_of_world.go
@@ -134,7 +134,7 @@ type DesiredStateOfWorld interface {
 	// UpdatePersistentVolumeSize updates persistentVolumeSize in desired state of the world
 	// so as it can be compared against actual size and volume expansion performed
 	// if necessary
-	UpdatePersistentVolumeSize(volumeName v1.UniqueVolumeName, size *resource.Quantity)
+	UpdatePersistentVolumeSize(volumeName v1.UniqueVolumeName, size resource.Quantity)
 }
 
 // VolumeToMount represents a volume that is attached to this node and needs to
@@ -206,7 +206,7 @@ type volumeToMount struct {
 
 	// persistentVolumeSize records desired size of a persistent volume.
 	// Usually this value reflects size recorded in pv.Spec.Capacity
-	persistentVolumeSize *resource.Quantity
+	persistentVolumeSize resource.Quantity
 
 	// effectiveSELinuxMountFileLabel is the SELinux label that will be applied to the volume using mount options.
 	// If empty, then:
@@ -347,7 +347,7 @@ func (dsw *desiredStateOfWorld) AddPodToVolume(
 			pvCap := volumeSpec.PersistentVolume.Spec.Capacity.Storage()
 			if pvCap != nil {
 				pvCapCopy := pvCap.DeepCopy()
-				vmt.persistentVolumeSize = &pvCapCopy
+				vmt.persistentVolumeSize = pvCapCopy
 			}
 		}
 		dsw.volumesToMount[volumeName] = vmt
@@ -499,7 +499,7 @@ func (dsw *desiredStateOfWorld) DeletePodFromVolume(
 
 // UpdatePersistentVolumeSize updates last known PV size. This is used for volume expansion and
 // should be only used for persistent volumes.
-func (dsw *desiredStateOfWorld) UpdatePersistentVolumeSize(volumeName v1.UniqueVolumeName, size *resource.Quantity) {
+func (dsw *desiredStateOfWorld) UpdatePersistentVolumeSize(volumeName v1.UniqueVolumeName, size resource.Quantity) {
 	dsw.Lock()
 	defer dsw.Unlock()
 
@@ -610,7 +610,7 @@ func (dsw *desiredStateOfWorld) GetVolumesToMount() []VolumeToMount {
 					SELinuxLabel:            volumeObj.effectiveSELinuxMountFileLabel,
 				},
 			}
-			if volumeObj.persistentVolumeSize != nil {
+			if !volumeObj.persistentVolumeSize.IsZero() {
 				vmt.DesiredPersistentVolumeSize = volumeObj.persistentVolumeSize.DeepCopy()
 			}
 			volumesToMount = append(volumesToMount, vmt)
diff --git a/pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go b/pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go
index c6c503d53870a..8fa56742f8e76 100644
--- a/pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go
+++ b/pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go
@@ -384,8 +384,8 @@ func (dswp *desiredStateOfWorldPopulator) checkVolumeFSResize(
 		return
 	}
 
-	pvCap := volumeSpec.PersistentVolume.Spec.Capacity.Storage()
-	pvcStatusCap := pvc.Status.Capacity.Storage()
+	pvCap := volumeSpec.PersistentVolume.Spec.Capacity.Storage().DeepCopy()
+	pvcStatusCap := pvc.Status.Capacity.Storage().DeepCopy()
 	dswp.desiredStateOfWorld.UpdatePersistentVolumeSize(uniqueVolumeName, pvCap)
 	klog.V(5).InfoS("NodeExpandVolume updating size", "actualSize", pvcStatusCap.String(), "desiredSize", pvCap.String(), "volumeName", uniqueVolumeName)
 	// in case the actualStateOfWorld was rebuild after kubelet restart ensure that claimSize is set to accurate value
diff --git a/pkg/volume/util/operationexecutor/operation_executor.go b/pkg/volume/util/operationexecutor/operation_executor.go
index d8fd95186d64c..6de2123e9318b 100644
--- a/pkg/volume/util/operationexecutor/operation_executor.go
+++ b/pkg/volume/util/operationexecutor/operation_executor.go
@@ -198,7 +198,7 @@ type ActualStateOfWorldMounterUpdater interface {
 	MarkDeviceAsUnmounted(volumeName v1.UniqueVolumeName) error
 
 	// Marks the specified volume's file system resize request is finished.
-	MarkVolumeAsResized(volumeName v1.UniqueVolumeName, claimSize *resource.Quantity) bool
+	MarkVolumeAsResized(volumeName v1.UniqueVolumeName, claimSize resource.Quantity) bool
 
 	// GetDeviceMountState returns mount state of the device in global path
 	GetDeviceMountState(volumeName v1.UniqueVolumeName) DeviceMountState
@@ -277,9 +277,9 @@ type ActualStateOfWorldAttacherUpdater interface {
 	AddVolumeToReportAsAttached(logger klog.Logger, volumeName v1.UniqueVolumeName, nodeName types.NodeName)
 
 	// InitializeClaimSize sets pvc claim size by reading pvc.Status.Capacity
-	InitializeClaimSize(logger klog.Logger, volumeName v1.UniqueVolumeName, claimSize *resource.Quantity)
+	InitializeClaimSize(logger klog.Logger, volumeName v1.UniqueVolumeName, claimSize resource.Quantity)
 
-	GetClaimSize(volumeName v1.UniqueVolumeName) *resource.Quantity
+	GetClaimSize(volumeName v1.UniqueVolumeName) resource.Quantity
 }
 
 // VolumeLogger defines a set of operations for generating volume-related logging and error msgs
diff --git a/pkg/volume/util/operationexecutor/operation_generator.go b/pkg/volume/util/operationexecutor/operation_generator.go
index 5f63aaa3db7fa..0933a31f4e930 100644
--- a/pkg/volume/util/operationexecutor/operation_generator.go
+++ b/pkg/volume/util/operationexecutor/operation_generator.go
@@ -1436,7 +1436,7 @@ func (og *operationGenerator) GenerateVerifyControllerAttachedVolumeFunc(
 		claimSize := actualStateOfWorld.GetClaimSize(volumeToMount.VolumeName)
 
 		// only fetch claimSize if it was not set previously
-		if volumeToMount.VolumeSpec.PersistentVolume != nil && claimSize == nil && !volumeToMount.VolumeSpec.InlineVolumeSpecForCSIMigration {
+		if volumeToMount.VolumeSpec.PersistentVolume != nil && claimSize.IsZero() && !volumeToMount.VolumeSpec.InlineVolumeSpecForCSIMigration {
 			pv := volumeToMount.VolumeSpec.PersistentVolume
 			pvc, err := og.kubeClient.CoreV1().PersistentVolumeClaims(pv.Spec.ClaimRef.Namespace).Get(context.TODO(), pv.Spec.ClaimRef.Name, metav1.GetOptions{})
 			if err != nil {
@@ -1445,7 +1445,7 @@ func (og *operationGenerator) GenerateVerifyControllerAttachedVolumeFunc(
 			}
 			pvcStatusSize := pvc.Status.Capacity.Storage()
 			if pvcStatusSize != nil {
-				claimSize = pvcStatusSize
+				claimSize = pvcStatusSize.DeepCopy()
 			}
 		}
 
@@ -1964,7 +1964,7 @@ func (og *operationGenerator) doOnlineExpansion(volumeToMount VolumeToMount,
 		return false, e1, e2
 	}
 	if resizeDone {
-		markingDone := actualStateOfWorld.MarkVolumeAsResized(volumeToMount.VolumeName, &newSize)
+		markingDone := actualStateOfWorld.MarkVolumeAsResized(volumeToMount.VolumeName, newSize)
 		if !markingDone {
 			// On failure, return error. Caller will log and retry.
 			genericFailureError := fmt.Errorf("unable to mark volume as resized")


Test patch:
diff --git a/pkg/kubelet/volumemanager/reconciler/reconciler_test.go b/pkg/kubelet/volumemanager/reconciler/reconciler_test.go
index 741123ace69e5..7f6d1b2f9cab4 100644
--- a/pkg/kubelet/volumemanager/reconciler/reconciler_test.go
+++ b/pkg/kubelet/volumemanager/reconciler/reconciler_test.go
@@ -1374,7 +1374,7 @@ func Test_Run_Positive_VolumeFSResizeControllerAttachEnabled(t *testing.T) {
 
 			t.Logf("Changing size of the volume to %s", tc.newPVSize.String())
 			newSize := tc.newPVSize.DeepCopy()
-			dsw.UpdatePersistentVolumeSize(volumeName, &newSize)
+			dsw.UpdatePersistentVolumeSize(volumeName, newSize)
 
 			_, _, podExistErr := asw.PodExistsInVolume(podName, volumeName, newSize, "" /* SELinuxLabel */)
 			if tc.expansionFailed {
diff --git a/pkg/volume/util/operationexecutor/node_expander_test.go b/pkg/volume/util/operationexecutor/node_expander_test.go
index 81938d509c694..4ac020005e1da 100644
--- a/pkg/volume/util/operationexecutor/node_expander_test.go
+++ b/pkg/volume/util/operationexecutor/node_expander_test.go
@@ -266,7 +266,7 @@ func (f *fakeActualStateOfWorld) MarkVolumeAsMounted(markVolumeOpts MarkVolumeOp
 }
 
 // MarkVolumeAsResized implements ActualStateOfWorldMounterUpdater.
-func (f *fakeActualStateOfWorld) MarkVolumeAsResized(volumeName v1.UniqueVolumeName, claimSize *resource.Quantity) bool {
+func (f *fakeActualStateOfWorld) MarkVolumeAsResized(volumeName v1.UniqueVolumeName, claimSize resource.Quantity) bool {
 	panic("unimplemented")
 }