Skip to content

Commit

Permalink
fix #5020: updating the resourceVersion on delete with finalizers
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins authored and manusa committed Apr 11, 2023
1 parent 1020516 commit 334bf3e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Fix #4988: Ensuring that previous requests are closed before retry
* fix #5002: Jetty response completion accounts for header processing
* Fix #5009: addressing issue with serialization of wrapped polymophic types
* Fix #5020: updating the resourceVersion on a delete with finalizers

#### Improvements
* Fix #4434: Update CronJobIT to use `batch/v1` CronJob instead
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ private void processDelete(String path, AttributeSet pathAttributes, AttributeSe
if (!resource.isMarkedForDeletion()) {
// Mark the resource as deleted, but don't remove it yet (wait for finalizer-removal).
resource.getMetadata().setDeletionTimestamp(LocalDateTime.now().toString());
resource.getMetadata().setResourceVersion(String.valueOf(requestResourceVersion()));
String updatedResource = Serialization.asJson(resource);
processEvent(path, pathAttributes, oldAttributes, resource, updatedResource);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ void tearDown() {
private Owl createOwlWithFinalizer(String owlName) {
final Owl owl = new Owl();
owl.setMetadata(new ObjectMetaBuilder().withName(owlName).withFinalizers("test-finalizer").build());
client.resources(Owl.class).resource(owl).create();
return owl;
return client.resources(Owl.class).resource(owl).create();
}

@Test
Expand Down Expand Up @@ -96,6 +95,7 @@ void deleteResourceWithFinalizerTwiceSameDeletionTimestamp() {
String deletionTimestamp1 = owl1.getMetadata().getDeletionTimestamp();
assertNotNull(deletionTimestamp1);
assertDoesNotThrow(() -> DateTimeFormatter.ISO_DATE_TIME.parse(deletionTimestamp1));
assertNotEquals(initialOwl.getMetadata().getResourceVersion(), owl1.getMetadata().getResourceVersion());

// When the owl is deleted a second time:
client.resources(Owl.class).resource(owl1).delete();
Expand Down

0 comments on commit 334bf3e

Please sign in to comment.