Skip to content

Commit

Permalink
Merge pull request #2270 from bcressey/ntp-restart
Browse files Browse the repository at this point in the history
fix ntp service restart when settings change
  • Loading branch information
bcressey authored Jul 11, 2022
2 parents 4940c76 + 5431a76 commit 49b1136
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Release.toml
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,6 @@ version = "1.8.0"
"migrate_v1.8.0_public-admin-container-v0-9-0.lz4",
"migrate_v1.8.0_public-control-container-v0-6-1.lz4",
]
"(1.8.0, 1.9.0)" = [
"migrate_v1.9.0_ntp-affected-services.lz4",
]
7 changes: 7 additions & 0 deletions sources/Cargo.lock

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

1 change: 1 addition & 0 deletions sources/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ members = [
"api/migration/migrations/v1.8.0/aws-control-container-v0-6-1",
"api/migration/migrations/v1.8.0/public-admin-container-v0-9-0",
"api/migration/migrations/v1.8.0/public-control-container-v0-6-1",
"api/migration/migrations/v1.9.0/ntp-affected-services",

"bottlerocket-release",

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "ntp-affected-services"
version = "0.1.0"
authors = ["Ben Cressey <bcressey@amazon.com>"]
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", version = "0.1.0" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#![deny(rust_2018_idioms)]

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

/// We updated the 'affected-services' list metadata for 'settings.ntp' to refer
/// to the correct service name ("ntp") instead of the incorrect one ("chronyd").
fn run() -> Result<()> {
migrate(ReplaceMetadataListsMigration(vec![
MetadataListReplacement {
setting: "settings.ntp",
metadata: "affected-services",
old_vals: &["chronyd"],
new_vals: &["ntp"],
},
]))
}

// 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);
}
}
2 changes: 1 addition & 1 deletion sources/models/shared-defaults/defaults.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ path = "/etc/chrony.conf"
template-path = "/usr/share/templates/chrony-conf"

[metadata.settings.ntp]
affected-services = ["chronyd"]
affected-services = ["ntp"]

# Kernel

Expand Down

0 comments on commit 49b1136

Please sign in to comment.