Skip to content

Commit fa40be2

Browse files
committed
feat: add Ready status condition to Server resource (fixes #359)
Signed-off-by: Simon Lauger <simon@lauger.de>
1 parent 4569b62 commit fa40be2

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

internal/controller/server_controller.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
networkingv1 "k8s.io/api/networking/v1"
1111
policyv1 "k8s.io/api/policy/v1"
1212
"k8s.io/apimachinery/pkg/api/errors"
13+
"k8s.io/apimachinery/pkg/api/meta"
1314
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1415
"k8s.io/apimachinery/pkg/runtime"
1516
"k8s.io/apimachinery/pkg/types"
@@ -152,8 +153,22 @@ func (r *ServerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
152153

153154
if ready > 0 {
154155
server.Status.Phase = openvoxv1alpha1.ServerPhaseRunning
156+
meta.SetStatusCondition(&server.Status.Conditions, metav1.Condition{
157+
Type: openvoxv1alpha1.ConditionServerReady,
158+
Status: metav1.ConditionTrue,
159+
Reason: "ReplicasReady",
160+
Message: fmt.Sprintf("%d/%d replicas ready", ready, replicas),
161+
LastTransitionTime: metav1.Now(),
162+
})
155163
} else {
156164
server.Status.Phase = openvoxv1alpha1.ServerPhasePending
165+
meta.SetStatusCondition(&server.Status.Conditions, metav1.Condition{
166+
Type: openvoxv1alpha1.ConditionServerReady,
167+
Status: metav1.ConditionFalse,
168+
Reason: "ReplicasNotReady",
169+
Message: fmt.Sprintf("0/%d replicas ready", replicas),
170+
LastTransitionTime: metav1.Now(),
171+
})
157172
}
158173
}); err != nil {
159174
return ctrl.Result{}, err

0 commit comments

Comments
 (0)