Skip to content

Commit 4ab60bc

Browse files
committed
Migrate ready.Controller to SSA status updates; remove PatchHypervisorStatusWithRetry
Replace the last caller of PatchHypervisorStatusWithRetry with Status().Apply() for ConditionTypeReady. With no remaining callers, PatchHypervisorStatusWithRetry and StatusPatchBackoff are removed.
1 parent 8edf548 commit 4ab60bc

2 files changed

Lines changed: 13 additions & 65 deletions

File tree

internal/controller/ready/controller.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"k8s.io/apimachinery/pkg/api/meta"
2525
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2626
"k8s.io/apimachinery/pkg/runtime"
27+
k8sacmetav1 "k8s.io/client-go/applyconfigurations/meta/v1"
2728
ctrl "sigs.k8s.io/controller-runtime"
2829
"sigs.k8s.io/controller-runtime/pkg/builder"
2930
k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
@@ -32,6 +33,7 @@ import (
3233
"sigs.k8s.io/controller-runtime/pkg/predicate"
3334

3435
kvmv1 "github.com/cobaltcore-dev/openstack-hypervisor-operator/api/v1"
36+
apiv1 "github.com/cobaltcore-dev/openstack-hypervisor-operator/applyconfigurations/api/v1"
3537
"github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/utils"
3638
)
3739

@@ -104,20 +106,21 @@ func (r *Controller) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
104106
return ctrl.Result{}, k8sclient.IgnoreNotFound(err)
105107
}
106108

107-
base := hv.DeepCopy()
108-
109109
// Compute Ready condition based on other conditions
110110
readyCondition := ComputeReadyCondition(hv)
111-
meta.SetStatusCondition(&hv.Status.Conditions, readyCondition)
112-
113-
if equality.Semantic.DeepEqual(hv.Status, base.Status) {
114-
return ctrl.Result{}, nil
115-
}
116111

117112
log.Info("Updating Ready condition", "status", readyCondition.Status, "reason", readyCondition.Reason)
118-
return ctrl.Result{}, utils.PatchHypervisorStatusWithRetry(ctx, r.Client, req.Name, ControllerName, func(h *kvmv1.Hypervisor) {
119-
meta.SetStatusCondition(&h.Status.Conditions, readyCondition)
120-
})
113+
statusCfg := apiv1.HypervisorStatus()
114+
statusCfg.Conditions = utils.ConditionsFromStatus(hv.Status.Conditions)
115+
utils.SetApplyConfigurationStatusCondition(&statusCfg.Conditions,
116+
*k8sacmetav1.Condition().
117+
WithType(readyCondition.Type).
118+
WithStatus(readyCondition.Status).
119+
WithReason(readyCondition.Reason).
120+
WithMessage(readyCondition.Message))
121+
return ctrl.Result{}, r.Status().Apply(ctx,
122+
apiv1.Hypervisor(hv.Name, "").WithStatus(statusCfg),
123+
k8sclient.ForceOwnership, k8sclient.FieldOwner(ControllerName))
121124
}
122125

123126
// ComputeReadyCondition determines the Ready condition based on other conditions

internal/utils/status_patch.go

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)