Skip to content

[Bug] - amazon-chrony-config systemd service/timer create an ordering cycle with chronyd #986

@anish

Description

@anish

Describe the bug
The chrony-config service shipped as part of amazon-chrony-config rpm is configured to be ordered both before and after chronyd at the same time

chronyd.service: Found ordering cycle on chrony-config.service/start
chronyd.service: Found dependency on chrony-config.timer/start
chronyd.service: Found dependency on chronyd.service/start
chronyd.service: Job chrony-config.service/start deleted to break ordering cycle starting with chronyd.service/start
[ SKIP ] Ordering cycle found, skipping chrony-config.service

To Reproduce
Steps to reproduce the behavior:

  1. Start an instance with chronyd enabled
  2. The following error messages are seen on startup :
chronyd.service: Found ordering cycle on chrony-config.service/start
chronyd.service: Found dependency on chrony-config.timer/start
chronyd.service: Found dependency on chronyd.service/start
chronyd.service: Job chrony-config.service/start deleted to break ordering cycle starting with chronyd.service/start
[ SKIP ] Ordering cycle found, skipping chrony-config.service

This could in theory also result in the chronyd service being skipped, resulting in misconfigured instances
3. This is obvious in the systemd service file for chrony-config.service, which declares a Before dependency vs the chrony-config.timer which declares an After dependency on chronyd.service. Timer units have an implicit Before dependency on the services they activate

bash-5.2# rpm -qf /usr/lib/systemd/system/chrony-config.service 
amazon-chrony-config-4.3-1.amzn2023.0.5.noarch
bash-5.2# rpm -qf /usr/lib/systemd/system/chrony-config.timer
amazon-chrony-config-4.3-1.amzn2023.0.5.noarch

bash-5.2# cat /usr/lib/systemd/system/chrony-config.service 
[Unit]
Description=Configures optimal endpoints for the chrony NTP client in AWS
Wants=network-online.target
After=network-online.target
Before=chronyd.service

[Service]
Type=oneshot
ExecStart=/usr/sbin/amazon-chrony-config
ExecStartPost=/usr/bin/touch /run/chrony.d/.configured
RemainAfterExit=no

[Install]
WantedBy=chronyd.service

bash-5.2# cat /usr/lib/systemd/system/chrony-config.timer
[Install]
WantedBy=timers.target

[Unit]
Description=Refresh chrony time sources based on DHCP lease renewals
After=chronyd.service

[Timer]
OnActiveSec=1800
OnUnitInactiveSec=1800
RandomizedDelaySec=180

This means chrony-config.timer wants to run after chronyd.service but before chrony-config.service, and chrony-config.service wants to run before chronyd.service creating a circular depedency
Expected behavior
There should be no ordering cycle

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions