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

Force evaluation before test execution #404

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions frontend/azlinux/handle_rpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ func handleRPM(w worker) gwclient.BuildFunc {
return nil, nil, err
}

if err := ref.Evaluate(ctx); err != nil {
adamperlin marked this conversation as resolved.
Show resolved Hide resolved
return ref, nil, err
}

if imgRef, err := runTests(ctx, client, w, spec, sOpt, st, targetKey, pg); err != nil {
// return the container ref in case of error so it can be used to debug
// the installed package state.
Expand Down
4 changes: 4 additions & 0 deletions frontend/jammy/handle_deb.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ func handleDeb(ctx context.Context, client gwclient.Client) (*gwclient.Result, e
return nil, nil, err
}

if err := ref.Evaluate(ctx); err != nil {
return ref, nil, err
}

if ref, err := runTests(ctx, client, spec, sOpt, st, targetKey, opt); err != nil {
cfg, _ := buildImageConfig(ctx, client, spec, platform, targetKey)
return ref, cfg, err
Expand Down
8 changes: 8 additions & 0 deletions frontend/test_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ func RunTests(ctx context.Context, client gwclient.Client, spec *dalec.Spec, ref
return nil
}

if err := ref.Evaluate(ctx); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we're already doing ref.Evaluate after we create package build state for deb/rpm, really the only extra errors this will surface here would be install errors from installing the package in the target container, correct? That should in general be the only extra state that hasn't yet been solved at this point?

Copy link
Member Author

Choose a reason for hiding this comment

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

At this point, the package build state is only evaluated on the packaging build targets, not the container targets.
But other than that, yes you are correct.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah got it, the build state hasn't yet been evaluated if we've reached this code path from a container target. And in the case of packaging build targets, this ref.Evaluate would actually surface errors from installing in the test container, not the target container since there is no target container in that case. Thanks for clarifying

// Force evaluation here so that any errors for the build itself can surface
// more cleanly.
// Otherwise an error for something wrong in the build (e.g. a failed compilation)
// will look like an error in a test (or all tests).
return err
}

ctr, err := ref.ToState()
if err != nil {
return err
Expand Down