Skip to content

Commit

Permalink
Merge pull request #12681 from hakman/ubuntu-chrony
Browse files Browse the repository at this point in the history
Use chrony for synchronizing time in Ubuntu
  • Loading branch information
k8s-ci-robot committed Nov 4, 2021
2 parents b47e023 + 5ec40c0 commit f49b99f
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions nodeup/pkg/model/ntp.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,17 @@ func (b *NTPBuilder) Build(c *fi.ModelBuilderContext) error {
ntpHost = ""
}

if b.Distribution.IsDebianFamily() {
// Ubuntu recommends systemd-timesyncd, but on ubuntu on GCE systemd-timesyncd is blocked (in favor of chrony)
if b.Distribution.IsUbuntu() && !b.RunningOnGCE() {
if ntpHost != "" {
c.AddTask(b.buildTimesyncdConf("/etc/systemd/timesyncd.conf", ntpHost))
}
c.AddTask((&nodetasks.Service{Name: "systemd-timesyncd"}).InitDefaults())
} else {
c.AddTask(&nodetasks.Package{Name: "chrony"})
if ntpHost != "" {
c.AddTask(b.buildChronydConf("/etc/chrony/chrony.conf", ntpHost))
}
c.AddTask((&nodetasks.Service{Name: "chrony"}).InitDefaults())
if !b.RunningOnGCE() && b.Distribution.IsUbuntu() && b.Distribution.Version() <= 20.04 {
if ntpHost != "" {
c.AddTask(b.buildTimesyncdConf("/etc/systemd/timesyncd.conf", ntpHost))
}
c.AddTask((&nodetasks.Service{Name: "systemd-timesyncd"}).InitDefaults())
} else if b.Distribution.IsDebianFamily() {
c.AddTask(&nodetasks.Package{Name: "chrony"})
if ntpHost != "" {
c.AddTask(b.buildChronydConf("/etc/chrony/chrony.conf", ntpHost))
}
c.AddTask((&nodetasks.Service{Name: "chrony"}).InitDefaults())
} else if b.Distribution.IsRHELFamily() {
c.AddTask(&nodetasks.Package{Name: "chrony"})
if ntpHost != "" {
Expand All @@ -87,7 +84,7 @@ func (b *NTPBuilder) Build(c *fi.ModelBuilderContext) error {
}

func (b *NTPBuilder) buildChronydConf(path string, host string) *nodetasks.File {
conf := `# Built by Kops - do NOT edit
conf := `# Built by kOps - do NOT edit
pool ` + host + ` prefer iburst
driftfile /var/lib/chrony/drift
Expand Down

0 comments on commit f49b99f

Please sign in to comment.