Skip to content

ntp: use per-server chrony settings - #4923

Draft
xiaotianlyu wants to merge 3 commits into
bottlerocket-os:developfrom
xiaotianlyu:ntp-per-server-config
Draft

xiaotianlyu wants to merge 3 commits into
bottlerocket-os:developfrom
xiaotianlyu:ntp-per-server-config

Conversation

@xiaotianlyu

@xiaotianlyu xiaotianlyu commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Description of changes:

Updates the shared NTP defaults to use named per-server chrony settings:

  • configures 169.254.169.123 as a preferred server polled every 16 seconds;
  • replaces 2.amazon.pool.ntp.org with the time.aws.com pool;
  • enables chrony measurement, statistics, and tracking logs.

Adds a datastore migration for existing nodes. On upgrade, it converts the old settings.ntp.time-servers list and shared options into named servers. On rollback, it converts named servers back into a list and shared options that the old API can read.

The migration is required because Storewolf otherwise retains the old list while adding the new named keys. This was reproduced during upgrade as:

duplicate field time_servers

The migration is registered for the 1.64.0 -> 1.65.0 transition.

Testing done:

Local tests:

  • cargo test -p ntp-time-servers: 6 passed
  • cargo test -p migration-helpers: 19 passed
  • cargo clippy -p ntp-time-servers --all-targets -- -D warnings: passed
  • cargo fmt --manifest-path sources/Cargo.toml --all -- --check: passed
  • git diff --check: passed

Filesystem migration test:

  • migrated an old list datastore forward to named servers;
  • migrated the named datastore backward to the old list form;
  • verified the expected data and metadata in both directions.

Full image upgrade and rollback test:

  • built a local core-kit and an aws-k8s-1.32 x86_64 1.65.0 test image containing all three related changes;
  • generated a signed TUF repository and verified it contained migrate_v1.65.0_ntp-time-servers.lz4;
  • launched a Bottlerocket 1.64.0 node with the old server list;
  • upgraded the node from 1.64.0 to the test 1.65.0 image;
  • rolled the node back to 1.64.0.

After upgrade:

  • the migrator journal reported that the NTP migration completed successfully;

  • apiclient get settings.ntp returned only the named link-local and amazon-pool entries, with no duplicate-field error;

  • /etc/chrony.conf rendered:

    pool time.aws.com iburst
    server 169.254.169.123 prefer iburst minpoll 4 maxpoll 4
    driftfile /var/lib/chrony/drift
    makestep 1.0 3
    dumponexit
    dumpdir /var/lib/chrony
    logdir /var/log/chrony
    log measurements statistics tracking
    user chrony
    rtcsync
    
  • changing logging to ["tracking"] rendered log tracking;

  • changing logging to [] removed the log directive;

  • chronyd was active with NRestarts=0;

  • all three log files were written under /var/log/chrony with the expected
    owner and measure_t SELinux label.

After rollback:

  • the node returned to Bottlerocket 1.64.0;
  • the backward migration completed successfully;
  • the old API read 169.254.169.123 and time.aws.com in the restored list;
  • the old chrony template rendered both entries with the shared iburst option.

Related PRs:

Testing remaining:

  • after the core-kit release is available, rebuild the final image and launch a fresh
    instance;

  • verify that chrony file logging is disabled by default;

  • verify that /etc/chrony.conf contains no log directive;

  • verify that logging can still be enabled through settings.ntp.logging.

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

@xiaotianlyu
xiaotianlyu force-pushed the ntp-per-server-config branch from d2acce8 to 97ae203 Compare September 2, 2026 03:37
@xiaotianlyu xiaotianlyu changed the title ntp: improve Amazon Time Sync recovery ntp: add per-server Amazon Time Sync configuration Sep 2, 2026
@xiaotianlyu xiaotianlyu changed the title ntp: add per-server Amazon Time Sync configuration ntp: use per-server chrony settings for Amazon Time Sync Sep 2, 2026
@xiaotianlyu xiaotianlyu changed the title ntp: use per-server chrony settings for Amazon Time Sync ntp: use per-server chrony settings Sep 2, 2026
Comment thread sources/shared-defaults/public-ntp.toml Outdated
Comment on lines +3 to +4
# chrony log categories, rendered as the `log` line.
logging = ["measurements", "statistics", "tracking"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logging should be opt-in, not on by default

Suggested change
# chrony log categories, rendered as the `log` line.
logging = ["measurements", "statistics", "tracking"]

Comment thread sources/shared-defaults/defaults.toml Outdated
Comment on lines +95 to +96
# chrony log categories, rendered as the `log` line.
logging = ["measurements", "statistics", "tracking"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logging should be opt-in, not on by default

Suggested change
# chrony log categories, rendered as the `log` line.
logging = ["measurements", "statistics", "tracking"]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, thanks! Chrony file logging is now opt-in and is no longer enabled in the shared defaults.

Move the default time servers to the named per-server format so each
source can carry its own directive and options. Configure chrony log
categories through the new ntp.logging setting.

Signed-off-by: Melody Lyu <tianlyu@amazon.com>
Convert the legacy server list to named per-server settings on upgrade.
Restore an old-readable list on rollback. Register the migration for the
1.65.0 to 1.66.0 transition and keep release versions aligned.

Signed-off-by: Melody Lyu <tianlyu@amazon.com>
Signed-off-by: Melody Lyu <tianlyu@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants