@@ -120,6 +120,9 @@ type ActualStateOfWorld interface {
120
120
// and false is returned.
121
121
PodRemovedFromVolume (podName volumetypes.UniquePodName , volumeName v1.UniqueVolumeName ) bool
122
122
123
+ // PodHasMountedVolumes returns true if any volume is mounted on the given pod
124
+ PodHasMountedVolumes (podName volumetypes.UniquePodName ) bool
125
+
123
126
// VolumeExistsWithSpecName returns true if the given volume specified with the
124
127
// volume spec name (a.k.a., InnerVolumeSpecName) exists in the list of
125
128
// volumes that should be attached to this node.
@@ -146,6 +149,10 @@ type ActualStateOfWorld interface {
146
149
// current actual state of the world.
147
150
GetMountedVolumesForPod (podName volumetypes.UniquePodName ) []MountedVolume
148
151
152
+ // GetMountedVolumeForPodByOuterVolumeSpecName returns the volume and true if
153
+ // the given outerVolumeSpecName is mounted on the given pod.
154
+ GetMountedVolumeForPodByOuterVolumeSpecName (podName volumetypes.UniquePodName , outerVolumeSpecName string ) (MountedVolume , bool )
155
+
149
156
// GetPossiblyMountedVolumesForPod generates and returns a list of volumes for
150
157
// the specified pod that either are attached and mounted or are "uncertain",
151
158
// i.e. a volume plugin may be mounting the volume right now.
@@ -948,6 +955,20 @@ func (asw *actualStateOfWorld) PodExistsInVolume(podName volumetypes.UniquePodNa
948
955
return podExists , volumeObj .devicePath , nil
949
956
}
950
957
958
+ func (asw * actualStateOfWorld ) PodHasMountedVolumes (podName volumetypes.UniquePodName ) bool {
959
+ asw .RLock ()
960
+ defer asw .RUnlock ()
961
+ for _ , volumeObj := range asw .attachedVolumes {
962
+ if podObj , hasPod := volumeObj .mountedPods [podName ]; hasPod {
963
+ if podObj .volumeMountStateForPod == operationexecutor .VolumeMounted {
964
+ return true
965
+ }
966
+ }
967
+ }
968
+
969
+ return false
970
+ }
971
+
951
972
func (asw * actualStateOfWorld ) volumeNeedsExpansion (volumeObj attachedVolume , desiredVolumeSize resource.Quantity ) (resource.Quantity , bool ) {
952
973
currentSize := resource.Quantity {}
953
974
if volumeObj .persistentVolumeSize != nil {
@@ -1063,7 +1084,7 @@ func (asw *actualStateOfWorld) GetMountedVolumesForPod(
1063
1084
podName volumetypes.UniquePodName ) []MountedVolume {
1064
1085
asw .RLock ()
1065
1086
defer asw .RUnlock ()
1066
- mountedVolume := make ([]MountedVolume , 0 /* len */ , len ( asw . attachedVolumes ) /* cap */ )
1087
+ mountedVolume := make ([]MountedVolume , 0 /* len */ )
1067
1088
for _ , volumeObj := range asw .attachedVolumes {
1068
1089
for mountedPodName , podObj := range volumeObj .mountedPods {
1069
1090
if mountedPodName == podName && podObj .volumeMountStateForPod == operationexecutor .VolumeMounted {
@@ -1077,6 +1098,21 @@ func (asw *actualStateOfWorld) GetMountedVolumesForPod(
1077
1098
return mountedVolume
1078
1099
}
1079
1100
1101
+ func (asw * actualStateOfWorld ) GetMountedVolumeForPodByOuterVolumeSpecName (
1102
+ podName volumetypes.UniquePodName , outerVolumeSpecName string ) (MountedVolume , bool ) {
1103
+ asw .RLock ()
1104
+ defer asw .RUnlock ()
1105
+ for _ , volumeObj := range asw .attachedVolumes {
1106
+ if podObj , hasPod := volumeObj .mountedPods [podName ]; hasPod {
1107
+ if podObj .volumeMountStateForPod == operationexecutor .VolumeMounted && podObj .outerVolumeSpecName == outerVolumeSpecName {
1108
+ return getMountedVolume (& podObj , & volumeObj ), true
1109
+ }
1110
+ }
1111
+ }
1112
+
1113
+ return MountedVolume {}, false
1114
+ }
1115
+
1080
1116
func (asw * actualStateOfWorld ) GetPossiblyMountedVolumesForPod (
1081
1117
podName volumetypes.UniquePodName ) []MountedVolume {
1082
1118
asw .RLock ()
0 commit comments