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

Fix get-deps tool to handle non LinuxKit containers #4168

Merged
merged 1 commit into from
Aug 28, 2024

Conversation

rucoder
Copy link
Contributor

@rucoder rucoder commented Aug 27, 2024

The tool assumed that all lfedge/... docker images are LinuxKit images and there must be pkg/ directory which it not true for e.g. eve-rust container lfedge/eve-rust:1.80.1 Improve version parsing algorithm

@jsfakian I think you also need this PR

@rucoder
Copy link
Contributor Author

rucoder commented Aug 27, 2024

The tool assumed that all lfedge/... docker images are LinuxKit images and there must be pkg/ directory which it not true for e.g. eve-rust container lfedge/eve-rust:1.80.1 Improve version parsing algorithm

@jsfakian I think you also need this PR

I realized that it is easier to check that the pkg/<image> directory exists...

for _, s := range deps {
// We are just interested on packages from lfegde (those that we
// published)
if reLF.MatchString(s) {
matches := rePkg.FindStringSubmatch(s)
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure I get what this is doing. I think that it is:

  • before: if it matched lfedge/eve-:.* then assume that it is pkg/<everything between eve-and tag :>
  • after: if it matched lfedge/eve-:<sha256> then assume that it is pkg/<everything between eve-and tag :>

Is that it?

If so:

  1. Do you mind adding a README to this? You actually figured out how this works, it is good to capture it. Something that just describes what this does (in a sentence or two) and more importantly, by what logic it filters (the important part).
  2. Is that solid enough? I can see other things following that path that do not come out of here.
  3. Should we add a check for the path? Meaning, instead of (or in addition to), "if it is lfedge/eve-.*:<sha256>", maybe also check if pkg/$1 exists, and, if not, clearly it doesn't belong as part of get-deps, so skip it?

Copy link
Contributor Author

@rucoder rucoder Aug 27, 2024

Choose a reason for hiding this comment

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

3. Should we add a check for the path? Meaning, instead of (or in addition to), "if it is lfedge/eve-.*:<sha256>", maybe also check if pkg/$1 exists, and, if not, clearly it doesn't belong as part of get-deps, so skip it?

yes, this is what I wrote above. Maybe the easiest way.

Do you mind adding a README to this

I would, but not now. I fixed this one because it was a show stopper for my 'eve visibility' task

Copy link
Contributor

Choose a reason for hiding this comment

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

Aw, no big deal. Two paragraphs. You know it never will get done otherwise. Who is going to take time to write it later?

yes, this is what I wrote above. Maybe the easiest way

Go for it.

for _, target := range targets {
foundMap[target] = true
expected := []string{"pkg/alpine", "pkg/xen-tools"}
sort.Strings(expected)
Copy link
Contributor

Choose a reason for hiding this comment

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

It is guaranteed that filterPkg returns a sorted array?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@christoph-zededa no, this is why I sort them at lines 63,66

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, now I see; then it is okay

version := matches[versionIndex]
// lf-edge version can be sha256 or variable substitution for parse-pkg.sh
// in later case it will be empty
reSha256 := regexp.MustCompile("^[[:xdigit:]]{1,40}(-amd64|-arm64)?$")
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess risc V is missing here, isn't it?

@rene
Copy link
Contributor

rene commented Aug 27, 2024

The tool assumed that all lfedge/... docker images are LinuxKit images and there must be pkg/ directory which it not true for e.g. eve-rust container lfedge/eve-rust:1.80.1 Improve version parsing algorithm
@jsfakian I think you also need this PR

I realized that it is easier to check that the pkg/<image> directory exists...

Yeah, it should be easier, FWIW (for other reviewers), the main goal of the tool is to scan Dockerfile files looking for dependencies of all eve-* packages that we built inside eve, so they will be under pkg/. With the introduction of the eve-rust (which AFAIK is now the only one that we build "outside" EVE) the parser wasn't prepared for this new use case and will consider a non-existent pkg/eve-rust, so it must be fixed....

@github-actions github-actions bot requested a review from deitch August 27, 2024 13:29
@rucoder
Copy link
Contributor Author

rucoder commented Aug 27, 2024

The tool assumed that all lfedge/... docker images are LinuxKit images and there must be pkg/ directory which it not true for e.g. eve-rust container lfedge/eve-rust:1.80.1 Improve version parsing algorithm
@jsfakian I think you also need this PR

I realized that it is easier to check that the pkg/<image> directory exists...

Yeah, it should be easier, FWIW (for other reviewers), the main goal of the tool is to scan Dockerfile files looking for dependencies of all eve-* packages that we built inside eve, so they will be under pkg/. With the introduction of the eve-rust (which AFAIK is now the only one that we build "outside" EVE) the parser wasn't prepared for this new use case and will consider a non-existent pkg/eve-rust, so it must be fixed....

there is another broken case pkg/external-boot-image: pkg/kernel whatever external-boot-image is. I do not think we even use it

If the package is built outside EVE source tree the tool still adds it
to dependencies and later Makefile fails to find target.
We have lfedge/eve-rust container that is affected but this bug
We just check that the package really exists in EVE source tree

This commit also fixes the following incorrect dependency

pkg/external-boot-image: pkg/kernel

Also add some tests

Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
@deitch
Copy link
Contributor

deitch commented Aug 27, 2024

which AFAIK is now the only one that we build "outside" EVE

For now 😁

Copy link
Contributor

@deitch deitch left a comment

Choose a reason for hiding this comment

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

Much simpler and cleaner.

Copy link
Contributor

@rene rene left a comment

Choose a reason for hiding this comment

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

LGTM

@rene
Copy link
Contributor

rene commented Aug 27, 2024

The tool assumed that all lfedge/... docker images are LinuxKit images and there must be pkg/ directory which it not true for e.g. eve-rust container lfedge/eve-rust:1.80.1 Improve version parsing algorithm
@jsfakian I think you also need this PR

I realized that it is easier to check that the pkg/<image> directory exists...

Yeah, it should be easier, FWIW (for other reviewers), the main goal of the tool is to scan Dockerfile files looking for dependencies of all eve-* packages that we built inside eve, so they will be under pkg/. With the introduction of the eve-rust (which AFAIK is now the only one that we build "outside" EVE) the parser wasn't prepared for this new use case and will consider a non-existent pkg/eve-rust, so it must be fixed....

there is another broken case pkg/external-boot-image: pkg/kernel whatever external-boot-image is. I do not think we even use it

pkg/external-boot-image (kubevirt related) is still built by our Makefile (and has a directory under pkg/), so is valid to check this dependency... pkg/kernel was the old kernel package, but I see that a kind of workaround was introduced here: 6cff366
maybe we could change get-deps to not consider eve-kernel, I think it makes more sense once the kernel is not built under pkg/ anymore.....

@rucoder
Copy link
Contributor Author

rucoder commented Aug 27, 2024

The tool assumed that all lfedge/... docker images are LinuxKit images and there must be pkg/ directory which it not true for e.g. eve-rust container lfedge/eve-rust:1.80.1 Improve version parsing algorithm
@jsfakian I think you also need this PR

I realized that it is easier to check that the pkg/<image> directory exists...

Yeah, it should be easier, FWIW (for other reviewers), the main goal of the tool is to scan Dockerfile files looking for dependencies of all eve-* packages that we built inside eve, so they will be under pkg/. With the introduction of the eve-rust (which AFAIK is now the only one that we build "outside" EVE) the parser wasn't prepared for this new use case and will consider a non-existent pkg/eve-rust, so it must be fixed....

there is another broken case pkg/external-boot-image: pkg/kernel whatever external-boot-image is. I do not think we even use it

pkg/external-boot-image (kubevirt related) is still built by our Makefile (and has a directory under pkg/), so is valid to check this dependency... pkg/kernel was the old kernel package, but I see that a kind of workaround was introduced here: 6cff366 maybe we could change get-deps to not consider eve-kernel, I think it makes more sense once the kernel is not built under pkg/ anymore.....

my fix fixes this incorrect dependency

@OhmSpectator
Copy link
Member

Merging, although there is one test failing. I don't see how it can be related to the PR.

@OhmSpectator OhmSpectator merged commit 0e95a89 into lf-edge:master Aug 28, 2024
38 of 40 checks passed
@rucoder rucoder added the stable Should be backported to stable release(s) label Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stable Should be backported to stable release(s)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants