-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
We had a lot of ancient master url helper functions, that all needed revisiting. The main philosophical update is a transition from "validate and canonicalize every master url every time" to "validate and canonicalize user input and assume the url is canonicalized everywhere else". This is similar to the networking concept of a "dumb network with smart edges", which allows network internals to be simple and scalable. In the same way, our code internals can be simple and easy to write, and only when receiving user input do we need to worry about validation or canonicalization. Issues with the old code: - parse_master_url() wasn't just parsing, it was also doing some amount of canonicalization (but not enough). - parse_master_url() actually returned a ParsedURL object but (almost) nobody used it directly; it was mostly a step of make_url(). - make_url() was essentially doing a urllib.parse.urljoin() on its arguments, where the first argument was the master_url and, confusingly, the second argument was actually allowed to an absolute url, causing the first argument to be ignored. Even more confusingly, there was a test that ensured that codepath worked, even though the test said it was "unexpected". And lastly that confusing functionality was never used, since we never let users pass values directly to that function. - make_url_new() claimed to deprecate make_url() (even though they are both internal functions) but make_url_new() was only used in the `det dev` subcommands, causing those commands to exhibit different behavior than the rest of the system. Also, make_url_new() explicitly preserved the most confusing parts of make_url(). - master_url was optional all over the place (even on internal functions), and we were willing to read from environment variables in way too many places. Confusingly, there were zero instances of calling these internal functions without a master_url, so the complexity was pointless. Solutions in the new code: - There is a canonicalize_master_url() that must be applied to all user-provided values before proceeding to the internal parts of the system. Happily, this only occurs in four places: - In the CLI. - In the det.cli.tunnel module (a different CLI, basically). - In the python SDK. - When building a ClusterInfo object. - Delete make_url() entirely. It was always confusing what it did, creating a cargo-cult situation where you had to use it but you didn't know why. Replace every use of make_url() with simple f-string concatenation of the master_url and the api path. - Design the canonical form of the master url specifically to make f-string concatenation of the master url and the path effective. - Bump the TokenStore's auth.json to v2, which is just like v1 only the master urls must be canonicalized, which is the actual fix for MLG-878.
- Loading branch information
1 parent
e3709bd
commit 72d54be
Showing
31 changed files
with
507 additions
and
348 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.