Properly handle the trailing/ in namespace registration and advertisement#2270
Conversation
jhiemstrawisc
left a comment
There was a problem hiding this comment.
Recording a few notes from the conversation we had in person for the record:
- This moved the error along a bit further so that registration succeeds, but there's still an issue with advertisement when the Origin exports a namespace with a trailing
/. I think we should target a few extra spots. Inserver_utils/origin.go::validateFederationPrefix()we should add something to strip the trailing/from the Origin's internal representation of the export (with a warning log statement telling the admin that this is happening). However, there are still old origins that won't do this, so we should look at where the advertisement arrives at the Director and make sure to strip the trailing/there as well, before that ad is stored in the TTL cache and before the Director asks the registry for the namespace key(s) used to verify the registration. - Let's add something in the e2e fed test package that tests the whole thing (the origin both registers and advertises successfully) to make sure the fixes in 1) did the trick.
- This one's a more recent pet peeve of mine that isn't something you introduced, but is in the functions you're touching here. I'm hoping you'll fix it 😉. In
registry/registry.go::keySignChallengeCommit()we do something like:
if clientVerified && serverVerified {
// big long section of indented code
} else {
return
}
My brain doesn't like excessive indentation, so I think this would be a lot easier to read:
if !(clientVerified && serverVerified) {
return
}
// big long section of code that's no longer indented
I think this style is referred to as guard clausing.
|
For 1), I create a new function to remove the trailing '/' in Origin exports. Because |
|
For 2), after some digging, I think the origin test framework would be sufficient for this modification. While spinning up a new fed test is unnecessary - we can't rely on fed tests too much because each fed test increase the test time significantly (Tests within a package are running sequentially). For 3), I'm happy to clear an eyesore 🧹🤪 |
/ in namespace registration/ in namespace registration and advertisement
- when the Origin exports a namespace with a trailing / - when the advertisement arrives at the Director, before that ad is stored in the TTL cache and before the Director asks the registry for the namespace key(s) used to verify the registration - add tests for the above
fab1c88 to
8e52103
Compare
We should allow user to set either
/foo/baror/foo/bar/as the federationprefix, but fundamentally treat them as the same (without trailing slash).This patch switches the order of prefix validation and prefix existence checking. It removes the trailing slash for the user input prefix, which prevents the error like this in the future.
Closes #1806