Skip to content

Provide a nicer image build failed message #20281

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 5 commits into from
Oct 15, 2024

Conversation

filiptronicek
Copy link
Member

@filiptronicek filiptronicek commented Oct 9, 2024

Description

Make the message you see when an image build fails nicer for humans, including the recommendation for gp validate.

Related Issue(s)

Fixes ENT-724

How to test

  1. Open https://ft-nicer-ie500177c4c.preview.gitpod-dev.com/new#https://github.com/kylos101/gitpod-custom-image/tree/kylos101/build-fail

@kylos101
Copy link
Contributor

kylos101 commented Oct 9, 2024

Hey @filiptronicek , to test you could try using an image build that will fail, like this one: https://github.com/kylos101/gitpod-custom-image/tree/kylos101/build-fail

It fails like so in catfood:
image

@filiptronicek
Copy link
Member Author

@kylos101 thanks for sharing, I have been able to get this screen as well. What I was originally curious about is this image build screen without any logs, where the improved error message would be a very nice addition:
image

For the purposes of testing this PR, your suggestion will be enough, though. Thanks!

@kylos101
Copy link
Contributor

kylos101 commented Oct 9, 2024

Oh, I see - have you tried deleting the image build pod, before logs start to stream? We might be able to enable debug with image-builder-mk3 too. I think that introduces a delay in the image build process, which might give us time to delete the imagebuild pod itself.

@filiptronicek
Copy link
Member Author

Trying with Kyle's example I actually still get Error: headless task failed: exit status 1. I must be changing this in an incorrect place?

@mustard-mh
Copy link
Contributor

mustard-mh commented Oct 9, 2024

@filiptronicek maybe you're looking for this one

msg := []byte("headless task failed: " + string(success))
err := ioutil.WriteFile("/dev/termination-log", msg, 0o644)
?

content inside /dev/termination-log will be consider as failed reason / status of a pod

update: but it's not always work well, like this one, it will show another message relates to pod sometimes if I remember it correctly

container workspace completed; containers of a workspace pod are not supposed to do that

@filiptronicek
Copy link
Member Author

filiptronicek commented Oct 9, 2024

Thanks so much for sharing that, @mustard-mh, that's exactly what I was looking for (I originally thought we display the error we catch from the workspace starter).

update: but it's not always work well, like this one, it will show another message relates to pod sometimes if I remember it correctly

Oh, that's a bummer. Do we have an issue for that? Feels like we should to make our error messages reliable

@mustard-mh
Copy link
Contributor

Oh, that's a bummer. Do we have an issue for that? Feels like we should to make our error messages reliable

@filiptronicek Searched, seems we don't have such issue

@mustard-mh
Copy link
Contributor

@filiptronicek ws-manager will read content of /dev/termination-log here

workspace.Status.SetCondition(workspacev1.NewWorkspaceConditionHeadlessTaskFailed(cs.State.Terminated.Message))

In case you need to investigate further

@filiptronicek
Copy link
Member Author

filiptronicek commented Oct 9, 2024

@mustard-mh could you help me understand why we fail the image build as part of the supervisor's stopWhenTasksAreDone? I never thought of that phase as a task because it can't run in parallel with the other ones. Are we adding it somewhere artificially to the list?

If so, we could make this work by communicating through the success channel not just the success state, but also some task identifier. If that matched the image build, we could trigger a special message.

Edit: I think I found it:

{Name: "GITPOD_TASKS", Value: `[{"name": "build", "init": "sudo -E /app/bob build"}]`},

@roboquat roboquat added size/S and removed size/XS labels Oct 10, 2024
@filiptronicek
Copy link
Member Author

🎉

image

@filiptronicek filiptronicek marked this pull request as ready for review October 10, 2024 08:20
@lucasvaltl
Copy link
Contributor

🎉

image

Regarding the actual error message we show. Is my assumption correct that in effectively every case this is an error caused by the user? I.e. something is wrong with the image being built, e.g. a mistake in the docker file? If this is the case, let's make this clear in the error message we show. E.g. (feel free to improve with AI) "The image failed to build. Most likely, this is due to a misconfiguration of the image that causes an error due to the build process. To debug this, it is advised to use gp validate (link to docs)."

@filiptronicek
Copy link
Member Author

@lucasvaltl: Regarding the actual error message we show. Is my assumption correct that in effectively every case this is an error caused by the user?

Yes, when a headless task fails, we categorize it as a user error.

I'm going to try with another message, adapted from your suggestion. Trying to keep it short to fit in all places we show these messages (wish we had a link shortener for the long gp validate docs link 🙈)

@filiptronicek
Copy link
Member Author

filiptronicek commented Oct 10, 2024

Argh, it doesn't really fit

image

Maybe we can do this without the docs link?

Edit: I ± made it work with allowing up to two lines before truncating:

image

Copy link
Contributor

@mustard-mh mustard-mh left a comment

Choose a reason for hiding this comment

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

LGTM

Image Build
image

nit: see screenshot, the links we provide on 'Learn More' and logs are different.

@@ -468,6 +468,11 @@ func (c WorkspaceConfig) isDebugWorkspace() bool {
return c.DebugWorkspaceType != api.DebugWorkspaceType_noDebug
}

// isImageBuild returns true if the workspace is an image build.
func (c WorkspaceConfig) isImageBuild() bool {
return os.Getenv("BOB_DOCKERFILE_PATH") != ""
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Other config will read env when init, we should do it the same for isImageBuild to align with others

image

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for pointing this out, fixed in e1b1d79 (#20281).

@roboquat roboquat added size/M and removed size/S labels Oct 15, 2024
@roboquat roboquat merged commit b1b2214 into main Oct 15, 2024
18 checks passed
@roboquat roboquat deleted the ft/nicer-image-build-failed-msg branch October 15, 2024 09:53
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.

6 participants