Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ntp service restart when settings change #2270

Merged
merged 2 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <[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", 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