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

Generate SBOM using buildkit's builtin mechanism #83

Merged
merged 3 commits into from
Mar 4, 2024

Conversation

rucoder
Copy link
Collaborator

@rucoder rucoder commented Feb 27, 2024

This PR should address #50

Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
@rucoder rucoder changed the base branch from main to eve-kernel-amd64-v6.1.38-generic February 27, 2024 23:56
@eriknordmark
Copy link

DCO signoff is missing.

@rucoder
Copy link
Collaborator Author

rucoder commented Feb 28, 2024

DCO signoff is missing.

@eriknordmark it is not missing for this PR. There are 2 old commits with wrong sign-off string and I'm not sure what to do about it.

Summary

Commit sha: 0c3194d, Author: Mikhail Malyshev, Committer: Mikhail Malyshev; Expected "Mikhail Malyshev mikem@zededa.com", but got "Nikolay Martyanov nikolay@zededa.com".
Commit sha: 0dc9b45, Author: Roman Shaposhnik, Committer: Mikhail Malyshev; The sign-off is missing.

@eriknordmark
Copy link

@eriknordmark it is not missing for this PR. There are 2 old commits with wrong sign-off string and I'm not sure what to do about it.

That's odd. So the DCO checker is broken?
We can ignore it for now, but I wonder if we'll see the same issue for the same old commits for the next PR.

Copy link

@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.

LGTM, except that linuxkit cache push is not yet implemented. Working on it. Real Soon Now ™️

@rucoder
Copy link
Collaborator Author

rucoder commented Feb 28, 2024

tried linuxkit cache push from commit 54d9db8650400a9f6af72b176b64c6dcc30cba07. It works but one last tiny fix is required. Right now it creates 2 tags assuming that every image is multi-platform

- --sbom=true is not compatible with --load because docker doesn't
  support full OCI spec. Instead we export TAR file in OCI format and
  later load it linuxkit cache

- since the image is now hosted by linuxkit cache we should use 'cache
  push' command to push it to dockerhub registry

Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
@rucoder rucoder force-pushed the rucoder/new-sbom branch from 16ec9f3 to 6353f50 Compare March 1, 2024 19:54
@rucoder rucoder changed the title [WIP] Generate SBOM using buildkit's builtin mechanism Generate SBOM using buildkit's builtin mechanism Mar 1, 2024
Copy link

@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.

LGTM.

Did you build it and do you see the correct sbom info? You should be able to look into the cache directly and see it.

@rucoder
Copy link
Collaborator Author

rucoder commented Mar 4, 2024

@yash-zededa it seems we need to upgrade buildkit on github runner. https://github.com/lf-edge/eve-kernel/actions/runs/8128820721/job/22215156330?pr=83

docker buildx build \
--build-arg="SOURCE_DATE_EPOCH=1709322857" \
--build-arg="KBUILD_BUILD_TIMESTAMP=Fri Mar 1 19:54:17 2024 " \
--build-arg="LOCALVERSION=6c57bd876fea" \
--platform linux/amd64 -t lfedge/eve-kernel:merge-6c57bd876fea-gcc \
--sbom=true --output=type=oci,dest=/tmp/tmp.Fa2e4DNCy2-kernel.tar -f Dockerfile.gcc .
ERROR: attestations are not supported by the current buildkitd
make: *** [Makefile.eve:59: kernel-build-gcc] Error 1

@rucoder rucoder requested a review from deitch March 4, 2024 13:29
@rucoder
Copy link
Collaborator Author

rucoder commented Mar 4, 2024

@yash-zededa it seems we need to upgrade buildkit on github runner. https://github.com/lf-edge/eve-kernel/actions/runs/8128820721/job/22215156330?pr=83

docker buildx build \
--build-arg="SOURCE_DATE_EPOCH=1709322857" \
--build-arg="KBUILD_BUILD_TIMESTAMP=Fri Mar 1 19:54:17 2024 " \
--build-arg="LOCALVERSION=6c57bd876fea" \
--platform linux/amd64 -t lfedge/eve-kernel:merge-6c57bd876fea-gcc \
--sbom=true --output=type=oci,dest=/tmp/tmp.Fa2e4DNCy2-kernel.tar -f Dockerfile.gcc .
ERROR: attestations are not supported by the current buildkitd
make: *** [Makefile.eve:59: kernel-build-gcc] Error 1

nvm, we are running the latest buildkit anyway.

@rucoder rucoder closed this Mar 4, 2024
@rucoder rucoder reopened this Mar 4, 2024
Makefile.eve Outdated
@@ -47,16 +47,21 @@ help: Makefile
@echo " clean: remove generated files"
@echo

.PHONY: ensure-builder
ensure-builder:
docker builder inspect eve-kernel-builder || docker builder create --name eve-kernel-builder --driver docker-container --bootstrap
Copy link

Choose a reason for hiding this comment

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

I recommend saving the builder to a Makefile var and using that here and in the build target

Copy link

Choose a reason for hiding this comment

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

I recommend redirecting the output of inspect to /dev/null, or it gets messy. You don't care about the output, only if it returns 0 or 1.

Copy link

Choose a reason for hiding this comment

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

Maybe an @ at the beginning of the line?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I recommend saving the builder to a Makefile var and using that here and in the build target

this was just a POC :). Will fix

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I recommend redirecting the output of inspect to /dev/null, or it gets messy. You don't care about the output, only if it returns 0 or 1.

it may be useful to troubleshoot issues with CI/CD in future

Makefile.eve Outdated
@echo "Building kernel version $(BRANCH):$(VERSION)-$* with compiler $*"
docker buildx build \
--builder=eve-kernel-builder \
Copy link

Choose a reason for hiding this comment

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

As above, use a var

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@deitch should we fix a build-kit version to something like 0.12.5 ? I could name --builder eve-kernel-builder-$(BK_VERSION)

Copy link

Choose a reason for hiding this comment

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

Yeah, that is a good idea.

Our build may depend on buildx features e.g. --sbom so we need to make
sure we have a correct builder version. This is not a big problem for
local build but a big one for GH runners.

Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
@rucoder rucoder force-pushed the rucoder/new-sbom branch from 94aa2db to 732e980 Compare March 4, 2024 15:01
@rucoder rucoder requested a review from deitch March 4, 2024 15:01
@rucoder
Copy link
Collaborator Author

rucoder commented Mar 4, 2024

@deitch

  1. Please approve to rerun actions
  2. ocker buildx create vs docker builder create. and possible problems here?

@rucoder
Copy link
Collaborator Author

rucoder commented Mar 4, 2024

@deitch @rene @eriknordmark it seems all issues are now solved, we can merge this PR if there are no objections

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: eve-kernel-* PR has to be merged to other branches pr-merged PR was merged to integration branches
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants