java-operator-sdk icon indicating copy to clipboard operation
java-operator-sdk copied to clipboard

isLastAttempt() is false on the single call to handle error when max-attempts is zero

Open scrocquesel opened this issue 3 years ago • 4 comments

Bug Report

To track the issue raised by https://github.com/quarkiverse/quarkus-operator-sdk/issues/380

scrocquesel avatar Aug 11 '22 18:08 scrocquesel

The problem is that the first reconcile loop has no information from the RetryConfiguration if the builded RetryInfo will actually provide a nextDelay.

As it seems that retryConfiguration cannot be null (there is always a default one), Instead of

@Override
public boolean isLastAttempt() {
  return controller.getConfiguration().getRetryConfiguration() == null;
}

may be something like

@Override
public boolean isLastAttempt() {
  return controller.getConfiguration().getRetryConfiguration().isActive()l;
}

The GenericRetryConfiguration may return false when max-attemps is 0.

scrocquesel avatar Aug 11 '22 18:08 scrocquesel

A repro https://github.com/scrocquesel/java-operator-sdk/blob/gh-1395/operator-framework/src/test/java/io/javaoperatorsdk/operator/ErrorStatusHandlerLastAttemptIT.java

scrocquesel avatar Aug 12 '22 21:08 scrocquesel

I think it should be rather nullable, thus controller.getConfiguration().getRetryConfiguration() should return an Optional?

That is better describing the domain, that there might not be a retry.

csviri avatar Aug 22 '22 07:08 csviri

I think it should be rather nullable, thus controller.getConfiguration().getRetryConfiguration() should return an Optional?

That is better describing the domain, that there might not be a retry.

It means that the configuration process is aware of why a given config for a given implementation would not produce a retry so it can set an empty RetryConfiguration instead of the given config/implementation.

scrocquesel avatar Aug 27 '22 17:08 scrocquesel

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

github-actions[bot] avatar Oct 27 '22 03:10 github-actions[bot]

@scrocquesel fixed this here: https://github.com/java-operator-sdk/java-operator-sdk/pull/1595 pls take a look if you have some time.

it is quite simple this way.

csviri avatar Nov 09 '22 12:11 csviri