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

Incorrect Error during Exporter "ERROR: failed to export: get run image top layer SHA: image has no layers" #1456

Open
BarDweller opened this issue Jan 25, 2025 · 0 comments
Labels
status/triage type/bug Something isn't working

Comments

@BarDweller
Copy link
Contributor

Summary

When running exporter during a daemon mode build, if the target run image is not in the daemon, exporter fails with the following error...

ERROR: failed to export: get run image top layer SHA: image has no layers

The error should instead indicate the run image was not found..


Reproduction

Run a daemon build using a platform, and arrange for the target run image to be absent from the daemon before exporter is executed.

Current behavior

Discovered during platform development, while debugging multi-arch issues.

Can occur when the platform has pulled the run image by it's name, but restorer has altered the run reference to be for the architecture specific sha reference. The platform pulled image will have the sha of the combined manifest, not the architecture specific one, leading to exporter being unable to locate the run image in the daemon. Although this particular example is likely unique to Platform versions 0.10 and 0.11 (because at 0.12 onwards restorer gained a -daemon flag and uses daemon image id's rather than architecture specific sha hashes), the problem is not uniquely constrained to this scenario and will occur whenever the run image is missing during export.

The error ERROR: failed to export: get run image top layer SHA: image has no layers is misleading, and a better error should be output.

Expected behavior

Expected an error indicating the targetted run image was not found during export. The error should ideally output the run image reference that had the issue, to enable end users to debug why the error occurred.


Context

lifecycle version

Tested against main at commit 9a7a3b5 , the error comes down to cmd/lifecycle/exporter.go within the initDaemonAppImage method, after calling imgutil's local.NewImage, the result is tested to see if the appImage Identifier can be retrieved. If not, the code should terminate there.

In the case of the missing image, on docker, it would appear appImage.Identifier() returns an empty string, so the code proceeds assuming it has created the new run image, when no image has been created. This eventually leads to the reported error when the code attempts to retrieve the top layer sha from the new image.

Should trap when run image ID is an empty string, and exit with an error saying the run image was absent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/triage type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant