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

Also read distro information from /etc/os-release when checking target compat #1352

Merged
merged 3 commits into from
May 10, 2024

Conversation

natalieparellano
Copy link
Member

@natalieparellano natalieparellano commented May 10, 2024

Summary

This will fix an issue reported by our friends from Paketo. Without this fallback, when combined with the stricter validation in #1348, we could fail builds that we actually want to proceed with.

#1347 reads the file when providing target env vars to buildpacks during detect, but we also need to consider this info when deciding whether or not to run detect for the buildpack.

Release notes

The detector, when determining if a base image satisfies target constraints declared by a buildpack, also uses information from /etc/os-release when distro information is not present in the run image labels


Related

Resolves #___


Context

I moved some functions around in files, so ignore the first commit when parsing the diff (it just moves stuff doesn't change any logic)

Signed-off-by: Natalie Arellano <narellano@vmware.com>
…t compat

#1347 reads the file when providing target env vars
to buildpacks during detect, but we also need to consider this info when deciding whether or not to run
detect for the buildpack

Signed-off-by: Natalie Arellano <narellano@vmware.com>
@natalieparellano natalieparellano requested a review from a team as a code owner May 10, 2024 14:46
phase/analyzer.go Outdated Show resolved Hide resolved
@natalieparellano
Copy link
Member Author

@edmorley @pbusko FYI

Comment on lines 46 to 47
if base.OS == "" || base.Distro == nil {
logger.Info("target distro name/version labels not found, reading /etc/os-release file")
Copy link
Contributor

@edmorley edmorley May 10, 2024

Choose a reason for hiding this comment

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

In what cases could OS be the empty string? If the author of the run image created it in such a way that the image didn't have properly specified metadata? The OCI spec says OS is required:
https://github.com/opencontainers/image-spec/blob/main/config.md#properties

It's just at the moment, the log message (albeit whose wording exists prior to this PR) isn't consistent with the conditional. ie: The message says "target distro name/version labels", but the conditional suggests it should say "OS metadata, or target distro name/version labels" etc. (But if OS should always be present, perhaps the OS check can be moved to an earlier assertion that errors instead? then the log message wouldn't need updating)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. I added an error in 609e287

And remove checks for missing OS later in the build, as it should always be there

Signed-off-by: Natalie Arellano <narellano@vmware.com>
@natalieparellano natalieparellano merged commit 83efa75 into main May 10, 2024
8 checks passed
@natalieparellano natalieparellano deleted the fix/get-target-data branch May 10, 2024 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants