Skip to content

Commit bc84452

Browse files
committed
Adjust Host Lease phases so that it is not Ready until after its template is complete
1 parent c585d85 commit bc84452

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

internal/controller/hostlease_controller.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,13 @@ func (r *HostLeaseReconciler) handleUpdate(ctx context.Context, hostLease *v1alp
116116
return ctrl.Result{}, nil
117117
}
118118

119-
if hostLease.Status.Phase == "" {
120-
hostLease.Status.Phase = v1alpha1.HostLeasePhaseProgressing
121-
}
122-
123119
if !controllerutil.ContainsFinalizer(hostLease, hostLeaseFinalizer) {
124120
controllerutil.AddFinalizer(hostLease, hostLeaseFinalizer)
125121
if err := r.Update(ctx, hostLease); err != nil {
122+
hostLease.Status.Phase = v1alpha1.HostLeasePhaseFailed
126123
return ctrl.Result{}, err
127124
}
125+
hostLease.Status.Phase = v1alpha1.HostLeasePhaseProgressing
128126
return ctrl.Result{Requeue: true}, nil
129127
}
130128

@@ -136,6 +134,12 @@ func (r *HostLeaseReconciler) handleUpdate(ctx context.Context, hostLease *v1alp
136134
return result, provErr
137135
}
138136
if !result.IsZero() {
137+
if hostLease.Status.Phase != v1alpha1.HostLeasePhaseFailed {
138+
hostLease.Status.Phase = v1alpha1.HostLeasePhaseProgressing
139+
}
140+
return result, nil
141+
}
142+
if hostLease.Status.Phase == v1alpha1.HostLeasePhaseFailed {
139143
return result, nil
140144
}
141145
}
@@ -167,6 +171,7 @@ func (r *HostLeaseReconciler) handleUpdate(ctx context.Context, hostLease *v1alp
167171
if hostLease.Spec.PoweredOn != nil {
168172
currentlyOn := node.PowerState == ironic.PowerOn.String()
169173
if *hostLease.Spec.PoweredOn != currentlyOn {
174+
hostLease.Status.Phase = v1alpha1.HostLeasePhaseProgressing
170175
return ctrl.Result{RequeueAfter: r.RecheckInterval}, nil
171176
}
172177
}

0 commit comments

Comments
 (0)