From ab28cf2ab3f1cb8ca7b1b818b1a768965527e3b9 Mon Sep 17 00:00:00 2001 From: Yutong Sun Date: Tue, 11 Jun 2024 23:45:29 +0000 Subject: [PATCH] Add missing symlink and metadata migration Signed-off-by: Yutong Sun --- Release.toml | 2 +- packages/.gitignore | 1 + .../nvidia-container-toolkit-config-k8s | 4 +-- .../Cargo.toml | 15 +++++++++++ .../build.rs | 6 +++++ .../src/main.rs | 26 +++++++++++++++++++ .../81-nvidia-k8s-container-toolkit.toml | 1 + .../81-nvidia-k8s-container-toolkit.toml | 1 + .../81-nvidia-k8s-container-toolkit.toml | 1 + 9 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 sources/api/migration/migrations/v1.21.0/container-runtime-nvidia-k8s-metadata/Cargo.toml create mode 100644 sources/api/migration/migrations/v1.21.0/container-runtime-nvidia-k8s-metadata/build.rs create mode 100644 sources/api/migration/migrations/v1.21.0/container-runtime-nvidia-k8s-metadata/src/main.rs create mode 120000 sources/models/src/aws-k8s-1.24-nvidia/defaults.d/81-nvidia-k8s-container-toolkit.toml create mode 120000 sources/models/src/aws-k8s-1.25-nvidia/defaults.d/81-nvidia-k8s-container-toolkit.toml create mode 120000 sources/models/src/aws-k8s-1.26-nvidia/defaults.d/81-nvidia-k8s-container-toolkit.toml diff --git a/Release.toml b/Release.toml index 7e37cdfad45..d807134dc5d 100644 --- a/Release.toml +++ b/Release.toml @@ -319,6 +319,6 @@ version = "1.21.0" "migrate_v1.21.0_pod-infra-container-image-remove-settings-generator.lz4", "migrate_v1.21.0_pod-infra-container-image-affected-services.lz4", "migrate_v1.21.0_pod-infra-container-image-services.lz4", - "migrate_v1.21.0_container-runtime-nvidia-k8s.lz4" + "migrate_v1.21.0_container-runtime-nvidia-k8s.lz4", "migrate_v1.21.0_container-runtime-nvidia-k8s-metadata.lz4", ] diff --git a/packages/.gitignore b/packages/.gitignore index ab0abbf93b7..53575349a41 100644 --- a/packages/.gitignore +++ b/packages/.gitignore @@ -1,3 +1,4 @@ *.patch.bz2 *.src.rpm *.zip +*.rpm diff --git a/packages/nvidia-container-toolkit/nvidia-container-toolkit-config-k8s b/packages/nvidia-container-toolkit/nvidia-container-toolkit-config-k8s index 16c756c32d6..99dbc317688 100644 --- a/packages/nvidia-container-toolkit/nvidia-container-toolkit-config-k8s +++ b/packages/nvidia-container-toolkit/nvidia-container-toolkit-config-k8s @@ -2,8 +2,8 @@ kubernetes = "v1" +++ -accept-nvidia-visible-devices-as-volume-mounts = {{settings.kubernetes.nvidia.container-runtime.visible-devices-as-volume-mounts}} -accept-nvidia-visible-devices-envvar-when-unprivileged = {{settings.kubernetes.nvidia.container-runtime.visible-devices-envvar-when-unprivileged}} +accept-nvidia-visible-devices-as-volume-mounts = {{default true settings.kubernetes.nvidia.container-runtime.visible-devices-as-volume-mounts}} +accept-nvidia-visible-devices-envvar-when-unprivileged = {{default false settings.kubernetes.nvidia.container-runtime.visible-devices-envvar-when-unprivileged}} [nvidia-container-cli] root = "/" diff --git a/sources/api/migration/migrations/v1.21.0/container-runtime-nvidia-k8s-metadata/Cargo.toml b/sources/api/migration/migrations/v1.21.0/container-runtime-nvidia-k8s-metadata/Cargo.toml new file mode 100644 index 00000000000..2e10f8a7d99 --- /dev/null +++ b/sources/api/migration/migrations/v1.21.0/container-runtime-nvidia-k8s-metadata/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "container-runtime-nvidia-k8s-metadata" +version = "0.1.0" +edition = "2021" +authors = ["Yutong Sun "] +license = "Apache-2.0 OR MIT" +publish = false +# Don't rebuild crate just because of changes to README. +exclude = ["README.md"] + +[dependencies] +migration-helpers = { path = "../../../migration-helpers", version = "0.1.0"} + +[build-dependencies] +bottlerocket-variant = { version = "0.1", path = "../../../../../bottlerocket-variant" } diff --git a/sources/api/migration/migrations/v1.21.0/container-runtime-nvidia-k8s-metadata/build.rs b/sources/api/migration/migrations/v1.21.0/container-runtime-nvidia-k8s-metadata/build.rs new file mode 100644 index 00000000000..51d16cf1b4c --- /dev/null +++ b/sources/api/migration/migrations/v1.21.0/container-runtime-nvidia-k8s-metadata/build.rs @@ -0,0 +1,6 @@ +use bottlerocket_variant::Variant; + +fn main() { + let variant = Variant::from_env().unwrap(); + variant.emit_cfgs(); +} diff --git a/sources/api/migration/migrations/v1.21.0/container-runtime-nvidia-k8s-metadata/src/main.rs b/sources/api/migration/migrations/v1.21.0/container-runtime-nvidia-k8s-metadata/src/main.rs new file mode 100644 index 00000000000..9d8e82f46ec --- /dev/null +++ b/sources/api/migration/migrations/v1.21.0/container-runtime-nvidia-k8s-metadata/src/main.rs @@ -0,0 +1,26 @@ +use migration_helpers::common_migrations::{AddMetadataMigration, NoOpMigration, SettingMetadata}; +use migration_helpers::migrate; +use migration_helpers::Result; +use std::process; + +/// We added a new setting for configuring container runtime (containerd) settings only for NVIDIA k8s variants. +fn run() -> Result<()> { + if cfg!(variant_family = "aws-k8s") && cfg!(variant_flavor = "nvidia") { + migrate(AddMetadataMigration(&[SettingMetadata { + metadata: &["affected-services"], + setting: "settings.kubernetes.nvidia.container-runtime", + }])) + } else { + migrate(NoOpMigration) + } +} + +// Returning a Result from main makes it print a Debug representation of the error, but with Snafu +// we have nice Display representations of the error, so we wrap "main" (run) and print any error. +// https://github.com/shepmaster/snafu/issues/110 +fn main() { + if let Err(e) = run() { + eprintln!("{}", e); + process::exit(1); + } +} diff --git a/sources/models/src/aws-k8s-1.24-nvidia/defaults.d/81-nvidia-k8s-container-toolkit.toml b/sources/models/src/aws-k8s-1.24-nvidia/defaults.d/81-nvidia-k8s-container-toolkit.toml new file mode 120000 index 00000000000..0b3f42928f1 --- /dev/null +++ b/sources/models/src/aws-k8s-1.24-nvidia/defaults.d/81-nvidia-k8s-container-toolkit.toml @@ -0,0 +1 @@ +../../../shared-defaults/nvidia-k8s-container-toolkit.toml \ No newline at end of file diff --git a/sources/models/src/aws-k8s-1.25-nvidia/defaults.d/81-nvidia-k8s-container-toolkit.toml b/sources/models/src/aws-k8s-1.25-nvidia/defaults.d/81-nvidia-k8s-container-toolkit.toml new file mode 120000 index 00000000000..0b3f42928f1 --- /dev/null +++ b/sources/models/src/aws-k8s-1.25-nvidia/defaults.d/81-nvidia-k8s-container-toolkit.toml @@ -0,0 +1 @@ +../../../shared-defaults/nvidia-k8s-container-toolkit.toml \ No newline at end of file diff --git a/sources/models/src/aws-k8s-1.26-nvidia/defaults.d/81-nvidia-k8s-container-toolkit.toml b/sources/models/src/aws-k8s-1.26-nvidia/defaults.d/81-nvidia-k8s-container-toolkit.toml new file mode 120000 index 00000000000..0b3f42928f1 --- /dev/null +++ b/sources/models/src/aws-k8s-1.26-nvidia/defaults.d/81-nvidia-k8s-container-toolkit.toml @@ -0,0 +1 @@ +../../../shared-defaults/nvidia-k8s-container-toolkit.toml \ No newline at end of file