Skip to content

fix: fix lastAttempt value on first try when maxAttempt is zero #1397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 15 commits into from

Conversation

scrocquesel
Copy link
Contributor

Fix #1395

I start adding enabled() on Retry interface but it feels wrong. Retry is a functional interface so it needs a default and neither true or false is a good choice. Moreover, implementation can wrongly implement it. For eg, return true while not returning at least one next delay.

Seems like ReconciliationDispatcher may call initExecution but if we don't want to create an instance only to test nextDelay result, it should be propagated up to the EventProcessor to be cached and I don't see how to do that.

@scrocquesel scrocquesel marked this pull request as draft August 12, 2022 21:37
@scrocquesel scrocquesel changed the title Gh 1395 fix: fix lastAttempt value on first try when maxAttempt is zero Aug 12, 2022
@scrocquesel scrocquesel changed the base branch from main to next October 16, 2022 13:27
@@ -342,6 +350,16 @@ public UpdateControl<ConfigMap> reconcile(ConfigMap resource, Context<ConfigMap>
}
}

@ControllerConfiguration(retry = NoRetry.class)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@csviri Tried something with Optional but as expected, configuration is a bit weird. We need a marker class because the given class is not a factory but the actual strategy. Then, there is something wrong because nothing prevent from adding @GradualRetry with NoRetry.class.

Does something like

@ControllerConfiguration(retry = @GradualRetry(maxAttempts = 0))

@ControllerConfiguration(retry = @NoRetry)

with the annotation being a factory returning an Optional based on the given configuration could be better ?
I think this has been discussed already when introducing GradualRetry annotation in #1317 and I think we hit some limitations.

Maybe we can keep the annotation out of controllerConfiguration but need a way to discover annotations that would configure the controllerConfiguration and let them override default configuration.

@GradualRetry(maxAttempts = 0)
@ControllerConfiguration() // retry is no longer exposed

@NoRetry
@ControllerConfiguration() // retry is no longer exposed

return controller.getConfiguration().getRetry() == null;
// on first try, we can only rely on the configured behavior
// if enabled, will at least produce one RetryExecution
return !controller.getConfiguration().getRetry().isPresent();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be optimized to avoid multiple call to configuration doing initialization each time

@csviri
Copy link
Collaborator

csviri commented Oct 21, 2022

@scrocquesel what is the state of this PR? Do you intend to continue with this, in that case probably should be rebased.

Or I can take a look on the original issue.

@csviri
Copy link
Collaborator

csviri commented Oct 21, 2022

Jus out of curiosity why wouldn't you use a retry?

csviri and others added 11 commits October 21, 2022 14:52
* feat: decouple event source from cache + list discriminator (operator-framework#1378)

* feat: bulk dependent resources (operator-framework#1448)

* feat: optional eventsource on dependent resources (operator-framework#1479)

* refactor: simplify handling of reused event sources (operator-framework#1518)



Co-authored-by: Chris Laprun <[email protected]>

* refactor: isolate index handling to BulkDependentResource interface (operator-framework#1517)

* feat: key based bulk resource creation (operator-framework#1521)

* improvement: bulk dependent resource api

* merge

Co-authored-by: Chris Laprun <[email protected]>
Co-authored-by: Chris Laprun <[email protected]>
…ork#1544)

* refactor: deleteBulkResource -> deleteTargetResource

* refactor: remove now unneeded class

* refactor: deleteBulkResourcesIfRequired -> deleteExtraResources

* fix: javadoc
@scrocquesel
Copy link
Contributor Author

Jus out of curiosity why wouldn't you use a retry?

Generally, for testing purpose or when you set periodic reconciliation to lower impact on external services

@scrocquesel
Copy link
Contributor Author

@scrocquesel what is the state of this PR? Do you intend to continue with this, in that case probably should be rebased.

Or I can take a look on the original issue.

Help is welcome, I tried different things but i'm not satisfied.

@csviri csviri deleted the branch operator-framework:next October 31, 2022 08:55
@csviri csviri closed this Oct 31, 2022
@csviri
Copy link
Collaborator

csviri commented Oct 31, 2022

I think the next branch deletion, closed this. It clearly was not intentional.

@csviri
Copy link
Collaborator

csviri commented Oct 31, 2022

Pls reopen it if you want to proceed. If not I can take a look on this issue.

@scrocquesel
Copy link
Contributor Author

Pls reopen it if you want to proceed. If not I can take a look on this issue.

You may cherry pick d500347 to have a red test to start with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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