-
Notifications
You must be signed in to change notification settings - Fork 6
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
Fix exception handling in AsyncDefaultAdmissionRequestMutator #284
Fix exception handling in AsyncDefaultAdmissionRequestMutator #284
Conversation
return asyncMutator.mutate(clonedResource, operation) | ||
.thenApply(resource -> admissionResponseFromMutation(originalResource, resource)) | ||
.exceptionally(e -> { | ||
if (e instanceof CompletionException) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the actual fix.
this(mutator, new ObjectMapperCloner<>()); | ||
} | ||
|
||
public AsyncDefaultAdmissionRequestMutator(AsyncMutator<T> mutator, Cloner<T> cloner) { | ||
this.mutator = mutator; | ||
public AsyncDefaultAdmissionRequestMutator(Mutator<T> mutator, Cloner<T> cloner) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the internal convenience constructor to enable the use of a Mutator
for an async endpoint.
resource.getMetadata().getLabels().putIfAbsent(MUTATION_TARGET_LABEL, "mutation-test"); | ||
return resource; | ||
})); | ||
return new AsyncAdmissionController<>(new IngressMutator()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This demonstrates the usage of the new convenience constructor. In general this shows how you can de-deduplicate the code for mutators and validators by using old-school inner classes that can be used for sync and async endpoints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you simply run mvn clean install
, that should fix it (if remember correctly)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, best would be to migrate this repo also to spotless plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly not, mvn clean install
is successful and no files are changed. The Quarkus/JOSDK repos with spotless worked indeed fine for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, sry, for me neither. Would you like to do the migration to spotless or should I do it (not sure in what timeline) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a Maven guy (anymore), but I can surely have a look. I'd say this should go in to a new PR and then I rebase this one later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that would be ideal, thx!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've re-created the branch from main
, cherry-picked each commit and ran spotless:apply
for all of them. So all commits should be compliant with the code formatting now.
Obviously it wasn't enough to import the code style into IDEA. Sadly EDIT: I just |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
Signed-off-by: David Sondermann <[email protected]>
Signed-off-by: David Sondermann <[email protected]>
Signed-off-by: David Sondermann <[email protected]>
7ff0dd4
to
d530946
Compare
@Donnerbart the build fails, could you pls take a look. Thx |
Signed-off-by: David Sondermann <[email protected]>
…d add constructor for Mutator interface Signed-off-by: David Sondermann <[email protected]>
d530946
to
6a6492f
Compare
It was just a missing import, an oversight when I re-created the branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thx @Donnerbart
Fixes #283
AsyncDefaultAdmissionRequestMutator
AsyncAdmissionController(Mutator<T> mutator)
constructorMutator
andValidator
classes inio.javaoperatorsdk.webhook.sample.commons.AdmissionControllers
Code Coverage
main
bugfix/fix-async-mutator-exception-handling