fix #4408: allowing for users to set the exception handling behavior #4488
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fix #4408
cc @csviri
I couldn't come up with a good way to deal with this all under the covers, so it seemed best to introduce an explicit handler with a signature that's sufficient to cover our default behavior. This makes the final solution much closer to some of the earlier proposals. For the method:
our current behavior is:
That is we'll retry once started and only if it's not a WatcherException.
The expectation here is that if you use the runnableInformer method, you can change this behavior by calling something like exceptionHandler((b, t) -> true)
In reviewing the go implementation, I see the following differences:
I've added a helper method to ExceptionHandler to check for deserialization issues - but that is not currently used in any built-in way. If you use something like exceptionHandler((b, t) -> true), but there is a jsonprocessing exception with the list call or with a watch event the result would be that you'll just keep retrying - a fresh list operation, then watch. If you don't want to make an assumption that things will self heal (a missing conversion webhook is installed later), then ExceptionHandler.isDeserializationException could be used - exceptionHandler((b, t) -> !ExceptionHandler.isDeserializationException(t))
With a major release we can then determine if the default behavior should become more generally to just keep retrying.
Along with this is a small breaking change to make the return type for start and stopped to be a CompletionStage rather than a CompletableFuture - I realized that since we don't want the user completing and don't support canceling, we should be using the narrower type instead. Since the stopped method was just introduced we may be able to change that one without too much concern (that would also need backported). If anyone has any qualms with start changing as well, I'll revert that.
Type of change
test, version modification, documentation, etc.)
Checklist