Skip to content

Proxito: refactor canonical redirects #10069

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

Merged
merged 6 commits into from
Mar 1, 2023
Merged

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Feb 24, 2023

Implementing the plan from #10065.

  • I'm caching all the redirects by default now, since the final URL will be checked for authz
  • Cache tags now are given by the project from the unresolved domain, since we are caching the response on that domain! Previous behavior wasn't correct.

Closes #10065

@stsewd stsewd force-pushed the refactor-canonical-redirects branch from e368e05 to 00ec8fb Compare February 27, 2023 16:15
@stsewd stsewd force-pushed the refactor-canonical-redirects branch from 00ec8fb to 1ab1759 Compare February 27, 2023 16:32
@stsewd stsewd marked this pull request as ready for review February 27, 2023 16:39
@stsewd stsewd requested a review from a team as a code owner February 27, 2023 16:39
@stsewd stsewd requested a review from benjaoming February 27, 2023 16:39
@stsewd stsewd requested review from ericholscher and humitos and removed request for benjaoming February 27, 2023 16:40
@ericholscher
Copy link
Member

Cache tags now are given by the project from the unresolved domain, since we are caching the response on that domain! Previous behavior wasn't correct.

Nice!

Copy link
Member

@ericholscher ericholscher 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 exciting too! Lots more comments, because I haven't looked through this refactor as much before, so sorry about that.

Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

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

Looks close!

Would this refactor be compatible with the resolution of this issue? #9988

Comment on lines +251 to +252
use_custom_domain = self._use_cname(canonical_project)
custom_domain = canonical_project.get_canonical_custom_domain()
Copy link
Member

Choose a reason for hiding this comment

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

What about overriding .get_canonical_custom_domain() instead? Would that be doable and simpler?

@benjaoming benjaoming changed the title Proxito: refactor canocanical redirects Proxito: refactor canonical redirects Feb 28, 2023
@stsewd
Copy link
Member Author

stsewd commented Feb 28, 2023

Would this refactor be compatible with the resolution of this issue? #9988

Logic around redirects won't change, or at least in a way that breaks the current expected behavior. Canonical redirects always were first, user redirects were second.

@stsewd
Copy link
Member Author

stsewd commented Feb 28, 2023

This should be ready for another round of review, added a glossary of the terms we use for each URL part at https://github.com/readthedocs/readthedocs.org/pull/10069/files#diff-92614ae090281fddaae958813072070fe6fe35b6491babadaab557c05898b8ab.

@ericholscher ericholscher linked an issue Feb 28, 2023 that may be closed by this pull request
Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

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

👍🏼

@@ -648,6 +649,17 @@ def proxied_static_path(self):
"""Path for static files hosted on the user's doc domain."""
return f"{self.proxied_api_host}/static/"

@property
def custom_path_prefix(self):
Copy link
Member

Choose a reason for hiding this comment

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

I feel these name changes a lot easier to read and follow 👍🏼

Copy link
Member

Choose a reason for hiding this comment

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

Naming is hard :)

@@ -5,6 +5,41 @@ Module in charge of serving documentation pages.

Read the Docs core team members can view the `Proxito design doc <https://github.com/readthedocs/el-proxito/blob/master/docs/design/architecture.rst>`_

URL parts
Copy link
Member

Choose a reason for hiding this comment

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

This is a really good start! 💯

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, really happy to see this.

Comment on lines 31 to 41
URL
|------------------------------------------------|
path
|---------------------|
https://docs.readthedocs.io/en/latest/index.html
|-------|-------------------|--|------|----------|
protocol | | | |
domain | | |
language | |
version |
filename
Copy link
Member

Choose a reason for hiding this comment

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

💯

Copy link
Member

Choose a reason for hiding this comment

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

This is great. Though this is varying a bit from urlparse in some ways which make sense, but we should be explicit if we don't care about the other parts (eg. query & fragment).

urlparse("scheme://netloc/path;parameters?query#fragment")

https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlparse

Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

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

Agreed this looks really good! 🎉

Comment on lines 31 to 41
URL
|------------------------------------------------|
path
|---------------------|
https://docs.readthedocs.io/en/latest/index.html
|-------|-------------------|--|------|----------|
protocol | | | |
domain | | |
language | |
version |
filename
Copy link
Member

Choose a reason for hiding this comment

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

This is great. Though this is varying a bit from urlparse in some ways which make sense, but we should be explicit if we don't care about the other parts (eg. query & fragment).

urlparse("scheme://netloc/path;parameters?query#fragment")

https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlparse

@stsewd stsewd merged commit 033aa6c into main Mar 1, 2023
@stsewd stsewd deleted the refactor-canonical-redirects branch March 1, 2023 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants