Skip to content

Switch from ntpd to chrony#20497

Merged
yxieca merged 35 commits intosonic-net:masterfrom
saiarcot895:use-chrony-ntp
Mar 28, 2025
Merged

Switch from ntpd to chrony#20497
yxieca merged 35 commits intosonic-net:masterfrom
saiarcot895:use-chrony-ntp

Conversation

@saiarcot895
Copy link
Copy Markdown
Contributor

@saiarcot895 saiarcot895 commented Oct 14, 2024

Why I did it

This replaces ntpd with Chrony, as described in sonic-net/SONiC#1852. The advantages of this (among others) is control over enabling/disabling long jumps/steps and guaranteed updates of the real time clock.

This PR also includes a submodule update of sonic-utilities, to bring in necessary changes there for chrony to work. The changelog for sonic-utilities is:

Submodule src/sonic-utilities ce51df2d8c..7cbb2f2fd5:
  > [sfputil] add support for sfputil debug tx-output/rx-output {port} enable/disable  (#3811)
  > Switch to using chrony instead of ntpd (#3574)
  > Added post commands for enabling fifos (#3801)
  > kdump-Remote-SSH-Configurations (#3400)
Work item tracking
  • Microsoft ADO (number only): 31759518

How I did it

How to verify it

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205
  • 202211
  • 202305

Tested branch (Please provide the tested image version)

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
…tart before ntp-config service (sonic-net#2335)"

Supervisor now handles the case where the time jumps back, now that
Supervisor/supervisor#1047 has been merged.

This reverts commit 298d2ad.
Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
Currently, for deb package installations, the --root argument is passed
into dpkg to install packages in a custom root directory. However, this
doesn't seem to do a full chroot, because there are some user/group name
checks that appear to be done before the chroot has taken place. This
becomes an issue with the chrony installation; if chrony doesn't happen
to be installed on the host system, then installing any pacakge after
chrony is installed in the fsroot that we're building will fail with the
following error:

```
+ sudo DEBIAN_FRONTEND=noninteractive dpkg --root=./fsroot-vs -i target/debs/bookworm/kdump-tools_1.8.1_amd64.deb
dpkg: unrecoverable fatal error, aborting:
 unknown system group '_chrony' in statoverride file; the system group got removed
before the override, which is most probably a packaging bug, to recover you
can remove the override manually with dpkg-statoverride
```

Therefore, for deb (and whl) package installations, define a bash
function that will copy the file into the fsroot, chroot into it,
install the pacakge, and then remove it. Replace all existing deb and
whl installations with code to call this function, so that it's
consolidated.

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
This should hopefully let it start in a custom VRF.

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
This lets the RTC reflect the correct time even if the system time is
still catching up.

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
For chrony to start in another VRF, it needs to access `/proc/mounts`
and it needs to create cgroups. The default systemd service restricts
access to both.

Disable those restrictions so that this works.

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@saiarcot895
Copy link
Copy Markdown
Contributor Author

/azpw run

@mssonicbld
Copy link
Copy Markdown
Collaborator

/AzurePipelines run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
@saiarcot895
Copy link
Copy Markdown
Contributor Author

/azpw run Azure.sonic-buildimage

@mssonicbld
Copy link
Copy Markdown
Collaborator

/AzurePipelines run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

KVM environments might not have an NTP server available (or running in
the PTF container).

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@saiarcot895 saiarcot895 marked this pull request as ready for review March 26, 2025 17:30
@saiarcot895 saiarcot895 requested a review from yxieca March 27, 2025 23:14
@yxieca yxieca merged commit 8e87130 into sonic-net:master Mar 28, 2025
21 checks passed
@saiarcot895 saiarcot895 deleted the use-chrony-ntp branch March 31, 2025 23:45
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.

3 participants