diff --git a/RELEASE.toml b/RELEASE.toml index d296bbcee42..01fc451f1ad 100644 --- a/RELEASE.toml +++ b/RELEASE.toml @@ -1,7 +1,7 @@ -version = "0.2.0" -datastore_version = "0.1" +version = "0.2.1" +datastore_version = "0.2" [[migrations]] -from = "0.1.6" -to = "0.2.0" -names = ["migrate_0.1_borkseed", "migrate_0.1_host-containers-version-migration"] +from = "0.2.0" +to = "0.2.1" +names = ["migrate_0.2_containerd-config-path"] diff --git a/packages/workspaces/data-store-version b/packages/workspaces/data-store-version index 49d59571fbf..3b04cfb60da 100644 --- a/packages/workspaces/data-store-version +++ b/packages/workspaces/data-store-version @@ -1 +1 @@ -0.1 +0.2 diff --git a/workspaces/Cargo.lock b/workspaces/Cargo.lock index 7cf776b3c0c..93a64e04d8f 100644 --- a/workspaces/Cargo.lock +++ b/workspaces/Cargo.lock @@ -569,6 +569,15 @@ name = "constant_time_eq" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "containerd-config-path" +version = "0.1.0" +dependencies = [ + "migration-helpers 0.1.0", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", + "snafu 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cookie" version = "0.12.0" diff --git a/workspaces/Cargo.toml b/workspaces/Cargo.toml index 09695f7307d..5fc43781010 100644 --- a/workspaces/Cargo.toml +++ b/workspaces/Cargo.toml @@ -20,6 +20,7 @@ members = [ # workspace member when we add cross-workspace dependencies. "api/migration/migrations/v0.1/borkseed", "api/migration/migrations/v0.1/host-containers-version", + "api/migration/migrations/v0.2/containerd-config-path", "models", diff --git a/workspaces/api/migration/migrations/v0.2/containerd-config-path/Cargo.toml b/workspaces/api/migration/migrations/v0.2/containerd-config-path/Cargo.toml new file mode 100644 index 00000000000..16a56245d51 --- /dev/null +++ b/workspaces/api/migration/migrations/v0.2/containerd-config-path/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "containerd-config-path" +version = "0.1.0" +authors = ["Tom Kirchner "] +edition = "2018" +publish = false + +[dependencies] +migration-helpers = { path = "../../../migration-helpers" } +serde_json = "1.0" +snafu = "0.6" diff --git a/workspaces/api/migration/migrations/v0.2/containerd-config-path/src/main.rs b/workspaces/api/migration/migrations/v0.2/containerd-config-path/src/main.rs new file mode 100644 index 00000000000..3cadca73b4e --- /dev/null +++ b/workspaces/api/migration/migrations/v0.2/containerd-config-path/src/main.rs @@ -0,0 +1,49 @@ +#![deny(rust_2018_idioms)] + +use migration_helpers::{migrate, Migration, MigrationData, Result}; +use std::process; + +/// We changed the path to our containerd configuration template so that we could support image +/// variants with different configs. We need to update old images to the new path, and on +/// downgrade, new images to the old path. +struct ContainerdConfigPath; + +const SETTING: &str = "configuration-files.containerd-config-toml.template-path"; +// Old version with no variant +const DEFAULT_CTRD_CONFIG_OLD: &str = "/usr/share/templates/containerd-config-toml"; +// Any users coming from old versions would be using the aws-k8s variant because no other existed :) +const DEFAULT_CTRD_CONFIG_NEW: &str = "/usr/share/templates/containerd-config-toml_aws-k8s"; + +impl Migration for ContainerdConfigPath { + fn forward(&mut self, mut input: MigrationData) -> Result { + if let Some(cfg_path) = input.data.get_mut(SETTING) { + if cfg_path.as_str() == Some(DEFAULT_CTRD_CONFIG_OLD) { + *cfg_path = serde_json::Value::String(DEFAULT_CTRD_CONFIG_NEW.to_string()); + } + } + Ok(input) + } + + fn backward(&mut self, mut input: MigrationData) -> Result { + if let Some(cfg_path) = input.data.get_mut(SETTING) { + if cfg_path.as_str() == Some(DEFAULT_CTRD_CONFIG_NEW) { + *cfg_path = serde_json::Value::String(DEFAULT_CTRD_CONFIG_OLD.to_string()); + } + } + Ok(input) + } +} + +fn run() -> Result<()> { + migrate(ContainerdConfigPath) +} + +// 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); + } +} diff --git a/workspaces/deny.toml b/workspaces/deny.toml index 24640699d3e..35326c0f72a 100644 --- a/workspaces/deny.toml +++ b/workspaces/deny.toml @@ -32,6 +32,7 @@ skip = [ { name = "block-party", licenses = [] }, { name = "bork", licenses = [] }, { name = "borkseed-migration", licenses = [] }, + { name = "containerd-config-path", licenses = [] }, { name = "data_store_version", licenses = [] }, { name = "growpart", licenses = [] }, { name = "host-containers", licenses = [] },