Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.junit.jupiter.api.extension.RegisterExtension;

import io.fabric8.kubernetes.api.model.ObjectMetaBuilder;
import io.fabric8.kubernetes.client.KubernetesClientException;
import io.javaoperatorsdk.operator.junit.LocallyRunOperatorExtension;
import io.javaoperatorsdk.operator.processing.retry.GenericRetry;

Expand Down Expand Up @@ -218,13 +219,6 @@ void additionalEventDuringRetryOnDeleteEvent() {

addNoMoreExceptionAnnotation();

await()
.untilAsserted(
() -> {
var r = getResource();
assertThat(r.getMetadata().getFinalizers()).doesNotContain(FINALIZER);
});

removeAdditionalFinalizerWaitForResourceDeletion();
}

Expand Down Expand Up @@ -258,9 +252,24 @@ void additionalEventAfterExhaustedRetry() {
}

private void removeAdditionalFinalizerWaitForResourceDeletion() {
var res = getResource();
res.removeFinalizer(ADDITIONAL_FINALIZER);
extension.update(res);
// The reconciler removes its own finalizer during the reconciliation triggered above, but the
// event count is already increased at the beginning of the reconciliation. Therefore, waiting
// for the event count alone would release the test into the middle of that reconciliation, and
// the update below would race with the finalizer removal.
await()
.untilAsserted(
() ->
assertThat(getResource().getMetadata().getFinalizers())
.containsExactly(ADDITIONAL_FINALIZER));
// update is optimistically locked, so retry with a fresh read on conflict
await()
.ignoreException(KubernetesClientException.class)
.untilAsserted(
() -> {
var res = getResource();
res.removeFinalizer(ADDITIONAL_FINALIZER);
extension.update(res);
});
Comment on lines +265 to +272
await().untilAsserted(() -> assertThat(getResource()).isNull());
}

Expand Down
Loading