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

better variant support in buildsys #2339

Merged
merged 7 commits into from Sep 7, 2022

Conversation

bcressey
Copy link
Contributor

Issue number:

Closes #2211

Description of changes:
This builds on the variant standardization work done in #2134 in a few ways.

Packages can now specify different levels of variant sensitivity; for example, they may only need to be rebuilt when the platform changes, rather than when any component changes.

Packages can make use of a new set of variant-related macros, such as %{_cross_variant_platform}, along with the existing %{_cross_variant} macro.

Packages can also take advantage of automatically generated build conditionals to handle conditional logic in the idiomatic way for RPM spec files. This is similar in spirit to cfg attributes emitted for Rust builds.

Testing done:
Built aws, vmware, and metal variants.

As expected, the kernel package emitted this cargo directive:

cargo:rerun-if-env-changed=BUILDSYS_VARIANT_PLATFORM

Confirmed that the correct files were included in os:

  • static-pods for *-k8s-*
  • cfsignal and shibaken for aws-*
  • pluto for aws-k8s-*
  • ecs-settings-applier for *-ecs-*
  • driverdog for *-nvidia

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

@bcressey bcressey force-pushed the buildsys-bconds branch 2 times, most recently from aaf664f to 6baa2f8 Compare August 14, 2022 17:46
@bcressey
Copy link
Contributor Author

Rebase with no changes to confirm that the clippy lints pass.

Copy link
Contributor

@foersleo foersleo left a comment

Choose a reason for hiding this comment

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

The failing tests are due to a clippy warning for testsys. Should be gone with a rebase including 5865114

I was thinking about possible ways to shave off unnecessary rebuilds by adding even finer grained control, like define sets of platforms (e.g. [metal], [aws, vmware]) and only rebuilding at transitions between these sets. But that is probably adding a lot of unnecessary complexity for rather small gain in build times, while also reducing flexibility. Any thoughts on that?

packages/kernel-5.10/kernel-5.10.spec Show resolved Hide resolved
tools/buildsys/src/manifest.rs Outdated Show resolved Hide resolved
@stmcginnis
Copy link
Contributor

I was thinking about possible ways to shave off unnecessary rebuilds by adding even finer grained control, like define sets of platforms (e.g. [metal], [aws, vmware]) and only rebuilding at transitions between these sets.

I like that idea. I think it might be worth trying to see how much time that could save.

@bcressey
Copy link
Contributor Author

I was thinking about possible ways to shave off unnecessary rebuilds by adding even finer grained control, like define sets of platforms (e.g. [metal], [aws, vmware]) and only rebuilding at transitions between these sets. But that is probably adding a lot of unnecessary complexity for rather small gain in build times, while also reducing flexibility. Any thoughts on that?

This would be pretty trivial to do with serde, I think, just a matter of deserializing to a list of platforms (etc) rather than a string.

One my of back pocket changes is disabling i8042 altogether for the aws platform, since it keeps showing up as a potential 500+ ms stall at boot, and it isn't used for anything. It might be needed for the VMware console though.

Lustre is in the opposite category, a driver that's aws-only that could usefully be disabled for other platforms. Xen might be another candidate.

So I see specializing the kernel config for these use cases as somewhat desirable or inevitable, which means the build time savings would disappear. But again, the added complexity isn't very much.

Copy link
Contributor

@zmrow zmrow left a comment

Choose a reason for hiding this comment

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

This all makes sense and I like the conciseness of it all!

Copy link
Contributor

@foersleo foersleo left a comment

Choose a reason for hiding this comment

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

Thanks for clarifying those questions. Splitting the config more and fitting it closer onto each use case makes sense to me.

&& echo "%bcond_without $(V=${VARIANT_PLATFORM,,}; echo ${V//-/_})_platform" > .bconds \
&& echo "%bcond_without $(V=${VARIANT_RUNTIME,,}; echo ${V//-/_})_runtime" >> .bconds \
&& echo "%bcond_without $(V=${VARIANT_FAMILY,,}; echo ${V//-/_})_family" >> .bconds \
&& echo "%bcond_without $(V=${VARIANT_FLAVOR:-no}; V=${V,,}; echo ${V//-/_})_flavor" >> .bconds \
Copy link
Contributor

Choose a reason for hiding this comment

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

I saw that this will end up as with_nvidia_flavor for NVIDIA variants, and one of its uses is to include driverdog. I wonder if we should be proactive and instead of doing with_nvidia_flavor we could have something more generic for future hardware integrations (AMD, Inferentia, etc).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd prefer to wait until we have some other flavors to figure out what this should look like. GPU support is a likely source of "flavor" but we could have others, like a FIPS flavor, that don't have a hardware component.

Parse the variant tuple into its components with the standard module
for that purpose, and pass each component into the build environment,
to avoid the need for ad-hoc parsing in spec files.

Signed-off-by: Ben Cressey <bcressey@amazon.com>
The previous definition of variant sensitivity treated any change to
the variant as requiring a rebuild.

However, packages might depend on only one component of the variant
tuple. For example, the kernel package might conditionally enable
some modules for the "aws" platform, and a different set for the
"metal" platform.

To prevent unnecessary rebuilds, packages are now allowed to specify
which component, or group of components, they depend upon.

Signed-off-by: Ben Cressey <bcressey@amazon.com>
Kernel support for various hardware depends on the target platform,
and not other attributes of the variant like the orchestrator agent.

Signed-off-by: Ben Cressey <bcressey@amazon.com>
This allows package specs to reference particular components of the
variant, without duplicating the parsing logic.

Signed-off-by: Ben Cressey <bcressey@amazon.com>
Leverage the newly-added variant platform macro to always include
platform-specific kernel configuration files, and ensure these files
exist even if empty.

Signed-off-by: Ben Cressey <bcressey@amazon.com>
This allows RPM spec files to conditionalize parts of the build in an
idiomatic way, using `with` tests rather than string comparisons.

Signed-off-by: Ben Cressey <bcressey@amazon.com>
Leverage the new build conditionals to clean up the various string
comparisons and to make it easier to add new conditional sections.

Signed-off-by: Ben Cressey <bcressey@amazon.com>
@bcressey
Copy link
Contributor Author

bcressey commented Sep 7, 2022

above force push takes away the redundant "take"

@bcressey bcressey merged commit f63fe0c into bottlerocket-os:develop Sep 7, 2022
@bcressey bcressey deleted the buildsys-bconds branch September 7, 2022 21:33
@@ -9,6 +9,7 @@ publish = false
exclude = ["README.md"]

[dependencies]
bottlerocket-variant = { version = "0.1", path = "../../sources/bottlerocket-variant" }
Copy link
Member

Choose a reason for hiding this comment

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

yay. but also weird. do we have tools crates depending on sources crates and sources crates depending on tools crates? should we consider having a common directory someday?

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.

Split metal and non-metal kernel config
6 participants