From 785d5dbc1c18743e94575d055323267c5b530aeb Mon Sep 17 00:00:00 2001 From: Yutong Sun Date: Fri, 8 Nov 2024 00:08:48 +0000 Subject: [PATCH] migration: add settings migration for kernel sysctl hugepages Signed-off-by: Yutong Sun --- Release.toml | 5 ++++- Twoliter.toml | 2 +- sources/Cargo.lock | 7 +++++++ sources/Cargo.toml | 1 + .../kernel-sysctl-hugepages/Cargo.toml | 15 +++++++++++++ .../kernel-sysctl-hugepages/src/main.rs | 21 +++++++++++++++++++ 6 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 sources/settings-migrations/v1.28.0/kernel-sysctl-hugepages/Cargo.toml create mode 100644 sources/settings-migrations/v1.28.0/kernel-sysctl-hugepages/src/main.rs diff --git a/Release.toml b/Release.toml index d806795dba0..f982c7abf83 100644 --- a/Release.toml +++ b/Release.toml @@ -1,4 +1,4 @@ -version = "1.27.0" +version = "1.28.0" [migrations] "(0.3.1, 0.3.2)" = ["migrate_v0.3.2_admin-container-v0-5-0.lz4"] @@ -371,3 +371,6 @@ version = "1.27.0" "(1.26.2, 1.27.0)" = [ "migrate_v1.27.0_aws-config.lz4", ] +"(1.27.0, 1.28.0)" = [ + "migrate_v1.28.0_kernel-sysctl-hugepages.lz4" +] diff --git a/Twoliter.toml b/Twoliter.toml index ab5a0edb1aa..b1ae5938b80 100644 --- a/Twoliter.toml +++ b/Twoliter.toml @@ -1,5 +1,5 @@ schema-version = 1 -release-version = "1.27.0" +release-version = "1.28.0" [vendor.bottlerocket] registry = "public.ecr.aws/bottlerocket" diff --git a/sources/Cargo.lock b/sources/Cargo.lock index 91ad9a13345..6c687c411ab 100644 --- a/sources/Cargo.lock +++ b/sources/Cargo.lock @@ -1563,6 +1563,13 @@ dependencies = [ "migration-helpers", ] +[[package]] +name = "kernel-sysctl-hugepages" +version = "0.1.0" +dependencies = [ + "migration-helpers", +] + [[package]] name = "kubelet-device-plugins-metadata" version = "0.1.0" diff --git a/sources/Cargo.toml b/sources/Cargo.toml index ed914b7cba5..e893f7a2f10 100644 --- a/sources/Cargo.toml +++ b/sources/Cargo.toml @@ -66,6 +66,7 @@ members = [ "settings-migrations/v1.25.0/aws-control-container-v0-7-17", "settings-migrations/v1.25.0/public-control-container-v0-7-17", "settings-migrations/v1.27.0/aws-config", + "settings-migrations/v1.28.0/kernel-sysctl-hugepages", "settings-plugins/aws-dev", "settings-plugins/aws-ecs-1", "settings-plugins/aws-ecs-2", diff --git a/sources/settings-migrations/v1.28.0/kernel-sysctl-hugepages/Cargo.toml b/sources/settings-migrations/v1.28.0/kernel-sysctl-hugepages/Cargo.toml new file mode 100644 index 00000000000..c08dcf08f50 --- /dev/null +++ b/sources/settings-migrations/v1.28.0/kernel-sysctl-hugepages/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "kernel-sysctl-hugepages" +version = "0.1.0" +authors = ["Yutong Sun "] +license = "Apache-2.0 OR MIT" +edition = "2021" +publish = false +# Don't rebuild crate just because of changes to README. +exclude = ["README.md"] + + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +migration-helpers.workspace = true diff --git a/sources/settings-migrations/v1.28.0/kernel-sysctl-hugepages/src/main.rs b/sources/settings-migrations/v1.28.0/kernel-sysctl-hugepages/src/main.rs new file mode 100644 index 00000000000..6422189b786 --- /dev/null +++ b/sources/settings-migrations/v1.28.0/kernel-sysctl-hugepages/src/main.rs @@ -0,0 +1,21 @@ +use migration_helpers::common_migrations::{AddMetadataMigration, SettingMetadata}; +use migration_helpers::{migrate, Result}; +use std::process; + +/// We added new settings metadata, `metadata.settings.kernel.sysctl.vm/nr_hugepages.setting-generator` +fn run() -> Result<()> { + migrate(AddMetadataMigration(&[SettingMetadata { + metadata: &["setting-generator"], + setting: "settings.kernel.sysctl.vm/nr_hugepages", + }])) +} + +// 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); + } +}