Skip to content

Commit

Permalink
🌱Minor change
Browse files Browse the repository at this point in the history
  • Loading branch information
yrs147 committed May 21, 2024
1 parent 6f186d1 commit 3af97a6
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions pkg/services/baremetal/host/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,41 +91,27 @@ func NewService(s *scope.BareMetalHostScope) *Service {

// Reconcile implements reconcilement of HetznerBareMetalHosts.
func (s *Service) Reconcile(ctx context.Context) (result reconcile.Result, err error) {
// Fetch the Hetzner bare metal host instance.
bmHost := &infrav1.HetznerBareMetalHost{}
err = s.scope.Client.Get(ctx, client.ObjectKey{
Namespace: s.scope.HetznerBareMetalHost.Namespace,
Name: s.scope.HetznerBareMetalHost.Name,
}, bmHost)
if err != nil {
if apierrors.IsNotFound(err) {
return reconcile.Result{}, nil
}
return reconcile.Result{}, fmt.Errorf("failed to get HetznerBareMetalHost : %w", err)
}
if !bmHost.DeletionTimestamp.IsZero() {
initialState := s.scope.HetznerBareMetalHost.Spec.Status.ProvisioningState

oldHost := s.scope.HetznerBareMetalHost.DeepCopy()

if !s.scope.HetznerBareMetalHost.DeletionTimestamp.IsZero() {
conditions.MarkFalse(
bmHost,
s.scope.HetznerBareMetalHost,
infrav1.HostReadyCondition,
infrav1.DeletionInProgressReason,
clusterv1.ConditionSeverityInfo,
"Host is not ready because it is being deleted",
)
conditions.SetSummary(bmHost)
}

initialState := s.scope.HetznerBareMetalHost.Spec.Status.ProvisioningState

oldHost := s.scope.HetznerBareMetalHost.DeepCopy()

hostStateMachine := newHostStateMachine(s.scope.HetznerBareMetalHost, s, s.scope.Logger)

defer func() {
// remove deprecated conditions
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
Expand Down

0 comments on commit 3af97a6

Please sign in to comment.