Skip to content

Commit

Permalink
migrations: migrate settings.container-registry, and related models
Browse files Browse the repository at this point in the history
Adds migrations for the new `container-registry` setting and the new
docker daemon config file and the new config file for host-containers
and bootstrap containers.
  • Loading branch information
etungsten committed Jul 30, 2021
1 parent 10902fb commit 2243f84
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Release.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,7 @@ version = "1.1.4"
"migrate_v1.1.3_kubelet-cpu-manager.lz4",
]
"(1.1.3, 1.1.4)" = []
"(1.1.4, 1.2.0)" = [
"migrate_v1.2.0_container-registry-mirrors.lz4",
"migrate_v1.2.0_container-registry-config-restarts.lz4",
]
14 changes: 14 additions & 0 deletions sources/Cargo.lock

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

2 changes: 2 additions & 0 deletions sources/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ members = [
"api/migration/migrations/v1.1.2/control-container-v0-5-1",
"api/migration/migrations/v1.1.3/kubelet-cpu-manager-state",
"api/migration/migrations/v1.1.3/kubelet-cpu-manager",
"api/migration/migrations/v1.2.0/container-registry-mirrors",
"api/migration/migrations/v1.2.0/container-registry-config-restarts",

"bottlerocket-release",

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "container-registry-config-restarts"
version = "0.1.0"
authors = ["Erikson Tung <[email protected]>"]
license = "Apache-2.0 OR MIT"
edition = "2018"
publish = false

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

use migration_helpers::common_migrations::{ListReplacement, ReplaceListsMigration};
use migration_helpers::{migrate, Result};
use std::process;

/// We templatized the configuration file for the Docker daemon.
/// We also added a new configuration file for host-containers and bootstrap-containers
fn run() -> Result<()> {
migrate(ReplaceListsMigration(vec![
ListReplacement {
setting: "services.docker.configuration-files",
old_vals: &["proxy-env"],
new_vals: &["docker-daemon-config", "proxy-env"],
},
ListReplacement {
setting: "services.bootstrap-containers.configuration-files",
old_vals: &[],
new_vals: &["host-ctr-registry-config"],
},
ListReplacement {
setting: "services.host-containers.configuration-files",
old_vals: &[],
new_vals: &["host-ctr-registry-config"],
},
]))
}

// 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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "container-registry-mirrors"
version = "0.1.0"
authors = ["Erikson Tung <[email protected]>"]
license = "Apache-2.0 OR MIT"
edition = "2018"
publish = false

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

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

/// We added a new setting for configuring image registries, `settings.container-registry`
/// We also added a new configuration template file for the Docker daemon
fn run() -> Result<()> {
migrate(AddPrefixesMigration(vec![
"settings.container-registry",
"configuration-files.docker-daemon-config",
"configuration-files.host-ctr-registry-config",
]))
}

// 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 2243f84

Please sign in to comment.