Skip to content

Commit

Permalink
Merge pull request #1258 from etungsten/migrate-network-proxy
Browse files Browse the repository at this point in the history
migrations: adds necessary migrations for `settings.network`
  • Loading branch information
etungsten authored Jan 7, 2021
2 parents 1dbacd3 + 7a10053 commit bff72eb
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Release.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,11 @@ version = "1.0.4"
"(1.0.1, 1.0.2)" = ["migrate_v1.0.2_add-enable-spot-instance-draining.lz4"]
"(1.0.2, 1.0.3)" = ["migrate_v1.0.3_add-sysctl.lz4"]
"(1.0.3, 1.0.4)" = []
"(1.0.4, 1.0.5)" = ["migrate_v1.0.5_add-lockdown.lz4", "migrate_v1.0.5_sysctl-subcommand.lz4", "migrate_v1.0.5_add-user-data.lz4"]
"(1.0.4, 1.0.5)" = [
"migrate_v1.0.5_add-lockdown.lz4",
"migrate_v1.0.5_sysctl-subcommand.lz4",
"migrate_v1.0.5_add-user-data.lz4",
"migrate_v1.0.5_add-network-settings.lz4",
"migrate_v1.0.5_add-proxy-restart.lz4",
"migrate_v1.0.5_add-proxy-services.lz4"
]
21 changes: 21 additions & 0 deletions sources/Cargo.lock

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

3 changes: 3 additions & 0 deletions sources/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ members = [
"api/migration/migrations/v1.0.5/add-lockdown",
"api/migration/migrations/v1.0.5/sysctl-subcommand",
"api/migration/migrations/v1.0.5/add-user-data",
"api/migration/migrations/v1.0.5/add-network-settings",
"api/migration/migrations/v1.0.5/add-proxy-restart",
"api/migration/migrations/v1.0.5/add-proxy-services",

"bottlerocket-release",

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "add-network-settings"
version = "0.1.0"
authors = ["Erikson Tung <[email protected]>"]
license = "Apache-2.0 OR MIT"
edition = "2018"
publish = false
# Don't rebuild crate just because of changes to README.
exclude = ["README.md"]

[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 set of settings for configuring service network behavior and their associated
/// configuration file. Remove the whole `settings.network`, `configuration-files.proxy-env` prefix
/// if we downgrade.
fn run() -> Result<()> {
migrate(AddPrefixesMigration(vec![
"settings.network",
"configuration-files.proxy-env",
]))
}

// 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,12 @@
[package]
name = "add-proxy-restart"
version = "0.1.0"
authors = ["Erikson Tung <[email protected]>"]
license = "Apache-2.0 OR MIT"
edition = "2018"
publish = false
# Don't rebuild crate just because of changes to README.
exclude = ["README.md"]

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

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

/// We updated the restart-commands and configuration-files settings for several existing services.
/// We need to replace them upon downgrades and upgrades
fn run() -> Result<()> {
migrate(ReplaceListsMigration(vec![
ListReplacement {
setting: "services.containerd.configuration-files",
old_vals: &["containerd-config-toml"],
new_vals: &["containerd-config-toml", "proxy-env"],
},
ListReplacement {
setting: "services.containerd.restart-commands",
old_vals: &[],
new_vals: &["/bin/systemctl try-restart containerd.service"],
},
ListReplacement {
setting: "services.kubernetes.configuration-files",
old_vals: &[
"kubelet-env",
"kubelet-config",
"kubelet-kubeconfig",
"kubernetes-ca-crt",
],
new_vals: &[
"kubelet-env",
"kubelet-config",
"kubelet-kubeconfig",
"kubernetes-ca-crt",
"proxy-env",
],
},
ListReplacement {
setting: "services.kubernetes.restart-commands",
old_vals: &[],
new_vals: &["/bin/systemctl try-restart kubelet.service"],
},
]))
}

// 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,12 @@
[package]
name = "add-proxy-services"
version = "0.1.0"
authors = ["Erikson Tung <[email protected]>"]
license = "Apache-2.0 OR MIT"
edition = "2018"
publish = false
# Don't rebuild crate just because of changes to README.
exclude = ["README.md"]

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

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

/// We added new configuration files and restart commands for docker and host-containerd.
/// On downgrade we need to remove all settings under these services
fn run() -> Result<()> {
migrate(AddPrefixesMigration(vec![
"services.docker",
"services.host-containerd",
]))
}

// 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 bff72eb

Please sign in to comment.