-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Allow for branch name lengths of 45 #8692
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
Conversation
I believe the build failure is unrelated to your changes(Ref), but let's retry after the quota problem is solved 🙂 |
Codecov Report
@@ Coverage Diff @@
## main #8692 +/- ##
==========================================
- Coverage 12.31% 11.17% -1.14%
==========================================
Files 20 18 -2
Lines 1161 993 -168
==========================================
- Hits 143 111 -32
+ Misses 1014 880 -134
+ Partials 4 2 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
b76ad64
to
630c3e3
Compare
This relaxes the branch name restriction from 20 characters to 45. This is achieved by constructing the preview name based on the first 10 characters of the branch name and then the first 10 characters of the hashed value of the branch name. All places that (to my knowledge) rely on the preview name has been updated. Fixes gitpod-io/ops#1252
630c3e3
to
2a525f6
Compare
Adding the hold label as I want to ask the teams if I have overlooked any places where we rely on the old on the branch name <-> preview environment name pattern |
@mads-hartmann Thx for looking into this! I just wonder if it's worth putting in this additional complexity when (I just learned that) VM-based previews BETA is just around the corner...? E.g., the property of deriving the name of the preview in your head is very nice to have. And If I have to mentally cut-off my branch names for just another 2-3 weeks until we're migrated completly, I personally gladly do so. 🙂 |
@geropl That was our initial hope as well but I decided to take this on for the following reasons:
So the 20 character limit restriction isn't going away soon (in all cases, at least) I got a sense that this is extremely frustrating to a lot of people and the request keeps coming up (slack, issue) and is confusing people (slack). In the last 14 days it has broken 58 builds and affected 32 different branches (query). While the PR touches quite a few files/places, I don't think it's adding complexity as such. It decouples the preview name from the Werft job name (which is a good thing IMO) and consolidates the "name generation" to a single place per language. I agree that the preview names can end up being not very readable, but that's only if you use more than 20 chars. And once we have fully migrated to VMs and deleted core-dev we can relax that so we get 45 (or 43, I forgot) characters for the branch name in the preview environment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and then the first 10 characters of the hashed value of the branch name if the branch name is longer than 20 characters
@mads-hartmann I overlooked this, sorry. 🙈 With this there is no sense in arguing - I'd even say keep the behavior for later (just with 20->45) then! 🙏
I personally would vote for cutting the branch names to 45 characters and accept the risk of a collision. I would guess the risk is quite low. However, nothing that should hold this pull request back but only my 2 cents for future decisions. Thanks a lot for this pull request! 😍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job! Awesome to see the attention you've put onto details to ensure backwards compatibility 🙂
I just have a couple of questions
.then(() => werft.endAllSpans()) | ||
.catch((err) => { | ||
werft.rootSpan.setStatus({ | ||
code: SpanStatusCode.ERROR, | ||
message: err | ||
}) | ||
}) | ||
.finally(() => { | ||
werft.phase("Flushing telemetry", "Flushing telemetry before stopping job") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to make sure, this isn't related to the proposed change, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this was a tiny improvement we should make it the other jobs as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And it was moved to "finally" as we want to flush in both the error and success cases :)
// During the transition from the old preview names to the new ones we have to check for the existence of both the old or new | ||
// preview name patterns before it is safe to delete a namespace. | ||
const expectedPreviewEnvironmentNamespaces = new Set(branches.flatMap(branch => [parseBranch(branch), expectedNamespaceFromBranch(branch)])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice safety check! That didn't cross my mind when I tried to implement this
* Based on the current branch name this will compute the name of the associated | ||
* preview environment. | ||
* | ||
* NOTE: This needs to produce the same result as the function in dev/preview/util/preview-name-from-branch.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid drift, could we just call scripts/branch-namespace.sh
wherever this function is called instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer not to for the following reasons:
- Currently the function doens't have any side effects. That's generally nice for utility functions as it means you can usually read the "main" script which uses the utility functions to understand what changes are made to your environment when you invoke it.
- The branch-namespace.sh function is core-dev specific and this utility function is used both for VMs and core-dev preview environments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, LGTM!
Description
This relaxes the branch name restriction from 20 characters to 45. This is achieved by constructing the preview name based on the first 10 characters of the branch name and then the first 10 characters of the hashed value of the branch name if the branch name is longer than 20 characters. Once we move to Harvester we can likely increase the preview name to be longer than 20 characters but still not arbitrarily long - see this issue and the comments therein for more details on where these restrictions are coming from. The purpose of making it longer than 20 characters would be to have more readable preview names - e.g. https://mads-a-lond78d730379.staging.gitpod-dev.com isn't the most readable thing in the world.
The 45 limit of the branch name is now based on an implementation detail in Werft. The Werft Job name is used as the name of the pod. Kubernetes has a pod name limit of 63 characters. For the build job we use 13 chars for "gitpod-build-" prefix and 5 for the "." ending (as there's a max supported of 9999 jobs for the same branch) - see Werft source - this leaves 45 characters for the branch name. We could decide to just not care, as there would only be a collision if the first 45 characters are the same. For this PR I decided to care.
Some implementation details
Some consequences of merging this PR
Related Issue(s)
Fixes https://github.com/gitpod-io/ops/issues/1252
How to test
scripts/branch-namespace.sh
works correctlyRelease Notes
Documentation
N/A