-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[Gitpod CLI] gp rebuild
#15638
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
[Gitpod CLI] gp rebuild
#15638
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
843e63b
to
7009402
Compare
This comment was marked as resolved.
This comment was marked as resolved.
d2127d0
to
8b9db0c
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
96499a9
to
755b956
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
227f8b6
to
70ed53b
Compare
components/gitpod-cli/cmd/rebuild.go
Outdated
event.Set("ErrorCode", utils.RebuildErrorCode_DockerfileNotFound).Send(ctx) | ||
return | ||
} | ||
dockerfile, err := os.ReadFile(dockerfilePath) |
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.
err is swallowed, we should give a root cause to the user
components/gitpod-cli/cmd/rebuild.go
Outdated
return | ||
} | ||
|
||
tmpDir, err := os.MkdirTemp("", "gp-rebuild-*") |
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.
err is swallowed, we should give a root cause to the user
components/gitpod-cli/cmd/rebuild.go
Outdated
} | ||
dockerfile, err := os.ReadFile(dockerfilePath) | ||
if err != nil { | ||
log.Fatal("Could not read the Dockerfile") |
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.
@andreafalzetti I don't think the flow here can work. Maybe I'm missing something. Fatal calls os.Exit and it interrupts the program immediately, defer are not called and events are not sent.
I'm asking can we restructure top level routine to something like (pseudo code):
ctx := context.Background()
event := utils.TrackEvent(ctx, ...)
err := doRebuild(ctx, event)
if err != nil && event.ErrorCode == "" {
err.ErrorCode = "system"
}
event.Send()
if err != nil {
utils.LogError(..) // log to a user and GCP
os.Exit(1)
}
It looks also we swallow errors here and there, we should always propagate given errors to users.
WorkspaceId string `json:"workspaceId,omitempty"` | ||
InstanceId string `json:"instanceId,omitempty"` | ||
Timestamp int64 `json:"timestamp,omitempty"` | ||
DockerBuildDurationSeconds float64 `json:"dockerBuildDurationSeconds,omitempty"` |
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.
Let’s call it imageBuildDurationSeconds. We are likely go away from docker next week to build the image.
3ebedc9
to
c61d095
Compare
Is there a reason why don’t we measure everything in milliseconds and drop suffix for unit, ie just duration and imageBuildDuration. We do it the same for other events? |
The thought process is that image build will most likely take seconds so it would be more convinent to have it already in seconds. About the suffix, I think it's a nice to have, in general, because it easily indicates the unit from the Segmenet/Mixpanel without having to access the code or remember what unit it was. Happy to make it all ms and drop the suffix, no hard opinions |
Co-authored-by: Victor Nogueira <[email protected]>
6a27862
to
8f6e79e
Compare
I've updated the PR with the suggestions from @akosyakov I've tested almost all scenarios, but feel free to test again @felladrin 🙏 |
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.
Code looks good, I have not tried, rely on Andrea and Victor for it
/hold
pease unhold when comfortable
I'm running a quick test on it now. |
@andreafalzetti follow up are to update docs and then contribute how to troubleshoot link to the image build screen? Maybe makes sense to talk to @gtsiolis where to add it, we will speak about it again next design meeting |
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.
Tested! ✅
/unhold |
Exciting changes! ➰ @akosyakov I've added your comment above in #15638 (comment) in the next 🍳 IDE / Design Check-in on next Wed (Jan 18), see relevant discussion point (internal). |
return err | ||
} | ||
|
||
err = os.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(baseimage), 0644) |
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.
@andreafalzetti @felladrin is not it bogus? 🤔
We should build in the context of /workspace because Dockerfile can make usage of COPY statements?
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 think we can use the current working direction to run docker command but then pass -f
which pints to the temp dockerfile?
fmt.Println("") | ||
fmt.Println("Once you configure your Dockerfile, re-run this command to validate your changes") | ||
event.Set("ErrorCode", utils.RebuildErrorCode_DockerfileEmpty) | ||
return err |
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.
@andreafalzetti @felladrin for me this branch is hanging 🤔
I think the problem is that it returns nil here. It should return some real error. We need to double check all places, where we return without having err object in advance.
Update hanging actually because of my branch, but I think we should return an error here to exit with 1 properly or another value like ok if we don't want to print an error
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.e. something like:
ok, err = runRebuild(ctx, supervisorClient, event)
if event.Data.ErrorCode == "" {
if err != nil {
event.Set("ErrorCode", utils.SystemErrorCode)
} else if !ok {
event.Set("ErrorCode", utils.UserErrorCode)
}
}
event.Send(ctx)
if err != nil {
utils.LogError(ctx, err, "Failed to rebuild", supervisorClient)
}
var exitCode int
if err != nil || !ok {
exitCode = 1
}
os.Exit(exitCode)
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.
oops, I wonder how I missed this :(
will send a follow-up PR!
Update: ok, it's not hanging then.. I will look into this anyway
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.
there is also the default branch of the switch having the same issue, I will check them all
@akosyakov I will double check that branch. About Dockerfile location it's a good pont, maybe the tmp file should be located in the root of the project 🤔 |
@andreafalzetti I think it does not matter, you can do |
@akosyakov there are 2 other things I've noticed now:
|
I've opened a follow-up PR: #15740 Let's discuss improvements over there 🙏 |
Description
We're introducing a new command to gp cli, to facilitate users in testing the the build and run of custom Docker workspace images.
Note: if the user closes the terminal via the IDE once they are inside the debug container, the event won't be sent.
Related Issue(s)
Relates to #7671
How to test
gp rebuild
and observe error messageimage: xxx
orimage.file
gp_command
is being sent with the following fields:gp_command
is being sent with the following fields:Release Notes
Documentation
Werft options:
If enabled this will build
install/preview
Valid options are
all
,workspace
,webapp
,ide
,jetbrains
,vscode
,ssh