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

Disable running prebuilds without a project #15026

Merged
merged 3 commits into from
Nov 30, 2022
Merged

Disable running prebuilds without a project #15026

merged 3 commits into from
Nov 30, 2022

Conversation

jankeromnes
Copy link
Contributor

@jankeromnes jankeromnes commented Nov 29, 2022

Description

Throw an error when attempting to start a prebuild on a repository without a corresponding project.

Also (reviving #15024) disable the deprecated #prebuild/ context URL prefix, because it doesn't know about projects (and thus ignores any project details, settings, or safeguards).

The supported ways to start a prebuild are:

  • Creating a Project
  • Pushing commits to a Project branch
  • Clicking on a Run Prebuild button in the UI

Related Issue(s)

Fixes #9898 and fixes #4353

How to test

  1. Should build
  2. Using the deprecated #prebuild/ URL prefix should no longer work

Release Notes

Disable running prebuilds without a project + disable the deprecated '#prebuild/' URL prefix

Documentation

Werft options:

  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-jx-remove-prefix.1 because the annotations in the pull request description changed
(with .werft/ from main)

@jankeromnes
Copy link
Contributor Author

jankeromnes commented Nov 29, 2022

/werft run with-clean-slate-deployment cert-issuer=letsencrypt

👍 started the job as gitpod-build-jx-remove-prefix.2
(with .werft/ from main)

@jankeromnes jankeromnes force-pushed the jx/remove-prefix branch 2 times, most recently from 5e54ed3 to 0e4ccf1 Compare November 29, 2022 13:28
@jankeromnes
Copy link
Contributor Author

jankeromnes commented Nov 29, 2022

Okay, this is what using the #prebuild/ URL prefix looks like now (with this PR):

Screenshot 2022-11-29 at 14 48 13

Maybe it could be nicer to actually redirect to some docs page? I wonder if this prefix is still being used. Maybe I should get some data on this. 🔍

EDIT: When looking at how many workspaces are being started with the prebuild/ prefix in their context URL, we see that it's still being used a few times every day:

SELECT substr(creationTime, 1, 10) day, count(id) FROM d_b_workspace where contextUrl like 'prebuild/%' group by day order by day desc;

Screenshot 2022-11-29 at 15 50 32

New question: Why?

@jankeromnes jankeromnes changed the title Remove deprecated '#prebuild/' context URL prefix Disable running prebuilds without a project Nov 29, 2022
@jankeromnes jankeromnes force-pushed the jx/remove-prefix branch 2 times, most recently from b1260d4 to 154891d Compare November 29, 2022 15:25
@jankeromnes
Copy link
Contributor Author

Alright, I think that throwing this more helpful error is a better approach:

Screenshot 2022-11-29 at 16 36 58

Try for yourself: https://jx-remove-prefix.preview.gitpod-dev.com/#prebuild/https://github.com/gitpod-io/gitpod

@jankeromnes jankeromnes marked this pull request as ready for review November 29, 2022 15:38
@jankeromnes jankeromnes requested a review from a team November 29, 2022 15:38
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Nov 29, 2022
Copy link
Member

@easyCZ easyCZ left a comment

Choose a reason for hiding this comment

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

LGTM

/hold for error type discussion

@@ -128,6 +128,11 @@ export class PrebuildManager {
if (user.blocked) {
throw new Error(`Blocked users cannot start prebuilds (${user.name})`);
}
if (!project) {
throw new Error(
Copy link
Member

Choose a reason for hiding this comment

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

Can we throw a User Error (Invalid Argument) here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea! I think this can be done. Let me try.

actual: context,
};
return result;
throw new Error(
Copy link
Member

Choose a reason for hiding this comment

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

Simlarly here, is it possible to throw an InvalidArgument error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case, it's more a case of a no-longer-valid route (gitpod.io/#prebuild/ URL prefix is deprecated), so it's not really an invalid argument. 🤔 Also, I'm not exactly sure a specific error would bubble correctly all the way to the user.

Let's see, I'll give this a quick try, but leave as is if it turns out too complicated for now.

Copy link
Member

Choose a reason for hiding this comment

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

Given this is the API, and you supplied something which is not valid anymore, I think it would be an Invalid Argument. You could also go with Not Found, but I think that doens't communicate the fact that the client to this API specified something which is no longer valid.

Copy link
Contributor Author

@jankeromnes jankeromnes Nov 30, 2022

Choose a reason for hiding this comment

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

Interesting. I guess this could also be a 400 Bad Request, or a 410 Gone?

@shaal
Copy link
Contributor

shaal commented Nov 29, 2022

my 2 cents -
While I do like the instructions - "Please add your project as a repository in a Gitpod team", I think it's important to add a link to the appropriate documentations, or at least a link to "projects" page of the user.

@jankeromnes
Copy link
Contributor Author

jankeromnes commented Nov 30, 2022

Thanks for the feedback @easyCZ and @shaal! 🚀 Your ideas make sense to me. I'll give them a try, but given how little visibility this code path has nowadays, if implementing them here turns out too complicated, I think I might just ship this PR as is and leave any improvements as potential follow-up items for the future. 💭

@easyCZ
Copy link
Member

easyCZ commented Nov 30, 2022

Thanks for the feedback @easyCZ and @shaal! 🚀 Your ideas make sense to me. I'll give them a try, but given how little visibility this code path has nowadays, if implementing them here turns out too complicated, I think I might just ship this PR as is and leave any improvements as potential follow-up items for the future. 💭

I think the particular code doesn't matter as much, as long as it does not show up as a 5xx error which would eat into our SLO but wasn't actually something we'd have control over.

@jankeromnes
Copy link
Contributor Author

jankeromnes commented Nov 30, 2022

[Ensure VM Readiness|PHASE] Ensuring VM is ready for deployment
[Waiting for VM readiness] Wait for VM readiness
[Waiting for VM readiness] Timeout while waiting for VM to get ready. Timeout: 600. Stderr: error: timed out waiting for the condition on pods/virt-launcher-jx-remove-prefix-gfdct
. Stdout: 
Error Error: VM didn't reach 'Ready' status before the timeout.

/werft run

👍 started the job as gitpod-build-jx-remove-prefix.9
(with .werft/ from main)

@jankeromnes
Copy link
Contributor Author

jankeromnes commented Nov 30, 2022

🙄

/werft run with-clean-slate-deployment

👍 started the job as gitpod-build-jx-remove-prefix.10
(with .werft/ from main)

@jankeromnes
Copy link
Contributor Author

jankeromnes commented Nov 30, 2022

Maybe 4th time's the charm!

/werft run

👍 started the job as gitpod-build-jx-remove-prefix.11
(with .werft/ from main)

@jankeromnes
Copy link
Contributor Author

jankeromnes commented Nov 30, 2022

/werft run cert-issuer=letsencrypt

👍 started the job as gitpod-build-jx-remove-prefix.12
(with .werft/ from main)

@jankeromnes
Copy link
Contributor Author

jankeromnes commented Nov 30, 2022

/werft run cert-issuer=letsencrypt recreate-preview

👍 started the job as gitpod-build-jx-remove-prefix.13
(with .werft/ from main)

@jankeromnes
Copy link
Contributor Author

jankeromnes commented Nov 30, 2022

New UX: https://jx-remove-prefix.preview.gitpod-dev.com/#prebuild/https://github.com/gitpod-io/gitpod

Screenshot 2022-11-30 at 14 07 08

Should be easy to introduce a new custom error type and make the UI display a link. 🙂

@jankeromnes
Copy link
Contributor Author

jankeromnes commented Nov 30, 2022

Latest UX:

Screenshot 2022-11-30 at 15 27 13

I'm guessing this is now good to go! 🚀

/unhold

@roboquat roboquat merged commit ff78e51 into main Nov 30, 2022
@roboquat roboquat deleted the jx/remove-prefix branch November 30, 2022 14:29
@gtsiolis
Copy link
Contributor

gtsiolis commented Nov 30, 2022

Thanks for shipping this, @jankeromnes!

Shall we open any follow up issues from the outstanding tasks in the epic (#9898) to consider this DONE? Cc @jldec

  • Change documentation to explain that prebuilds require a project
  • Post announcement about new prebuild requirement in changelog

@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Dec 1, 2022
@jankeromnes
Copy link
Contributor Author

jankeromnes commented Dec 5, 2022

Follow-up issue: Now that the #prebuild/ URL prefix is no more, users no longer have a reliable way to re-trigger a Prebuild (other than pushing a new commit to a branch), because the 'Run Prebuild' UI button only works for "failed" or "cancelled" prebuilds.

To fix this, we plan to make the 'Run Prebuild' button do what it says 100% of the time: #15144

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note size/M team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Epic: Require a Gitpod project for prebuilds Remove deprecated '#prebuild/' context URL prefix
5 participants