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 the first SBOM protoype from the Kubernetes release process #2095

Merged
merged 8 commits into from
Jun 7, 2021

Conversation

puerco
Copy link
Member

@puerco puerco commented May 29, 2021

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR integrates the Bill of Materials code Into the release process. This generates the first SBOM prototypes that describe a Kubernetes release. We are generating one SBOM for the source code and one for the release artifacts. The proposed namespaces for these are the following:

This PR aims to test the integration of the BOM code with the Kubernetes Release process. The resulting SBOM documents will describe the release source and artifacts, but will not include yet all the features of the SPDX libraries. They will do most of the work of creating the BOM however, enabling us to look for bugs and polish the documents to their final state in beta.0.

This PR is broken into several commits, I've attempted to add meaningful descriptions to each one. The most important changes are:

  • Prewarming the license cache during release.PrepareWorkspaceStage() to avoid downloading the license files later
  • The release process staging phase now has a GenerateBillOfMaterials() step that builds the SPDX documents.
  • We now create an SPDX SBOM describing the Kubernetes source during staging
  • Each version in a release now features an SPDX bill of materials listing its binaries and images
  • stage.GenerateBillOfMaterials() now has an integration test

Which issue(s) this PR fixes:

Part of: #1837

Special notes for your reviewer:

The SBOM generation has been tested in several test runs of the release process. I've verified that both stage and release work as expected. For details see:

One of the commits features a temporary function: ListArtifacts(). This function will be replaced with the Supported Platforms framework once we finish it (ref: #1926 )

Does this PR introduce a user-facing change?

* When staging a new kubernetes build, `krel` will now prewarm the license cache to have the classifier data ready when generating the bill of materials.
* The release process staging phase now has a `GenerateBillOfMaterials()` step that builds the SPDX documents.
* We now create an SPDX SBOM describing the Kubernetes source during staging
* Each version in a release now features an SPDX bill of materials listing its binaries and images
* stage.GenerateBillOfMaterials() now has an integration test

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority approved Indicates a PR has been approved by an approver from all required OWNERS files. area/release-eng Issues or PRs related to the Release Engineering subproject size/L Denotes a PR that changes 100-499 lines, ignoring generated files. sig/release Categorizes an issue or PR as relevant to SIG Release. labels May 29, 2021
@puerco puerco changed the title Bom rproc 1 Prewarm license cache during release.PrepareWorkspaceStage() May 29, 2021
@puerco
Copy link
Member Author

puerco commented May 29, 2021

/milestone v1.22

@k8s-ci-robot k8s-ci-robot added this to the v1.22 milestone May 29, 2021
@puerco
Copy link
Member Author

puerco commented May 29, 2021

I gave it a test run with export TOOL_ORG=puerco && export TOOL_REF=bom-rproc-1 (using a slightly modified version as currently there is a problem with the release process) and it works:

[2021-05-29T06:02:24Z] Found release versions: prime: v1.22.0-alpha.3, alpha: v1.22.0-alpha.3 
INFO[2021-05-29T06:02:24Z] Preparing workspace                           step=5/9
INFO[2021-05-29T06:02:24Z] Caching SPDX license set to /tmp.k8s/spdx/downloadCache 
INFO[2021-05-29T06:02:24Z] Downloading main SPDX license data from https://spdx.org/licenses/ 
INFO[2021-05-29T06:02:24Z] Sending GET request to https://spdx.org/licenses/licenses.json 
INFO[2021-05-29T06:02:25Z] Read data for 460 licenses. Downloading.     
INFO[2021-05-29T06:02:25Z] Downloading license data from https://spdx.org/licenses/UCL-1.0.json 
...
INFO[2021-05-29T06:02:31Z] Downloaded 460 licenses                      
INFO[2021-05-29T06:02:31Z] Preparing workspace for staging in /workspace/src/k8s.io/kubernetes 
INFO[2021-05-29T06:02:31Z] Cloning repository to /workspace/src/k8s.io/kubernetes 

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 31, 2021
@puerco
Copy link
Member Author

puerco commented Jun 4, 2021

Since this PR has not merged I will further this branch to generate the first BOM prototypes from the release process.
/hold

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 4, 2021
@puerco puerco changed the title Prewarm license cache during release.PrepareWorkspaceStage() Generate the first SBOM protoype from the Kubernetes release process Jun 4, 2021
@puerco puerco mentioned this pull request Jun 4, 2021
19 tasks
@puerco puerco force-pushed the bom-rproc-1 branch 2 times, most recently from 8e5e122 to 9c32986 Compare June 4, 2021 06:17
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 4, 2021
@puerco puerco force-pushed the bom-rproc-1 branch 6 times, most recently from bb6ad2b to 4fa3f7b Compare June 6, 2021 19:20
@puerco
Copy link
Member Author

puerco commented Jun 6, 2021

/test pull-release-integration-test

This change prewarms the license cache when we prepare the workspace
before staging a new build.

The idea is to perform all the requests to download the data at the
beginning, to have it ready when we generate the Bill of Materials,
failing early if there is a communications issue
Log messages from the SPDX File where overwhelming the
GCB log.

Signed-off-by: Adolfo García Veytia (Puerco) <adolfo.garcia@uservers.net>
Add TestGenerateBillOfMaterials() which uses the mocks
to test the new stage implementation functions.

Signed-off-by: Adolfo García Veytia (Puerco) <adolfo.garcia@uservers.net>
This commit adds the Bill of Materials generation function as
the 10th step of staging in the Kubernetes release process.

This function generates the SPDX documents for each of the
versions cut. Once done, the files are copied to the satging
bucket.

Signed-off-by: Adolfo García Veytia (Puerco) <adolfo.garcia@uservers.net>
Signed-off-by: Adolfo García Veytia (Puerco) <adolfo.garcia@uservers.net>
While we finish the supported platforms code, we list the produced
binaries and images using a temporary function ListArtifacts().

This function will be replaced with the supporte platforms framework
once it's finished (Ref kubernetes#1926)

Signed-off-by: Adolfo García Veytia (Puerco) <adolfo.garcia@uservers.net>
This commit generates the release artifacts SBOM for each of
the kubernetes versions built during stage.

The artifacts SBOM includes the binaries and images. The source
code gets a separate Bill of Materials to make them both more
manageable as they are rather large files.

Signed-off-by: Adolfo García Veytia (Puerco) <adolfo.garcia@uservers.net>
This commits plugs the generation of the kubernetes source
code SBOM into the stage phase of the release process.

The source code SBOM is generated on lye once as all versions
in a release are cut at the same point in the commit history.

After generating the source SBOM, it is customized and tagged
with its own namespace before writing the SPDX file.

Signed-off-by: Adolfo García Veytia (Puerco) <adolfo.garcia@uservers.net>
@puerco puerco changed the title WIP Generate the first SBOM protoype from the Kubernetes release process Generate the first SBOM protoype from the Kubernetes release process Jun 7, 2021
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 7, 2021
@puerco
Copy link
Member Author

puerco commented Jun 7, 2021

The SBOM integration is ready to go! 🎉

There are still details to iron out, but the big chunk is done. We are ready to produce the first set of SBOMs for v1.22.0-alpha.3! 🚀

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 7, 2021
@dims
Copy link
Member

dims commented Jun 7, 2021

@puerco is the list of things in the SBOM, exactly reflect the stuff in the LICENSES/ directory in k/k? (or does it have more stuff?)

@puerco
Copy link
Member Author

puerco commented Jun 7, 2021

All the data in LICENSES should be included plus a lot more. Most should be there now, but I noticed in the logs that some packages could not be downloaded and hence have no license declared. I have to check why.

This PR lays the groundwork to generate the doc automatically. Once this is in, my focus will be on perfecting the output for beta.0 The licensing data of dependencies will be 1:1 to the LICENSES dir but I have yet to write some scripts to verify.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 7, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: puerco, saschagrunert

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@dims
Copy link
Member

dims commented Jun 7, 2021

@puerco "plus a lot more" sounds like could be a concern...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/release-eng Issues or PRs related to the Release Engineering subproject cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/release Categorizes an issue or PR as relevant to SIG Release. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants