Skip to content

Commit

Permalink
migrations: add send-metrics setting-generator
Browse files Browse the repository at this point in the history
AWS variants now generate the `settings.metrics.send-metrics` setting
based on partition information gathered from shibaken.
  • Loading branch information
cbgbt committed Jul 13, 2022
1 parent a44e397 commit eb2bbc9
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions Release.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,5 @@ version = "1.8.0"
"(1.8.0, 1.9.0)" = [
"migrate_v1.9.0_ntp-affected-services.lz4",
"migrate_v1.9.0_shibaken-admin-userdata-semantics.lz4",
"migrate_v1.9.0_shibaken-send-metrics.lz4",
]
7 changes: 7 additions & 0 deletions sources/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions sources/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ members = [
"api/migration/migrations/v1.8.0/public-control-container-v0-6-1",
"api/migration/migrations/v1.9.0/ntp-affected-services",
"api/migration/migrations/v1.9.0/shibaken-admin-userdata-semantics",
"api/migration/migrations/v1.9.0/shibaken-send-metrics",

"bottlerocket-release",

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "shibaken-send-metrics"
version = "0.1.0"
authors = ["Sean P. Kelly <seankell@amazon.com>"]
license = "Apache-2.0 OR MIT"
edition = "2018"
publish = false

[dependencies]
migration-helpers = { path = "../../../migration-helpers", version = "0.1.0"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#![deny(rust_2018_idioms)]

use migration_helpers::common_migrations::{AddMetadataMigration, SettingMetadata};
use migration_helpers::{migrate, Result};
use std::process;

/// We added a `setting-generator` for `settings.metrics.send-metrics` on AWS variants.
/// This migration will do nothing on upgrade, but will remove the metadata if present on downgrade.
fn run() -> Result<()> {
migrate(AddMetadataMigration(&[SettingMetadata {
setting: "settings.metrics.send-metrics",
metadata: &["setting-generator"],
}]))
}

// 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);
}
}

0 comments on commit eb2bbc9

Please sign in to comment.