From 719dbc846981b661301bcbe5cc2170776a129761 Mon Sep 17 00:00:00 2001 From: Sparks Song Date: Thu, 19 Sep 2024 23:08:55 +0000 Subject: [PATCH] migrations: Add migrations for configuration-files.kubelet-exec-start-conf --- sources/Cargo.lock | 7 ++++++ sources/Cargo.toml | 1 + .../kubernetes-service-config/Cargo.toml | 15 +++++++++++ .../kubernetes-service-config/src/main.rs | 25 +++++++++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 sources/settings-migrations/v1.23.0/kubernetes-service-config/Cargo.toml create mode 100644 sources/settings-migrations/v1.23.0/kubernetes-service-config/src/main.rs diff --git a/sources/Cargo.lock b/sources/Cargo.lock index 7b3d46e3a41..4ed8951acd1 100644 --- a/sources/Cargo.lock +++ b/sources/Cargo.lock @@ -1289,6 +1289,13 @@ dependencies = [ "migration-helpers", ] +[[package]] +name = "kubernetes-service-config" +version = "0.1.0" +dependencies = [ + "migration-helpers", +] + [[package]] name = "lazy_static" version = "1.4.0" diff --git a/sources/Cargo.toml b/sources/Cargo.toml index 546802fbb6a..a6cc593e705 100644 --- a/sources/Cargo.toml +++ b/sources/Cargo.toml @@ -55,6 +55,7 @@ members = [ "settings-migrations/v1.23.0/nvidia-container-runtime-settings", "settings-migrations/v1.23.0/kubelet-device-plugins-metadata", "settings-migrations/v1.23.0/kubelet-device-plugins-settings", + "settings-migrations/v1.23.0/kubernetes-service-config", "settings-plugins/aws-dev", "settings-plugins/aws-ecs-1", diff --git a/sources/settings-migrations/v1.23.0/kubernetes-service-config/Cargo.toml b/sources/settings-migrations/v1.23.0/kubernetes-service-config/Cargo.toml new file mode 100644 index 00000000000..3bf26771847 --- /dev/null +++ b/sources/settings-migrations/v1.23.0/kubernetes-service-config/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "kubernetes-service-config" +version = "0.1.0" +authors = ["Sparks Song "] +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.23.0/kubernetes-service-config/src/main.rs b/sources/settings-migrations/v1.23.0/kubernetes-service-config/src/main.rs new file mode 100644 index 00000000000..9d179b8d9bb --- /dev/null +++ b/sources/settings-migrations/v1.23.0/kubernetes-service-config/src/main.rs @@ -0,0 +1,25 @@ +use migration_helpers::common_migrations::ReplaceStringMigration; +use migration_helpers::{migrate, Result}; +use std::process; + +const OLD_MODE: &str = "0600"; +const NEW_MODE: &str = "0644"; + +/// We changed the permissions mode for kubelet-exec-start-conf +fn run() -> Result<()> { + migrate(ReplaceStringMigration { + setting: "configuration-files.kubelet-exec-start-conf.mode", + old_val: OLD_MODE, + new_val: NEW_MODE, + }) +} + +// 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); + } +}