@@ -46,6 +46,9 @@ type NodeExpander struct {
46
46
// PVC has already been updated - possibly because expansion already succeeded on different node.
47
47
// This can happen when a RWX PVC is expanded.
48
48
pvcAlreadyUpdated bool
49
+
50
+ // testStatus is used for testing purposes only.
51
+ testStatus testResponseData
49
52
}
50
53
51
54
func newNodeExpander (resizeOp nodeResizeOperationOpts , client clientset.Interface , recorder record.EventRecorder ) * NodeExpander {
@@ -115,11 +118,12 @@ func (ne *NodeExpander) runPreCheck() bool {
115
118
return false
116
119
}
117
120
118
- func (ne * NodeExpander ) expandOnPlugin () (bool , resource.Quantity , error , testResponseData ) {
121
+ func (ne * NodeExpander ) expandOnPlugin () (bool , resource.Quantity , error ) {
119
122
allowExpansion := ne .runPreCheck ()
120
123
if ! allowExpansion {
121
124
klog .V (3 ).Infof ("NodeExpandVolume is not allowed to proceed for volume %s with resizeStatus %s" , ne .vmt .VolumeName , ne .resizeStatus )
122
- return false , ne .pluginResizeOpts .OldSize , nil , testResponseData {false , true }
125
+ ne .testStatus = testResponseData {false /* resizeCalledOnPlugin */ , true /* assumeResizeFinished */ }
126
+ return false , ne .pluginResizeOpts .OldSize , nil
123
127
}
124
128
125
129
var err error
@@ -131,7 +135,8 @@ func (ne *NodeExpander) expandOnPlugin() (bool, resource.Quantity, error, testRe
131
135
if err != nil {
132
136
msg := ne .vmt .GenerateErrorDetailed ("MountVolume.NodeExpandVolume failed to mark node expansion in progress: %v" , err )
133
137
klog .Errorf (msg .Error ())
134
- return false , ne .pluginResizeOpts .OldSize , err , testResponseData {}
138
+ ne .testStatus = testResponseData {}
139
+ return false , ne .pluginResizeOpts .OldSize , err
135
140
}
136
141
}
137
142
_ , resizeErr := ne .volumePlugin .NodeExpand (ne .pluginResizeOpts )
@@ -158,24 +163,27 @@ func (ne *NodeExpander) expandOnPlugin() (bool, resource.Quantity, error, testRe
158
163
if volumetypes .IsFailedPreconditionError (resizeErr ) {
159
164
ne .actualStateOfWorld .MarkForInUseExpansionError (ne .vmt .VolumeName )
160
165
klog .Errorf (ne .vmt .GenerateErrorDetailed ("MountVolume.NodeExapndVolume failed with %v" , resizeErr ).Error ())
161
- return false , ne .pluginResizeOpts .OldSize , nil , testResponseData {assumeResizeFinished : true , resizeCalledOnPlugin : true }
166
+ ne .testStatus = testResponseData {assumeResizeFinished : true , resizeCalledOnPlugin : true }
167
+ return false , ne .pluginResizeOpts .OldSize , nil
162
168
}
163
- return false , ne .pluginResizeOpts .OldSize , resizeErr , testResponseData {assumeResizeFinished : true , resizeCalledOnPlugin : true }
169
+ ne .testStatus = testResponseData {assumeResizeFinished : true , resizeCalledOnPlugin : true }
170
+ return false , ne .pluginResizeOpts .OldSize , resizeErr
164
171
}
165
172
simpleMsg , detailedMsg := ne .vmt .GenerateMsg ("MountVolume.NodeExpandVolume succeeded" , nodeName )
166
173
ne .recorder .Eventf (ne .vmt .Pod , v1 .EventTypeNormal , kevents .FileSystemResizeSuccess , simpleMsg )
167
174
ne .recorder .Eventf (ne .pvc , v1 .EventTypeNormal , kevents .FileSystemResizeSuccess , simpleMsg )
168
175
klog .InfoS (detailedMsg , "pod" , klog .KObj (ne .vmt .Pod ))
169
176
177
+ ne .testStatus = testResponseData {true /*resizeCalledOnPlugin */ , true /* assumeResizeFinished */ }
170
178
// no need to update PVC object if we already updated it
171
179
if ne .pvcAlreadyUpdated {
172
- return true , ne .pluginResizeOpts .NewSize , nil , testResponseData { true , true }
180
+ return true , ne .pluginResizeOpts .NewSize , nil
173
181
}
174
182
175
183
// File system resize succeeded, now update the PVC's Capacity to match the PV's
176
184
ne .pvc , err = util .MarkFSResizeFinished (ne .pvc , ne .pluginResizeOpts .NewSize , ne .kubeClient )
177
185
if err != nil {
178
- return true , ne .pluginResizeOpts .NewSize , fmt .Errorf ("mountVolume.NodeExpandVolume update pvc status failed: %w" , err ), testResponseData { true , true }
186
+ return true , ne .pluginResizeOpts .NewSize , fmt .Errorf ("mountVolume.NodeExpandVolume update pvc status failed: %w" , err )
179
187
}
180
- return true , ne .pluginResizeOpts .NewSize , nil , testResponseData { true , true }
188
+ return true , ne .pluginResizeOpts .NewSize , nil
181
189
}
0 commit comments