Skip to content

Commit e08b791

Browse files
🌱 Ignore missing rescue flag in Robot server response (#1926)
Ignore missing Robot rescue flag Co-authored-by: Dhairya Arora <dhairya.arora@syself.com>
1 parent 24f77fc commit e08b791

2 files changed

Lines changed: 47 additions & 16 deletions

File tree

pkg/services/baremetal/host/host.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -218,22 +218,6 @@ func (s *Service) actionPreparing(ctx context.Context) actionResult {
218218
s.scope.HetznerBareMetalHost.Spec.Status.RebootTypes = rebootTypes
219219
}
220220

221-
// if there is no rescue system, we cannot provision the server
222-
if !server.Rescue {
223-
errMsg := fmt.Sprintf("bm server %v has no rescue system", server.ServerNumber)
224-
conditions.MarkFalse(
225-
s.scope.HetznerBareMetalHost,
226-
infrav1.ProvisionSucceededCondition,
227-
infrav1.RescueSystemUnavailableReason,
228-
clusterv1.ConditionSeverityError,
229-
"%s",
230-
errMsg,
231-
)
232-
record.Warnf(s.scope.HetznerBareMetalHost, "NoRescueSystemAvailable", errMsg)
233-
s.scope.HetznerBareMetalHost.SetError(infrav1.PermanentError, errMsg)
234-
return actionStop{}
235-
}
236-
237221
if err := s.enforceRescueMode(); err != nil {
238222
return actionError{err: fmt.Errorf("failed to enforce rescue mode: %w", err)}
239223
}

pkg/services/baremetal/host/host_test.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,53 @@ var _ = Describe("ensureSSHKey", func() {
720720
)
721721
})
722722

723+
var _ = Describe("actionPreparing", func() {
724+
It("continues when Robot omits rescue availability from the server response", func() {
725+
host := helpers.BareMetalHost(
726+
"test-host",
727+
"default",
728+
helpers.WithSSHSpecInclPorts(22, 22),
729+
)
730+
731+
robotMock := robotmock.Client{}
732+
robotMock.On("GetBMServer", mock.Anything).Return(&models.Server{
733+
ServerNumber: 1,
734+
ServerIP: "1.2.3.4",
735+
ServerIPv6Net: "2a01:4f9:3051:12ce::",
736+
Rescue: false,
737+
}, nil)
738+
robotMock.On("ListSSHKeys").Return([]models.Key{}, nil)
739+
robotMock.On("SetSSHKey", mock.Anything, mock.Anything).Return(
740+
&models.Key{Name: rescueSSHKeyName, Fingerprint: sshFingerprint},
741+
nil,
742+
)
743+
robotMock.On("GetReboot", mock.Anything).Return(&models.Reset{Type: []string{"sw", "hw"}}, nil)
744+
robotMock.On("DeleteBootRescue", mock.Anything).Return(&models.Rescue{Active: false}, nil)
745+
robotMock.On("SetBootRescue", mock.Anything, sshFingerprint).Return(&models.Rescue{Active: true}, nil)
746+
robotMock.On("RebootBMServer", mock.Anything, infrav1.RebootTypeSoftware).Return(&models.ResetPost{}, nil)
747+
748+
sshMock := &sshmock.Client{}
749+
sshMock.On("GetHostName").Return(sshclient.Output{})
750+
751+
service := newTestService(
752+
host,
753+
&robotMock,
754+
bmmock.NewSSHFactory(sshMock, sshMock, sshMock),
755+
helpers.GetDefaultSSHSecret(osSSHKeyName, "default"),
756+
helpers.GetDefaultSSHSecret(rescueSSHKeyName, "default"),
757+
)
758+
759+
actResult := service.actionPreparing(context.Background())
760+
761+
Expect(actResult).To(BeAssignableToTypeOf(actionComplete{}))
762+
Expect(host.Spec.Status.ErrorType).To(Equal(infrav1.ErrorTypeSoftwareRebootTriggered))
763+
Expect(host.Spec.Status.IPv4).To(Equal("1.2.3.4"))
764+
Expect(host.Spec.Status.IPv6).To(Equal("2a01:4f9:3051:12ce::1"))
765+
Expect(robotMock.AssertCalled(GinkgoT(), "DeleteBootRescue", mock.Anything)).To(BeTrue())
766+
Expect(robotMock.AssertCalled(GinkgoT(), "SetBootRescue", mock.Anything, sshFingerprint)).To(BeTrue())
767+
})
768+
})
769+
723770
var _ = Describe("analyzeSSHOutputInstallImage", func() {
724771
type testCaseAnalyzeSSHOutputInstallImageOutErr struct {
725772
err error

0 commit comments

Comments
 (0)