Commit 12d49298 authored by Steve Azzopardi's avatar Steve Azzopardi

Merge branch 'fix/mac-parallels' into 'master'

fix(parallels): use the newer sntp command to time sync

Closes #3666

See merge request gitlab-org/gitlab-runner!1145
parents 03a0f894 aa06c2b6
Pipeline #47184134 passed with stages
in 26 minutes and 52 seconds
......@@ -112,6 +112,7 @@ type ParallelsConfig struct {
BaseName string `toml:"base_name" json:"base_name" long:"base-name" env:"PARALLELS_BASE_NAME" description:"VM name to be used"`
TemplateName string `toml:"template_name,omitempty" json:"template_name" long:"template-name" env:"PARALLELS_TEMPLATE_NAME" description:"VM template to be created"`
DisableSnapshots bool `toml:"disable_snapshots,omitzero" json:"disable_snapshots" long:"disable-snapshots" env:"PARALLELS_DISABLE_SNAPSHOTS" description:"Disable snapshoting to speedup VM creation"`
TimeServer string `toml:"time_server,omitempty" json:"time_server" long:"time-server" env:"PARALLELS_TIME_SERVER" description:"Timeserver to sync the guests time from. Defaults to time.apple.com"`
}
type VirtualBoxConfig struct {
......
......@@ -153,6 +153,24 @@ func (s *executor) createVM() error {
return nil
}
func (s *executor) updateGuestTime() error {
s.Debugln("Updating VM date...")
timeServer := s.Config.Parallels.TimeServer
if timeServer == "" {
timeServer = "time.apple.com"
}
err := prl.TryExec(s.vmName, 20, "sudo", "ntpdate", "-u", timeServer)
if err != nil {
s.Debugln("Could not run ntpdate command. Trying the sntp command instead...")
err = prl.TryExec(s.vmName, 20, "sudo", "sntp", "-S", timeServer)
if err != nil {
return err
}
}
return nil
}
func (s *executor) Prepare(options common.ExecutorPrepareOptions) error {
err := s.AbstractExecutor.Prepare(options)
if err != nil {
......@@ -264,9 +282,9 @@ func (s *executor) Prepare(options common.ExecutorPrepareOptions) error {
// TODO: integration tests do fail on this due
// Unable to open new session in this virtual machine.
// Make sure the latest version of Parallels Tools is installed in this virtual machine and it has finished booting
s.Debugln("Updating VM date...")
err = prl.TryExec(s.vmName, 20, "sudo", "ntpdate", "-u", "time.apple.com")
err = s.updateGuestTime()
if err != nil {
s.Println("Could not sync with timeserver!")
return err
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment