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 PerformValidation more like DoDCV #7828

Merged
merged 11 commits into from
Nov 20, 2024
Merged

Conversation

beautifulentropy
Copy link
Member

@beautifulentropy beautifulentropy commented Nov 19, 2024

  • Remove Perspective and RIR from ValidationRecords
  • Make ValidationResultToPB Perspective and RIR aware
  • Update comment for VA.PerformValidation
  • Make verificationRequestEvent more like doDCVAuditLog
  • Update language used in problems created by performRemoteValidation to be more like doRemoteDCV.

@beautifulentropy beautifulentropy marked this pull request as ready for review November 19, 2024 16:51
@beautifulentropy beautifulentropy requested a review from a team as a code owner November 19, 2024 16:51
aarongable
aarongable previously approved these changes Nov 19, 2024
va/va.go Outdated Show resolved Hide resolved
va/va.go Outdated Show resolved Hide resolved
jprenken
jprenken previously approved these changes Nov 20, 2024
aarongable
aarongable previously approved these changes Nov 20, 2024
Comment on lines +467 to +470
go func(rva RemoteVA) {
res, err := rva.PerformValidation(ctx, req)
out <- &response{
addr: rva.Address,
result: res,
err: err,
}
}(va.remoteVAs[i], responses)
responses <- &response{rva.Address, res, err}
}(va.remoteVAs[i])
Copy link
Contributor

Choose a reason for hiding this comment

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

Just noting that removing the channel as an argument to this anonymous function is not a necessary change.

I added the channel as an argument here in #7522 upon Jacob's reminder that "explicit is better than implicit" -- it's better for the anonymous function to be explicit about what objects it is using than to implicitly close over everything.

It's a fully arbitrary line -- obviously I added the channel as an argument but didn't bother to add ctx as an argument too. I think there are perfectly good arguments to be made that this anonymous function should take no arguments, just the rva (effectively the loop variable), or take everything as arguments. Just noting that this is a personal preference change for which we don't have an established team-wide best practice.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also worth noting I recently added a subCtx here (which is captured in the same way as ctx is) and considered adding it to the explicit argument list but wound up not doing so, since I thought folks might not like it stylistically. So there's some local pattern matching possible for "does this anonymous function need to receive all things as parameters? or is taking some of them as captures okay?"

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh and I remembered the specific reason I backed out that change! I was going to pass subCtx as a parameter, but call that parameter ctx locally. So inside the function we would have ctx shadowed and have no chance of using the original ctx by accident. But I decided that was too clever by half and backed it out.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, interesting! Personally, I prefer closing over everything. Initially, I wasn’t planning to backport this change and was instead going to update the MPIC code. However, I noticed we’re doing the same thing in this function’s offshoot in va/caa.go, so I figured this was a consistency win:

boulder/va/caa.go

Lines 239 to 273 in a8cdaf8

func (va *ValidationAuthorityImpl) performRemoteCAACheck(
ctx context.Context,
req *vapb.IsCAAValidRequest,
results chan<- *remoteVAResult) {
for _, i := range rand.Perm(len(va.remoteVAs)) {
remoteVA := va.remoteVAs[i]
go func(rva RemoteVA) {
result := &remoteVAResult{
VAHostname: rva.Address,
}
res, err := rva.IsCAAValid(ctx, req)
if err != nil {
if canceled.Is(err) {
// Handle the cancellation error.
result.Problem = probs.ServerInternal("Remote VA IsCAAValid RPC cancelled")
} else {
// Handle validation error.
va.log.Errf("Remote VA %q.IsCAAValid failed: %s", rva.Address, err)
result.Problem = probs.ServerInternal("Remote VA IsCAAValid RPC failed")
}
} else if res.Problem != nil {
prob, err := bgrpc.PBToProblemDetails(res.Problem)
if err != nil {
va.log.Infof("Remote VA %q.IsCAAValid returned malformed problem: %s", rva.Address, err)
result.Problem = probs.ServerInternal(
fmt.Sprintf("Remote VA IsCAAValid RPC returned malformed result: %s", err))
} else {
va.log.Infof("Remote VA %q.IsCAAValid returned problem: %s", rva.Address, prob)
result.Problem = prob
}
}
results <- result
}(remoteVA)
}
}

jsha
jsha previously approved these changes Nov 20, 2024
@beautifulentropy beautifulentropy merged commit 8bf13a9 into main Nov 20, 2024
12 checks passed
@beautifulentropy beautifulentropy deleted the mpic-backport-4 branch November 20, 2024 19:13
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