Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

fix: use ntp instead of systemd-timesyncd in 18.04 #2815

Merged
merged 10 commits into from
Mar 19, 2020

Conversation

jackfrancis
Copy link
Member

Reason for Change:

This PR changes the 18.04-LTS bootstrap implementation (both VHD and non-VHD) to use the ntp package instead of the built-in systemd-timesyncd. This is due to a hypothesis that this time synchronization configuration is more reliable.

Issue Fixed:

Fixes #1306

Requirements:

Notes:

@codecov
Copy link

codecov bot commented Mar 2, 2020

Codecov Report

Merging #2815 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #2815   +/-   ##
=======================================
  Coverage   72.49%   72.49%           
=======================================
  Files         141      141           
  Lines       25847    25847           
=======================================
  Hits        18739    18739           
  Misses       6021     6021           
  Partials     1087     1087

if [[ $UBUNTU_VERSION == "18.04" ]]; then
NTP="ntp"
systemctl_stop 20 5 10 systemd-timesyncd || exit $ERR_SYSTEMCTL_STOP_FAIL
retrycmd_if_failure 120 5 25 systemctl disable systemd-timesyncd || exit $ERR_SYSTEMCTL_STOP_FAIL
Copy link
Contributor

Choose a reason for hiding this comment

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

can we put disabling timesyncd in a separate function since it's not actually part of installing any dependencies?

Copy link
Member Author

Choose a reason for hiding this comment

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

I would prefer not to install the ntp package on an OS runtime w/ systemd-timesyncd running and enabled, but maybe that's paranoia?

Copy link
Contributor

Choose a reason for hiding this comment

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

we can at least extract it into a func and call it from here, just want to make sure installDeps doesn't become an long list of unrelated commands

@@ -35,6 +35,11 @@ removeContainerd() {
fi
}

disableTimeSyncd() {
systemctl_stop 20 5 10 systemd-timesyncd || exit $1
Copy link
Contributor

Choose a reason for hiding this comment

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

why not just

Suggested change
systemctl_stop 20 5 10 systemd-timesyncd || exit $1
systemctl_stop 20 5 10 systemd-timesyncd || exit $ERR_SYSTEMCTL_STOP_FAIL

to stay consistent with the rest of the file? We're not passing in exit codes as args in other CSE functions

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question! I'm just sort of desparate to save cloud-init bytes here is the reason.

Copy link
Contributor

Choose a reason for hiding this comment

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

in that case maybe we can change systemctl_stop to take more than one arg and stop both in one call

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that's a good suggestion for a follow-up PR, how about my latest change?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's okay but I really don't like that we have to lower code quality/readability to save space :(

Copy link
Member Author

Choose a reason for hiding this comment

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

:(

@@ -35,6 +35,11 @@ removeContainerd() {
fi
}

disableTimeSyncd() {
systemctl_stop 20 5 10 systemd-timesyncd || exit $1
retrycmd_if_failure 120 5 25 systemctl disable systemd-timesyncd || exit $1
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
retrycmd_if_failure 120 5 25 systemctl disable systemd-timesyncd || exit $1
retrycmd_if_failure 120 5 25 systemctl disable systemd-timesyncd || exit $ERR_SYSTEMCTL_STOP_FAIL

@@ -68,6 +73,10 @@ installDeps() {
retrycmd_if_failure 60 5 10 dpkg -i /tmp/packages-microsoft-prod.deb || exit $ERR_MS_PROD_DEB_PKG_ADD_FAIL
aptmarkWALinuxAgent hold
packages+=" cgroup-lite ceph-common glusterfs-client"
if [[ $UBUNTU_RELEASE == "18.04" ]]; then
disableTimeSyncd $ERR_SYSTEMCTL_STOP_FAIL
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
disableTimeSyncd $ERR_SYSTEMCTL_STOP_FAIL
disableTimeSyncd

Copy link
Contributor

@CecileRobertMichon CecileRobertMichon left a comment

Choose a reason for hiding this comment

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

/lgtm

@acs-bot
Copy link

acs-bot commented Mar 19, 2020

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CecileRobertMichon, jackfrancis

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [CecileRobertMichon,jackfrancis]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jackfrancis
Copy link
Member Author

@yangl900 @xuto2 @palma21 FYI, AKS Engine will be shipping a ntp-enabled (in favor of systemd-timesync) 18.04-LTS on the way towards considering making it the default Ubuntu flavor.

@ritazh FYI

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ubuntu 18.04: Timesync stays Idle for a while after boot
3 participants