-
Notifications
You must be signed in to change notification settings - Fork 519
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1258 from etungsten/migrate-network-proxy
migrations: adds necessary migrations for `settings.network`
- Loading branch information
Showing
9 changed files
with
170 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
sources/api/migration/migrations/v1.0.5/add-network-settings/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" } |
25 changes: 25 additions & 0 deletions
25
sources/api/migration/migrations/v1.0.5/add-network-settings/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
sources/api/migration/migrations/v1.0.5/add-proxy-restart/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" } |
53 changes: 53 additions & 0 deletions
53
sources/api/migration/migrations/v1.0.5/add-proxy-restart/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
sources/api/migration/migrations/v1.0.5/add-proxy-services/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" } |
24 changes: 24 additions & 0 deletions
24
sources/api/migration/migrations/v1.0.5/add-proxy-services/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |