Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱Add condition indicating deletion timestamp is set #1284

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/v1beta1/conditions_const.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ const (
HostAssociateFailedReason = "HostAssociateFailed"
)

const (
yrs147 marked this conversation as resolved.
Show resolved Hide resolved
// DeletionInProgressReason indicates that a host is being deleted.
DeletionInProgressReason = "DeletionInProgress"
)

// deprecated conditions.

const (
Expand Down
11 changes: 10 additions & 1 deletion pkg/services/baremetal/host/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,23 @@ 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() {
// 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