Skip to content

Commit

Permalink
migrations: add migrations needed to remove ECS settings applier
Browse files Browse the repository at this point in the history
Signed-off-by: Arnaldo Garcia Rincon <[email protected]>
  • Loading branch information
arnaldo2792 committed Apr 1, 2024
1 parent 05b6448 commit ea39589
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Release.toml
Original file line number Diff line number Diff line change
Expand Up @@ -290,4 +290,7 @@ version = "1.20.0"
"migrate_v1.20.0_host-containers-config-list-v0-1-0.lz4",
"migrate_v1.20.0_corndog-config-file-v0-1-0.lz4",
"migrate_v1.20.0_corndog-services-cfg-v0-1-0.lz4",
"migrate_v1.20.0_remove-ecs-settings-applier.lz4",
"migrate_v1.20.0_update-ecs-config-path.lz4",
"migrate_v1.20.0_update-ecs-config-template-path.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 @@ -75,6 +75,9 @@ members = [
"api/migration/migrations/v1.20.0/host-containers-config-list-v0-1-0",
"api/migration/migrations/v1.20.0/corndog-config-file-v0-1-0",
"api/migration/migrations/v1.20.0/corndog-services-cfg-v0-1-0",
"api/migration/migrations/v1.20.0/remove-ecs-settings-applier",
"api/migration/migrations/v1.20.0/update-ecs-config-path",
"api/migration/migrations/v1.20.0/update-ecs-config-template-path",

"bloodhound",

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "remove-ecs-settings-applier"
version = "0.1.0"
edition = "2021"
authors = ["Arnaldo Garcia <[email protected]>"]
license = "Apache-2.0 OR MIT"
publish = false
exclude = ["README.md"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
migration-helpers = { path = "../../../migration-helpers", version = "0.1.0" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use migration_helpers::common_migrations::{ListReplacement, ReplaceListsMigration};
use migration_helpers::{migrate, Result};
use std::process;

/// We updated the 'affected-services' list metadata for 'settings.ecs' to remove
/// ecs-settings-applier on upgrade, and to add it on downgrade.
fn run() -> Result<()> {
migrate(ReplaceListsMigration(vec![ListReplacement {
setting: "services.ecs.restart-commands",
old_vals: &[
"/usr/bin/ecs-settings-applier",
"/bin/systemctl try-reload-or-restart ecs.service",
],
new_vals: &["/bin/systemctl try-reload-or-restart ecs.service"],
}]))
}

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,13 @@
[package]
name = "update-ecs-config-path"
version = "0.1.0"
edition = "2021"
authors = ["Arnaldo Garcia <[email protected]>"]
license = "Apache-2.0 OR MIT"
publish = false
exclude = ["README.md"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
migration-helpers = { path = "../../../migration-helpers", version = "0.1.0" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use migration_helpers::common_migrations::ReplaceStringMigration;
use migration_helpers::{migrate, Result};
use std::process;

/// We updated the 'path' string for 'ecs-config'
fn run() -> Result<()> {
migrate(ReplaceStringMigration {
setting: "configuration-files.ecs-config.path",
old_val: "/etc/ecs/ecs.config",
new_val: "/etc/systemd/system/ecs.service.d/10-base.conf",
})
}

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,13 @@
[package]
name = "update-ecs-config-template-path"
version = "0.1.0"
edition = "2021"
authors = ["Arnaldo Garcia <[email protected]>"]
license = "Apache-2.0 OR MIT"
publish = false
exclude = ["README.md"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
migration-helpers = { path = "../../../migration-helpers", version = "0.1.0" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use migration_helpers::common_migrations::ReplaceStringMigration;
use migration_helpers::{migrate, Result};
use std::process;

/// We updated the 'template-path' for 'ecs-config'
fn run() -> Result<()> {
migrate(ReplaceStringMigration {
setting: "configuration-files.ecs-config.template-path",
old_val: "/usr/share/templates/ecs.config",
new_val: "/usr/share/templates/ecs-base-conf",
})
}

fn main() {
if let Err(e) = run() {
eprintln!("{}", e);
process::exit(1);
}
}

0 comments on commit ea39589

Please sign in to comment.