From 0dfd144720a5191b46455bfc3d9b90536f25ffad Mon Sep 17 00:00:00 2001 From: Shikha Vyaghra Date: Fri, 24 Jan 2025 22:50:53 +0000 Subject: [PATCH] migrations: Remove metdata and data public Admin In this migration we will remove the data and metadata if it matches with existing ones in datastore. We will rely on storewolf to populate correct metadata and data. --- Release.toml | 1 + sources/Cargo.lock | 7 ++++++ sources/Cargo.toml | 1 + .../public-remove-source-admin/Cargo.toml | 15 +++++++++++ .../public-remove-source-admin/src/main.rs | 25 +++++++++++++++++++ 5 files changed, 49 insertions(+) create mode 100644 sources/settings-migrations/v1.33.0/public-remove-source-admin/Cargo.toml create mode 100644 sources/settings-migrations/v1.33.0/public-remove-source-admin/src/main.rs diff --git a/Release.toml b/Release.toml index 73381b61cf1..2948b5c240b 100644 --- a/Release.toml +++ b/Release.toml @@ -398,4 +398,5 @@ version = "1.33.0" "migrate_v1.33.0_reset-metadata-migration.lz4", "migrate_v1.33.0_aws-remove-schnauzer-admin.lz4", "migrate_v1.33.0_aws-remove-schnauzer-control.lz4", + "migrate_v1.33.0_public-remove-source-admin.lz4", ] diff --git a/sources/Cargo.lock b/sources/Cargo.lock index 43c3a9ed928..c976fd3e886 100644 --- a/sources/Cargo.lock +++ b/sources/Cargo.lock @@ -2209,6 +2209,13 @@ dependencies = [ "migration-helpers", ] +[[package]] +name = "public-remove-source-admin" +version = "0.1.0" +dependencies = [ + "migration-helpers", +] + [[package]] name = "quinn" version = "0.11.5" diff --git a/sources/Cargo.toml b/sources/Cargo.toml index f02a8e181e8..b4d49ab67cd 100644 --- a/sources/Cargo.toml +++ b/sources/Cargo.toml @@ -86,6 +86,7 @@ members = [ "settings-migrations/v1.33.0/reset-metadata-migration", "settings-migrations/v1.33.0/aws-remove-schnauzer-admin", "settings-migrations/v1.33.0/aws-remove-schnauzer-control", + "settings-migrations/v1.33.0/public-remove-source-admin", "settings-plugins/aws-dev", "settings-plugins/aws-ecs-1", diff --git a/sources/settings-migrations/v1.33.0/public-remove-source-admin/Cargo.toml b/sources/settings-migrations/v1.33.0/public-remove-source-admin/Cargo.toml new file mode 100644 index 00000000000..5cbc5eaf457 --- /dev/null +++ b/sources/settings-migrations/v1.33.0/public-remove-source-admin/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "public-remove-source-admin" +version = "0.1.0" +authors = ["Shikha Vyaghra "] +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.33.0/public-remove-source-admin/src/main.rs b/sources/settings-migrations/v1.33.0/public-remove-source-admin/src/main.rs new file mode 100644 index 00000000000..ecb0f46f775 --- /dev/null +++ b/sources/settings-migrations/v1.33.0/public-remove-source-admin/src/main.rs @@ -0,0 +1,25 @@ +use migration_helpers::common_migrations::RemoveOldData; +use migration_helpers::{migrate, Result}; +use std::process; + +const OLD_ADMIN_CTR: &str = "public.ecr.aws/bottlerocket/bottlerocket-admin:v0.11.14"; +const NEW_ADMIN_CTR: &str = "public.ecr.aws/bottlerocket/bottlerocket-admin:v0.11.14"; + +/// We bumped the version of the default admin container +fn run() -> Result<()> { + migrate(RemoveOldData { + setting: "settings.host-containers.admin.source", + old_val: OLD_ADMIN_CTR, + new_val: NEW_ADMIN_CTR, + }) +} + +// 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); + } +}