diff --git a/api/v1beta1/conditions_const.go b/api/v1beta1/conditions_const.go index b39778778..b19642a93 100644 --- a/api/v1beta1/conditions_const.go +++ b/api/v1beta1/conditions_const.go @@ -200,6 +200,11 @@ const ( HostAssociateFailedReason = "HostAssociateFailed" ) +const ( + // DeletionInProgressReason indicates that a host is being deleted. + DeletionInProgressReason = "DeletionInProgress" +) + // deprecated conditions. const ( diff --git a/pkg/services/baremetal/host/host.go b/pkg/services/baremetal/host/host.go index 02943e328..dd4437b9b 100644 --- a/pkg/services/baremetal/host/host.go +++ b/pkg/services/baremetal/host/host.go @@ -96,6 +96,16 @@ func (s *Service) Reconcile(ctx context.Context) (result reconcile.Result, err e oldHost := s.scope.HetznerBareMetalHost.DeepCopy() + if !s.scope.HetznerBareMetalHost.DeletionTimestamp.IsZero() { + conditions.MarkFalse( + s.scope.HetznerBareMetalHost, + infrav1.HostReadyCondition, + infrav1.DeletionInProgressReason, + clusterv1.ConditionSeverityWarning, + "Host is not ready because it is being deleted", + ) + } + hostStateMachine := newHostStateMachine(s.scope.HetznerBareMetalHost, s, s.scope.Logger) defer func() { @@ -103,7 +113,6 @@ func (s *Service) Reconcile(ctx context.Context) (result reconcile.Result, err e conditions.Delete(s.scope.HetznerBareMetalHost, infrav1.DeprecatedHetznerBareMetalHostReadyCondition) conditions.Delete(s.scope.HetznerBareMetalHost, infrav1.DeprecatedHostProvisionSucceededCondition) conditions.Delete(s.scope.HetznerBareMetalHost, infrav1.DeprecatedRateLimitExceededCondition) - conditions.SetSummary(s.scope.HetznerBareMetalHost) // save host if it changed during reconciliation