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

Cloudflare Preview sets an alias for long branch names #4308

Closed
Marigold opened this issue Dec 16, 2024 · 4 comments
Closed

Cloudflare Preview sets an alias for long branch names #4308

Marigold opened this issue Dec 16, 2024 · 4 comments
Labels
bug ops Devops related issues (stagings servers, ...)

Comments

@Marigold
Copy link
Contributor

Description

Staging servers deployed to Cloudflare Preview are not always hosted on https://[branch].owid.pages.dev as one would expect, but if the branch name is too long, CF creates a shorter alias for it. For instance

https://download-api-add-filter-information.owid.pages.dev/

becomes

https://download-api-add-filter-info.owid.pages.dev/

This is not easily fixable, because the alias is known only after deploying the preview, and we need it for BAKED_BASE_URL in baking.

Potential solutions

  1. Don't use long branch names
  2. Reverse engineer how CF creates an alias and use it
  • The problem is that other apps like owidbot rely on that URL, too. This would entail having "alias" function in multiple systems
  1. Create a proxy from https://[branch].owid.pages.dev to alias
  • Doing this dynamically through CF API could be painful
  1. Start using commit hashes like https://43c301ed.owid.pages.dev (the link wouldn't be persistent then...)
@marcelgerber
Copy link
Member

Related issues on the CF side: cloudflare/workers-sdk#2410, cloudflare/workers-sdk#7547.

Here's also a description of how the alias generating function works: https://community.cloudflare.com/t/algorithm-to-generate-a-preview-dns-subdomain-from-a-branch-name/477633/2

@Marigold
Copy link
Contributor Author

Marigold commented Dec 16, 2024

Thanks Marcel, that's very helpful!

Since we now know the alias function, the most straightforward fix would be to use the same function for creating the staging server name (or an even simpler version than what CF uses - i.e. truncating after 28 characters instead of 50), ensuring it doesn't get modified by CF. My only concern is having that function duplicated across multiple places and languages... but it's not going be worse than what we currently have.

@danyx23
Copy link
Contributor

danyx23 commented Dec 17, 2024

We could add a check on push if our branch names are longer than 28 characters? Seems like the easiest would be to just ensure this as a convention?

Suggest to close this issue - what do you think, @Marigold

@danyx23 danyx23 added ops Devops related issues (stagings servers, ...) and removed needs triage labels Dec 17, 2024
@Marigold
Copy link
Contributor Author

Fixed by truncating branch names to 28 characters, just as CF does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ops Devops related issues (stagings servers, ...)
Projects
None yet
Development

No branches or pull requests

3 participants