@@ -133,7 +133,7 @@ void addFinalizerOnNewResource() {
133
133
verify (reconciler , never ())
134
134
.reconcile (ArgumentMatchers .eq (testCustomResource ), any ());
135
135
verify (customResourceFacade , times (1 ))
136
- .replaceResourceWithLock (
136
+ .updateResource (
137
137
argThat (testCustomResource -> testCustomResource .hasFinalizer (DEFAULT_FINALIZER )));
138
138
assertThat (testCustomResource .hasFinalizer (DEFAULT_FINALIZER )).isTrue ();
139
139
}
@@ -155,20 +155,20 @@ void updatesOnlyStatusSubResourceIfFinalizerSet() {
155
155
reconciliationDispatcher .handleExecution (executionScopeWithCREvent (testCustomResource ));
156
156
157
157
verify (customResourceFacade , times (1 )).patchStatus (eq (testCustomResource ), any ());
158
- verify (customResourceFacade , never ()).replaceResourceWithLock (any ());
158
+ verify (customResourceFacade , never ()).updateResource (any ());
159
159
}
160
160
161
161
@ Test
162
162
void updatesBothResourceAndStatusIfFinalizerSet () {
163
163
testCustomResource .addFinalizer (DEFAULT_FINALIZER );
164
164
165
165
reconciler .reconcile = (r , c ) -> UpdateControl .updateResourceAndStatus (testCustomResource );
166
- when (customResourceFacade .replaceResourceWithLock (testCustomResource ))
166
+ when (customResourceFacade .updateResource (testCustomResource ))
167
167
.thenReturn (testCustomResource );
168
168
169
169
reconciliationDispatcher .handleExecution (executionScopeWithCREvent (testCustomResource ));
170
170
171
- verify (customResourceFacade , times (1 )).replaceResourceWithLock (testCustomResource );
171
+ verify (customResourceFacade , times (1 )).updateResource (testCustomResource );
172
172
verify (customResourceFacade , times (1 )).updateStatus (testCustomResource );
173
173
}
174
174
@@ -182,7 +182,7 @@ void patchesStatus() {
182
182
183
183
verify (customResourceFacade , times (1 )).patchStatus (eq (testCustomResource ), any ());
184
184
verify (customResourceFacade , never ()).updateStatus (any ());
185
- verify (customResourceFacade , never ()).replaceResourceWithLock (any ());
185
+ verify (customResourceFacade , never ()).updateResource (any ());
186
186
}
187
187
188
188
@ Test
@@ -214,7 +214,7 @@ void removesDefaultFinalizerOnDeleteIfSet() {
214
214
reconciliationDispatcher .handleExecution (executionScopeWithCREvent (testCustomResource ));
215
215
216
216
assertThat (postExecControl .isFinalizerRemoved ()).isTrue ();
217
- verify (customResourceFacade , times (1 )).replaceResourceWithLock (testCustomResource );
217
+ verify (customResourceFacade , times (1 )).updateResource (testCustomResource );
218
218
}
219
219
220
220
@ Test
@@ -223,7 +223,7 @@ void retriesFinalizerRemovalWithFreshResource() {
223
223
markForDeletion (testCustomResource );
224
224
var resourceWithFinalizer = TestUtils .testCustomResource ();
225
225
resourceWithFinalizer .addFinalizer (DEFAULT_FINALIZER );
226
- when (customResourceFacade .replaceResourceWithLock (testCustomResource ))
226
+ when (customResourceFacade .updateResource (testCustomResource ))
227
227
.thenThrow (new KubernetesClientException (null , 409 , null ))
228
228
.thenReturn (testCustomResource );
229
229
when (customResourceFacade .getResource (any (), any ())).thenReturn (resourceWithFinalizer );
@@ -232,15 +232,15 @@ void retriesFinalizerRemovalWithFreshResource() {
232
232
reconciliationDispatcher .handleExecution (executionScopeWithCREvent (testCustomResource ));
233
233
234
234
assertThat (postExecControl .isFinalizerRemoved ()).isTrue ();
235
- verify (customResourceFacade , times (2 )).replaceResourceWithLock (any ());
235
+ verify (customResourceFacade , times (2 )).updateResource (any ());
236
236
verify (customResourceFacade , times (1 )).getResource (any (), any ());
237
237
}
238
238
239
239
@ Test
240
240
void throwsExceptionIfFinalizerRemovalRetryExceeded () {
241
241
testCustomResource .addFinalizer (DEFAULT_FINALIZER );
242
242
markForDeletion (testCustomResource );
243
- when (customResourceFacade .replaceResourceWithLock (any ()))
243
+ when (customResourceFacade .updateResource (any ()))
244
244
.thenThrow (new KubernetesClientException (null , 409 , null ));
245
245
when (customResourceFacade .getResource (any (), any ()))
246
246
.thenAnswer ((Answer <TestCustomResource >) invocationOnMock -> createResourceWithFinalizer ());
@@ -252,7 +252,7 @@ void throwsExceptionIfFinalizerRemovalRetryExceeded() {
252
252
assertThat (postExecControl .getRuntimeException ()).isPresent ();
253
253
assertThat (postExecControl .getRuntimeException ().get ())
254
254
.isInstanceOf (OperatorException .class );
255
- verify (customResourceFacade , times (MAX_FINALIZER_REMOVAL_RETRY )).replaceResourceWithLock (any ());
255
+ verify (customResourceFacade , times (MAX_FINALIZER_REMOVAL_RETRY )).updateResource (any ());
256
256
verify (customResourceFacade , times (MAX_FINALIZER_REMOVAL_RETRY - 1 )).getResource (any (),
257
257
any ());
258
258
}
@@ -261,15 +261,15 @@ void throwsExceptionIfFinalizerRemovalRetryExceeded() {
261
261
void throwsExceptionIfFinalizerRemovalClientExceptionIsNotConflict () {
262
262
testCustomResource .addFinalizer (DEFAULT_FINALIZER );
263
263
markForDeletion (testCustomResource );
264
- when (customResourceFacade .replaceResourceWithLock (any ()))
264
+ when (customResourceFacade .updateResource (any ()))
265
265
.thenThrow (new KubernetesClientException (null , 400 , null ));
266
266
267
267
var res =
268
268
reconciliationDispatcher .handleExecution (executionScopeWithCREvent (testCustomResource ));
269
269
270
270
assertThat (res .getRuntimeException ()).isPresent ();
271
271
assertThat (res .getRuntimeException ().get ()).isInstanceOf (KubernetesClientException .class );
272
- verify (customResourceFacade , times (1 )).replaceResourceWithLock (any ());
272
+ verify (customResourceFacade , times (1 )).updateResource (any ());
273
273
verify (customResourceFacade , never ()).getResource (any (), any ());
274
274
}
275
275
@@ -315,7 +315,7 @@ void doesNotRemovesTheSetFinalizerIfTheDeleteNotMethodInstructsIt() {
315
315
reconciliationDispatcher .handleExecution (executionScopeWithCREvent (testCustomResource ));
316
316
317
317
assertEquals (1 , testCustomResource .getMetadata ().getFinalizers ().size ());
318
- verify (customResourceFacade , never ()).replaceResourceWithLock (any ());
318
+ verify (customResourceFacade , never ()).updateResource (any ());
319
319
}
320
320
321
321
@ Test
@@ -325,21 +325,21 @@ void doesNotUpdateTheResourceIfNoUpdateUpdateControlIfFinalizerSet() {
325
325
reconciler .reconcile = (r , c ) -> UpdateControl .noUpdate ();
326
326
327
327
reconciliationDispatcher .handleExecution (executionScopeWithCREvent (testCustomResource ));
328
- verify (customResourceFacade , never ()).replaceResourceWithLock (any ());
328
+ verify (customResourceFacade , never ()).updateResource (any ());
329
329
verify (customResourceFacade , never ()).updateStatus (testCustomResource );
330
330
}
331
331
332
332
@ Test
333
333
void addsFinalizerIfNotMarkedForDeletionAndEmptyCustomResourceReturned () {
334
334
removeFinalizers (testCustomResource );
335
335
reconciler .reconcile = (r , c ) -> UpdateControl .noUpdate ();
336
- when (customResourceFacade .replaceResourceWithLock (any ())).thenReturn (testCustomResource );
336
+ when (customResourceFacade .updateResource (any ())).thenReturn (testCustomResource );
337
337
338
338
var postExecControl =
339
339
reconciliationDispatcher .handleExecution (executionScopeWithCREvent (testCustomResource ));
340
340
341
341
assertEquals (1 , testCustomResource .getMetadata ().getFinalizers ().size ());
342
- verify (customResourceFacade , times (1 )).replaceResourceWithLock (any ());
342
+ verify (customResourceFacade , times (1 )).updateResource (any ());
343
343
assertThat (postExecControl .updateIsStatusPatch ()).isFalse ();
344
344
assertThat (postExecControl .getUpdatedCustomResource ()).isPresent ();
345
345
}
@@ -351,7 +351,7 @@ void doesNotCallDeleteIfMarkedForDeletionButNotOurFinalizer() {
351
351
352
352
reconciliationDispatcher .handleExecution (executionScopeWithCREvent (testCustomResource ));
353
353
354
- verify (customResourceFacade , never ()).replaceResourceWithLock (any ());
354
+ verify (customResourceFacade , never ()).updateResource (any ());
355
355
verify (reconciler , never ()).cleanup (eq (testCustomResource ), any ());
356
356
}
357
357
@@ -475,7 +475,7 @@ void updateObservedGenerationOnCustomResourceUpdate() throws Exception {
475
475
when (config .isGenerationAware ()).thenReturn (true );
476
476
when (reconciler .reconcile (any (), any ()))
477
477
.thenReturn (UpdateControl .updateResource (observedGenResource ));
478
- when (facade .replaceResourceWithLock (any ())).thenReturn (observedGenResource );
478
+ when (facade .updateResource (any ())).thenReturn (observedGenResource );
479
479
when (facade .updateStatus (observedGenResource )).thenReturn (observedGenResource );
480
480
var dispatcher = init (observedGenResource , reconciler , config , facade , true );
481
481
0 commit comments