Skip to content

Commit

Permalink
fix fabric8io#5020: updating the resourceVersion on delete with final…
Browse files Browse the repository at this point in the history
…izers
  • Loading branch information
shawkins committed Apr 6, 2023
1 parent 43f2e0e commit 488d0e3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
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 488d0e3

Please sign in to comment.