diff --git a/src/installer/installer.go b/src/installer/installer.go index 1f23d7e836..10e7f9584e 100644 --- a/src/installer/installer.go +++ b/src/installer/installer.go @@ -615,7 +615,7 @@ func (i *installer) waitForBootkube(ctx context.Context) { return case <-time.After(generalWaitInterval): // check if bootkube is done every 5 seconds - if _, err := i.ops.ExecPrivilegeCommand(nil, "stat", "/opt/openshift/.bootkube.done"); err == nil { + if i.ops.FileExists("/opt/openshift/.bootkube.done") { // in case bootkube is done log the status and return i.log.Info("bootkube service completed") out, _ := i.ops.ExecPrivilegeCommand(nil, "systemctl", "status", "bootkube.service") diff --git a/src/main/drymock/dry_mode_k8s_mock.go b/src/main/drymock/dry_mode_k8s_mock.go index eaa1f523a9..b959cef5c5 100644 --- a/src/main/drymock/dry_mode_k8s_mock.go +++ b/src/main/drymock/dry_mode_k8s_mock.go @@ -22,7 +22,7 @@ import ( func mockNodeList(mockk8sclient *k8s_client.MockK8SClient, clusterHosts config.DryClusterHosts, o ops.Ops) v1.NodeList { nodeListPopulated := v1.NodeList{} for _, clusterHost := range clusterHosts { - if !o.DryRebootHappened(clusterHost.RebootMarkerPath) { + if !o.FileExists(clusterHost.RebootMarkerPath) { // Host didn't even reboot yet, don't pretend it's a node continue } @@ -103,7 +103,7 @@ func PrepareControllerDryMock(mockk8sclient *k8s_client.MockK8SClient, logger *l mcsLogs := "" for _, clusterHost := range clusterHosts { // Add IP access log for each IP, this is how the controller determines which node has downloaded the ignition - if !o.DryRebootHappened(clusterHost.RebootMarkerPath) { + if !o.FileExists(clusterHost.RebootMarkerPath) { // Host didn't even reboot yet, don't pretend it fetched the ignition continue } diff --git a/src/ops/mock_ops.go b/src/ops/mock_ops.go index a742d549ce..7a7b26a317 100644 --- a/src/ops/mock_ops.go +++ b/src/ops/mock_ops.go @@ -82,18 +82,18 @@ func (mr *MockOpsMockRecorder) CreateRandomHostname(hostname any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateRandomHostname", reflect.TypeOf((*MockOps)(nil).CreateRandomHostname), hostname) } -// DryRebootHappened mocks base method. -func (m *MockOps) DryRebootHappened(markerPath string) bool { +// FileExists mocks base method. +func (m *MockOps) FileExists(markerPath string) bool { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DryRebootHappened", markerPath) + ret := m.ctrl.Call(m, "FileExists", markerPath) ret0, _ := ret[0].(bool) return ret0 } -// DryRebootHappened indicates an expected call of DryRebootHappened. -func (mr *MockOpsMockRecorder) DryRebootHappened(markerPath any) *gomock.Call { +// FileExists indicates an expected call of FileExists. +func (mr *MockOpsMockRecorder) FileExists(markerPath any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DryRebootHappened", reflect.TypeOf((*MockOps)(nil).DryRebootHappened), markerPath) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FileExists", reflect.TypeOf((*MockOps)(nil).FileExists), markerPath) } // EvaluateDiskSymlink mocks base method. diff --git a/src/ops/ops.go b/src/ops/ops.go index bfa4f2c266..d6657429d8 100644 --- a/src/ops/ops.go +++ b/src/ops/ops.go @@ -65,7 +65,7 @@ type Ops interface { EvaluateDiskSymlink(string) string FormatDisk(string) error CreateManifests(string, []byte) error - DryRebootHappened(markerPath string) bool + FileExists(markerPath string) bool ExecPrivilegeCommand(liveLogger io.Writer, command string, args ...string) (string, error) ReadFile(filePath string) ([]byte, error) GetEncapsulatedMC(ignitionPath string) (*mcfgv1.MachineConfig, error) @@ -431,7 +431,7 @@ func (o *ops) GetMCSLogs() (string, error) { mcsLogs := "" for _, clusterHost := range o.installerConfig.ParsedClusterHosts { // Add IP access log for each IP, this is how the installer determines which node has downloaded the ignition - if !o.DryRebootHappened(clusterHost.RebootMarkerPath) { + if !o.FileExists(clusterHost.RebootMarkerPath) { // Host didn't even reboot yet, don't pretend it fetched the ignition continue } @@ -645,11 +645,12 @@ func (o *ops) CreateManifests(kubeconfig string, content []byte) error { return nil } -// DryRebootHappened checks if a reboot happened according to a particular reboot marker path -// The dry run installer creates this file on "Reboot" (instead of actually rebooting) -// We use this function to check whether the given node in the cluster have already rebooted -func (o *ops) DryRebootHappened(markerPath string) bool { - _, err := o.ExecPrivilegeCommand(nil, "stat", markerPath) +// FileExists checks if a file exists. It's notably used to check if a +// dry reboot happened. The dry run installer creates the marker file on +// "Reboot" (instead of actually rebooting) We use this function to check +// whether the given node in the cluster have already rebooted +func (o *ops) FileExists(path string) bool { + _, err := o.ExecPrivilegeCommand(nil, "stat", path) return err == nil }