Avoid build error messages on okteto test execution #4736
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed changes
On
okteto test
, when it fails due to some problem with BuildKit (bad Dockerfile for example) we are showing the error coming from the buildkit underlying layers, which usually mention build operations or similar, that doesn't make sense for test execution.For that reason, I'm changing to show a generic error when okteto test execution fails unexpectedly indicating that the test execution of the test container failed, with a hint to review the image and artifacts, and a reminder for using
log-level
flag to get additional output.In the case of getting a
CommandErr
, we just return that error, as that represents an error in the test execution itself.As part of this, I also added some changes in
pkg/build/buildkit/errors.go
to not consider the errorfailed to calculate checksum of ref xxxx: "xxx": not found
as some lack of permissions getting the image. I added an extra check to return the error as it is in that case instead of completely replace it.In the of having
artifacts
defined in the test container, this is the error we return nowIf there is no artifacts defined, this is the error we display
In case of a failure in the test itself, we keep returning the same:
How to validate
Define a test container with an artifact that is not generated by the commands, for example:
It should fail with the generic error I'm adding. Before, it was failing with a misleading error:
The image '' is not accessible or it does not exist
Define a test container with a non-existent image, for example:
It should fail with the generic error I'm adding.
Define a test container with a failed command to make sure we are failing in the same way we used to do:
It should fail with the same error than without my changes.