Skip to content

OCPBUGS-59751: baremetal: add additional ntp servers to worker config #9904

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions pkg/asset/machines/machineconfig/chrony.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package machineconfig

import (
"fmt"
"strings"

igntypes "github.com/coreos/ignition/v2/config/v3_2/types"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -11,8 +12,8 @@ import (
)

// ForCustomNTP lays down chrony.conf with given NTP server.
func ForCustomNTP(role string, server string) (*mcfgv1.MachineConfig, error) {
chronyConf, err := createChronyConf(server)
func ForCustomNTP(role string, servers []string) (*mcfgv1.MachineConfig, error) {
chronyConf, err := createChronyConf(servers)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -49,11 +50,17 @@ func ForCustomNTP(role string, server string) (*mcfgv1.MachineConfig, error) {
}, nil
}

func createChronyConf(server string) (string, error) {
unit := `server %s iburst
func createChronyConf(servers []string) (string, error) {
lines := []string{}

for _, server := range servers {
lines = append(lines, fmt.Sprintf("server %s iburst", server))
}

unit := `%s
driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
logdir /var/log/chrony`
return fmt.Sprintf(unit, server), nil
return fmt.Sprintf(unit, strings.Join(lines, "\n")), nil
}
2 changes: 1 addition & 1 deletion pkg/asset/machines/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ func (m *Master) Generate(ctx context.Context, dependencies asset.Parents) error

if installConfig.Config.Publish == types.InternalPublishingStrategy &&
(len(installConfig.Config.ImageDigestSources) > 0 || len(installConfig.Config.DeprecatedImageContentSources) > 0) {
ignChrony, err := machineconfig.ForCustomNTP("master", powervsdefaults.DefaultNTPServer)
ignChrony, err := machineconfig.ForCustomNTP("master", []string{powervsdefaults.DefaultNTPServer})
if err != nil {
return errors.Wrap(err, "failed to create ignition for custom NTP for master machines")
}
Expand Down
10 changes: 9 additions & 1 deletion pkg/asset/machines/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ func (w *Worker) Generate(ctx context.Context, dependencies asset.Parents) error

if installConfig.Config.Publish == types.InternalPublishingStrategy &&
(len(installConfig.Config.ImageDigestSources) > 0 || len(installConfig.Config.DeprecatedImageContentSources) > 0) {
ignChrony, err := machineconfig.ForCustomNTP("worker", powervsdefaults.DefaultNTPServer)
ignChrony, err := machineconfig.ForCustomNTP("worker", []string{powervsdefaults.DefaultNTPServer})
if err != nil {
return errors.Wrap(err, "failed to create ignition for custom NTP for worker machines")
}
Expand Down Expand Up @@ -629,6 +629,14 @@ func (w *Worker) Generate(ctx context.Context, dependencies asset.Parents) error
machineSets = append(machineSets, set)
}
}

if len(ic.Platform.BareMetal.AdditionalNTPServers) > 0 {
ignChrony, err := machineconfig.ForCustomNTP("worker", ic.Platform.BareMetal.AdditionalNTPServers)
if err != nil {
return errors.Wrap(err, "failed to create ignition for custom NTP for worker machines")
}
machineConfigs = append(machineConfigs, ignChrony)
}
case gcptypes.Name:
mpool := defaultGCPMachinePoolPlatform(pool.Architecture)
mpool.Set(ic.Platform.GCP.DefaultMachinePlatform)
Expand Down