Skip to content
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

VA: Make performRemoteValidation more generic #7847

Merged
merged 3 commits into from
Nov 27, 2024

Conversation

beautifulentropy
Copy link
Member

@beautifulentropy beautifulentropy commented Nov 26, 2024

  • Make performRemoteValidation a more generic function that returns a new remoteResult interface
  • Modify the return value of IsCAAValid and PerformValidation to satisfy the remoteResult interface
  • Include compile time checks and tests that pass an arbitrary operation

@beautifulentropy beautifulentropy force-pushed the generic-perform-remote-validation branch from c6d1a3d to 80fa2a3 Compare November 26, 2024 16:25
@beautifulentropy beautifulentropy force-pushed the generic-perform-remote-validation branch from 80fa2a3 to b305e5e Compare November 26, 2024 16:33
@beautifulentropy beautifulentropy marked this pull request as ready for review November 26, 2024 16:35
@beautifulentropy beautifulentropy requested a review from a team as a code owner November 26, 2024 16:35
jprenken
jprenken previously approved these changes Nov 26, 2024
va/va.go Show resolved Hide resolved
va/va.go Show resolved Hide resolved
} else {
va.log.Errf("Remote VA %q.PerformValidation failed: %s", resp.addr, resp.err)
currProb = probs.ServerInternal("Secondary domain validation RPC failed")
va.log.Errf("Operation on remote VA (%s) failed: %s", resp.addr, resp.err)
Copy link
Contributor

Choose a reason for hiding this comment

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

If there's a clean way to get the human-readable name of the operation interpolated into this log message (and the similar one on line 526), that'd be really nice. But I suspect that doing so ends up being pretty ugly, so feel free to ignore me.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm pretty sure it does wind up being ugly. We could pass the name of the operation into performRemoteValidation, but passing in a string just for the purpose of returning an error is ugly indeed.

Though that makes me realize: that's exactly what error wrapping is for. The caller (PerformValidation or IsCAAValid) knows which operation it was asking for, and can add that information by wrapping a returned error.

Copy link
Member Author

@beautifulentropy beautifulentropy Nov 27, 2024

Choose a reason for hiding this comment

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

I tried to add this but unfortunately it wasn’t very testable. The only way I can think to introduce a failure would be to replace the PerformValidation impl but that’s the same impl we’re going to call the operation on inside of performRemoteOperation. I would only be testing that my own test impl wraps errors 😅. I also don’t think it’ll be terribly useful. Inside of PerformValidation we never return the internal error to the caller (except for some of the first few checks), instead we log them and then pass it through detailedError() which is going to unwrap to a specific error and return it as a problem that’s relevant to the requester.

va/va.go Outdated Show resolved Hide resolved
va/va.go Show resolved Hide resolved
Copy link
Contributor

@jsha jsha left a comment

Choose a reason for hiding this comment

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

This is very nice! I'll approve after Aaron's comments have been addressed.

Copy link
Contributor

@jsha jsha left a comment

Choose a reason for hiding this comment

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

Lookin' awesome, just a couple small tweaks left. 🔧

va/va.go Outdated Show resolved Hide resolved
va/va.go Show resolved Hide resolved
va/va_test.go Show resolved Hide resolved
@beautifulentropy beautifulentropy merged commit 27a7714 into main Nov 27, 2024
12 checks passed
@beautifulentropy beautifulentropy deleted the generic-perform-remote-validation branch November 27, 2024 20:29
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.

4 participants