Skip to content

forcing the werft job to fail if the branch name is too long to suppo… #8316

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 1 commit into from
Feb 25, 2022

Conversation

fullmetalrooster
Copy link
Contributor

@fullmetalrooster fullmetalrooster commented Feb 18, 2022

/werft no-preview

Description

This set a limit for the branch name to 26 characters to make sure that preview-environments can get started. The length depends either on the length of the domain that is created or the label that is added by ws-daemon/registry-facade.
It does not solve the problem but at least gives a useful information instead of just failing.

Related Issue(s)

Fixes #8169

How to test

Run a preview environment on a branch with a long, 26 character at least, and a short name.

Release Notes

None

Documentation

@codecov
Copy link

codecov bot commented Feb 18, 2022

Codecov Report

Merging #8316 (2af29f0) into main (6f8bbba) will increase coverage by 2.75%.
The diff coverage is n/a.

❗ Current head 2af29f0 differs from pull request most recent head d78dad7. Consider uploading reports for the commit d78dad7 to get more accurate results

Impacted file tree graph

@@            Coverage Diff            @@
##            main    #8316      +/-   ##
=========================================
+ Coverage   8.42%   11.17%   +2.75%     
=========================================
  Files         33       18      -15     
  Lines       2339      993    -1346     
=========================================
- Hits         197      111      -86     
+ Misses      2137      880    -1257     
+ Partials       5        2       -3     
Flag Coverage Δ
components-gitpod-cli-app 11.17% <ø> (ø)
components-installer-raw-app ?
components-local-app-app-darwin-amd64 ?
components-local-app-app-darwin-arm64 ?
components-local-app-app-linux-amd64 ?
components-local-app-app-linux-arm64 ?
components-local-app-app-windows-386 ?
components-local-app-app-windows-amd64 ?
components-local-app-app-windows-arm64 ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
components/installer/pkg/common/objects.go
.../installer/pkg/components/ws-manager/deployment.go
components/installer/pkg/common/common.go
...components/ws-manager/unpriviledged-rolebinding.go
components/installer/pkg/common/ca.go
...s/installer/pkg/components/ws-manager/tlssecret.go
...staller/pkg/components/ws-manager/networkpolicy.go
components/local-app/pkg/auth/auth.go
components/installer/pkg/common/render.go
components/local-app/pkg/auth/pkce.go
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6f8bbba...d78dad7. Read the comment docs.

// echo -n "gitpod.io/registry-facade_ready_ns_staging-" | wc -c
const maxBranchNameLength = 20;
if (deploymentConfig.destname.length > maxBranchNameLength) {
werft.fail(phases.PREDEPLOY, `The branch name ${deploymentConfig.destname} is more than ${maxBranchNameLength} character. Please choose a shorter name!`)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should fail much sooner than that - best before we do anything.
Note: don't forget to tie this to the absence of no-preview

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
Contributor Author

Choose a reason for hiding this comment

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

I put it there as it is the phase where it would break. I created an extra phase that fails early. I tested it with this branch [1], with noPreview [2] and with a branch that has a shorter name [3].

@corneliusludmann
Copy link
Contributor

Can't we just shorten the destname to the required length instead of letting the job fail? E.g. here:

const previewDestName = version.split(".")[0];
const previewEnvironmentNamespace = withVM ? `default` : `staging-${previewDestName}`;
const previewEnvironment = {
destname: previewDestName,
namespace: previewEnvironmentNamespace
}

@geropl
Copy link
Member

geropl commented Feb 21, 2022

Can't we just shorten the destname to the required length instead of letting the job fail?

IMO this is just a quick fix, and we should merge the early-as-possible error fix here. Hopefully we won't have this restriction too long, until we can use 1 VM / preview environment.

@fullmetalrooster
Copy link
Contributor Author

fullmetalrooster commented Feb 21, 2022

Can't we just shorten the destname to the required length instead of letting the job fail? E.g. here:

const previewDestName = version.split(".")[0];
const previewEnvironmentNamespace = withVM ? `default` : `staging-${previewDestName}`;
const previewEnvironment = {
destname: previewDestName,
namespace: previewEnvironmentNamespace
}

I do not know all places where the branch-name is used and simply shortening it might break something down the line.

mads-hartmann
mads-hartmann previously approved these changes Feb 24, 2022
Copy link
Contributor

@mads-hartmann mads-hartmann left a comment

Choose a reason for hiding this comment

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

Thanks @wulfthimm!

Let's get this merged - we're working on allowing longer names in parallel - follow https://github.com/gitpod-io/ops/issues/1252 if you're interested in that.

@mads-hartmann
Copy link
Contributor

mads-hartmann commented Feb 24, 2022

@wulfthimm Adding the hold label - the build job needs to be happy before this can be merged ☺️

@fullmetalrooster fullmetalrooster changed the base branch from main to wth/test February 24, 2022 13:44
@fullmetalrooster fullmetalrooster changed the base branch from wth/test to main February 24, 2022 13:44
@fullmetalrooster
Copy link
Contributor Author

@wulfthimm Adding the hold label - the build job needs to be happy before this can be merged relaxed

I added the no-preview flag. And now it was successful. For verification I started a job with this PR on a shorter branch. https://werft.gitpod-dev.com/job/gitpod-build-wth-short.0

mads-hartmann
mads-hartmann previously approved these changes Feb 24, 2022
Copy link
Contributor

@mads-hartmann mads-hartmann left a comment

Choose a reason for hiding this comment

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

@wulfthimm I approved but added the hold label. Please merge this PR manually using Squash and merge so you can edit the commit message to get rid of the /werft command (otherwise branches off main won't get a preview environment)

@mads-hartmann
Copy link
Contributor

mads-hartmann commented Feb 24, 2022

@wulfthimm hah, okay, tide is a required check so you can't merge manually 😂 You have to

  1. Put /werft no-preview in your PR description
  2. Reword your latest commit to not have the /werft command
  3. Force push

Then I can approve and Tide can merge it.

@fullmetalrooster fullmetalrooster force-pushed the wulfthimm/max-branch-name-lenght-is-toooooooo-long branch from da707ac to d78dad7 Compare February 24, 2022 14:17
@fullmetalrooster
Copy link
Contributor Author

@mads-hartmann It is ready now.

@csweichel
Copy link
Contributor

@mads-hartmann someone would need to unhold if this should be merged

@roboquat roboquat merged commit 73cbeef into main Feb 25, 2022
@roboquat roboquat deleted the wulfthimm/max-branch-name-lenght-is-toooooooo-long branch February 25, 2022 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[core-dev] registry facade in crash loop due to namespace name being too long
7 participants