From 7cb2390d452f1878504562c0b816040e76414d00 Mon Sep 17 00:00:00 2001 From: James Masson Date: Fri, 7 Jun 2024 10:15:31 +0100 Subject: [PATCH] K8s kubelet reserved-cpus migration --- Release.toml | 1 + sources/Cargo.lock | 7 +++++++ sources/Cargo.toml | 1 + .../k8s-reserved-cpus-v0-1-0/Cargo.toml | 10 ++++++++++ .../k8s-reserved-cpus-v0-1-0/src/main.rs | 18 ++++++++++++++++++ 5 files changed, 37 insertions(+) create mode 100644 sources/api/migration/migrations/v1.21.0/k8s-reserved-cpus-v0-1-0/Cargo.toml create mode 100644 sources/api/migration/migrations/v1.21.0/k8s-reserved-cpus-v0-1-0/src/main.rs diff --git a/Release.toml b/Release.toml index d965f51cdf7..ffbc6cf7609 100644 --- a/Release.toml +++ b/Release.toml @@ -319,4 +319,5 @@ 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_k8s-reserved-cpus-v0-1-0.lz4", ] diff --git a/sources/Cargo.lock b/sources/Cargo.lock index 0840683f25e..0a43370f27b 100644 --- a/sources/Cargo.lock +++ b/sources/Cargo.lock @@ -2391,6 +2391,13 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "k8s-reserved-cpus-v0-1-0" +version = "0.1.0" +dependencies = [ + "migration-helpers", +] + [[package]] name = "language-tags" version = "0.3.2" diff --git a/sources/Cargo.toml b/sources/Cargo.toml index 43575f3fb72..0ca12eed0a9 100644 --- a/sources/Cargo.toml +++ b/sources/Cargo.toml @@ -28,6 +28,7 @@ members = [ "api/migration/migrations/v1.21.0/pod-infra-container-image-affected-services", "api/migration/migrations/v1.21.0/pod-infra-container-image-remove-settings-generator", "api/migration/migrations/v1.21.0/pod-infra-container-image-services", + "api/migration/migrations/v1.21.0/k8s-reserved-cpus-v0-1-0", "bloodhound", diff --git a/sources/api/migration/migrations/v1.21.0/k8s-reserved-cpus-v0-1-0/Cargo.toml b/sources/api/migration/migrations/v1.21.0/k8s-reserved-cpus-v0-1-0/Cargo.toml new file mode 100644 index 00000000000..4ec663aaa3e --- /dev/null +++ b/sources/api/migration/migrations/v1.21.0/k8s-reserved-cpus-v0-1-0/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "k8s-reserved-cpus-v0-1-0" +version = "0.1.0" +authors = ["James Masson "] +license = "Apache-2.0 OR MIT" +edition = "2021" +publish = false + +[dependencies] +migration-helpers = { path = "../../../migration-helpers", version = "0.1.0" } diff --git a/sources/api/migration/migrations/v1.21.0/k8s-reserved-cpus-v0-1-0/src/main.rs b/sources/api/migration/migrations/v1.21.0/k8s-reserved-cpus-v0-1-0/src/main.rs new file mode 100644 index 00000000000..54cba0056d5 --- /dev/null +++ b/sources/api/migration/migrations/v1.21.0/k8s-reserved-cpus-v0-1-0/src/main.rs @@ -0,0 +1,18 @@ +use migration_helpers::common_migrations::AddSettingsMigration; +use migration_helpers::{migrate, Result}; +use std::process; + +/// Add the option to set Kubernetes reserved-cpus +fn run() -> Result<()> { + migrate(AddSettingsMigration(&["settings.kubernetes.reserved-cpus"])) +} + +// 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); + } +}