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

Switch to using chrony instead of ntpd #3574

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

saiarcot895
Copy link
Contributor

@saiarcot895 saiarcot895 commented Oct 14, 2024

What I did

Switch to calling chronyc instead of ntpq and ntpstat. This is as part of switching to using Chrony instead of ntpd.

Buildimage PR: sonic-net/sonic-buildimage#20497

How I did it

  1. Replace calls to ntpq, ntpstat with chrony, as the former commands will no longer work.
  2. Restart the chrony service instead of the ntp-config service (which also handles regeneration of /etc/chrony/chrony.conf).
  3. Add support for accepting the NTP version, iburst, and association type from the CLI. Previously, these could only be specified via writing to config_db directly.

How to verify it

Previous command output (if the output of a command-line utility has changed)

admin@strtk5-msn2700-02:~$ sudo config ntp add --help
Usage: config ntp add [OPTIONS] <ntp_ip_address>

  Add NTP server IP

Options:
  -h, -?, --help  Show this message and exit.

With ntpd, time synchronized:

admin@strtk5-msn2700-02:~$ show ntp
MGMT_VRF_CONFIG is not present.
synchronised to unspecified at stratum 3
   time correct to within 47 ms
   polling server every 64 s
     remote           refid      st t when poll reach   delay   offset   jitter
===============================================================================
*10.212.65.2     10.201.148.43    2 u   17   64  377   0.2070  -1.0223   0.1344

With ntpd, time not synchronized:

admin@vlab-05:~$ show ntp
MGMT_VRF_CONFIG is not present.
unsynchronised
   polling server every 1 s

New command output (if the output of a command-line utility has changed)

admin@vlab-01:~$ sudo config ntp add --help
Usage: config ntp add [OPTIONS] <ntp_ip_address>

  Add NTP server IP

Options:
  --association-type [server|pool]
                                  Define the association type for this NTP
                                  server
  --iburst                        Enable iburst for this NTP server
  --version INTEGER               Specify the version for this NTP server
  -?, -h, --help                  Show this message and exit.

With chrony, time not synchronized:

admin@vlab-01:~$ show ntp
MGMT_VRF_CONFIG is not present.
Reference ID    : 00000000 ()
Stratum         : 0
Ref time (UTC)  : Thu Jan 01 00:00:00 1970
System time     : 0.000000000 seconds fast of NTP time
Last offset     : +0.000000000 seconds
RMS offset      : 0.000000000 seconds
Frequency       : 0.000 ppm slow
Residual freq   : +0.000 ppm
Skew            : 0.000 ppm
Root delay      : 1.000000000 seconds
Root dispersion : 1.000000000 seconds
Update interval : 0.0 seconds
Leap status     : Not synchronised
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^? 10.11.0.1                     0   6     0     -     +0ns[   +0ns] +/-    0ns
^? 10.11.0.2                     0   6     0     -     +0ns[   +0ns] +/-    0ns

With chrony, time synchronized:

admin@vlab-01:~$ show ntp
MGMT_VRF_CONFIG is not present.
Reference ID    : 0AFA0001 (10.250.0.1)
Stratum         : 2
Ref time (UTC)  : Thu Mar 06 00:27:21 2025
System time     : 0.000000000 seconds fast of NTP time
Last offset     : -0.000010956 seconds
RMS offset      : 0.000010956 seconds
Frequency       : 5.709 ppm slow
Residual freq   : -0.000 ppm
Skew            : 13.460 ppm
Root delay      : 0.000119419 seconds
Root dispersion : 0.000720337 seconds
Update interval : 2.0 seconds
Leap status     : Normal
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^? 10.11.0.1                     0   7     0     -     +0ns[   +0ns] +/-    0ns
^? 10.11.0.2                     0   7     0     -     +0ns[   +0ns] +/-    0ns
^* 10.250.0.1                    1   6    17    46  -3332ns[  -14us] +/-  103us

When adding new NTP servers via the CLI, allow options such as iburst,
version, and the association type to be specified.

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

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@saiarcot895
Copy link
Contributor Author

/azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Pool NTP servers are typically domain names, and will resolve to
multiple IP addresses. All of those IP addresses are expected to be
used.

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

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@saiarcot895 saiarcot895 marked this pull request as ready for review March 3, 2025 23:48
@yxieca
Copy link
Contributor

yxieca commented Mar 5, 2025

@saiarcot895 can you fill the PR template?

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@saiarcot895
Copy link
Contributor Author

/azpw run

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

/azp run

Copy link

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@saiarcot895
Copy link
Contributor Author

/azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

yxieca
yxieca previously approved these changes Mar 6, 2025
Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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