Skip to content

Commit

Permalink
chore: remove Gateway's Ready status condition
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalek committed May 8, 2024
1 parent e8844dd commit 453ad11
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
4 changes: 2 additions & 2 deletions controller/gateway/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
gwConditionAware.initListenersStatus()
gwConditionAware.setConflicted()
gwConditionAware.setAccepted()
gwConditionAware.initReadyAndProgrammed()
gwConditionAware.initProgrammedAndListenersStatus()
if err := gwConditionAware.setResolvedRefsAndSupportedKinds(ctx, r.Client); err != nil {
return ctrl.Result{}, err
}
Expand Down Expand Up @@ -340,7 +340,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
gatewayConditionsAndListenersAware(&gateway))
}

gwConditionAware.setReadyAndProgrammed()
gwConditionAware.setProgrammedAndListenersConditions()
res, err := patch.ApplyGatewayStatusPatchIfNotEmpty(ctx, r.Client, logger, &gateway, oldGateway)
if err != nil {
return ctrl.Result{}, err
Expand Down
22 changes: 10 additions & 12 deletions controller/gateway/controller_reconciler_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,12 +535,11 @@ func supportedRoutesByProtocol() map[gatewayv1.ProtocolType]map[gatewayv1.Kind]s
}
}

// initReadyAndProgrammed initializes the gateway Programmed and Ready conditions
// by setting the underlying Gateway Programmed and Ready status to false.
// Furthermore, it sets the supportedKinds and initializes the readiness to false with reason
// Pending for each Gateway listener.
func (g *gatewayConditionsAndListenersAwareT) initReadyAndProgrammed() {
k8sutils.InitReady(g)
// initProgrammedAndListenersStatus initializes the gateway Programmed condition
// by setting the underlying Gateway Programmed status to false.
// It also sets the listeners Programmed condition by setting the underlying
// Listener Programmed status to false.
func (g *gatewayConditionsAndListenersAwareT) initProgrammedAndListenersStatus() {
k8sutils.InitProgrammed(g)
for i := range g.Spec.Listeners {
lStatus := listenerConditionsAware(&g.Status.Listeners[i])
Expand Down Expand Up @@ -634,12 +633,11 @@ func (g *gatewayConditionsAndListenersAwareT) setConflicted() {
}
}

// setReadyAndProgrammed sets the gateway Programmed and Ready conditions by
// setting the underlying Gateway Programmed and Ready status to true.
// Furthermore, it sets the supportedKinds and initializes the readiness to true with reason
// Ready or false with reason Invalid for each Gateway listener.
func (g *gatewayConditionsAndListenersAwareT) setReadyAndProgrammed() {
k8sutils.SetReady(g)
// setProgrammedAndListenersConditions sets the gateway Programmed condition by setting the underlying
// Gateway Programmed status to true.
// It also sets the listeners Programmed condition by setting the underlying
// Listener Programmed status to true.
func (g *gatewayConditionsAndListenersAwareT) setProgrammedAndListenersConditions() {
k8sutils.SetProgrammed(g)

for i := range g.Spec.Listeners {
Expand Down
10 changes: 5 additions & 5 deletions controller/gateway/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func TestGatewayReconciler_Reconcile(t *testing.T) {

var currentGateway gwtypes.Gateway
require.NoError(t, reconciler.Client.Get(ctx, gatewayReq.NamespacedName, &currentGateway))
require.False(t, k8sutils.IsReady(gatewayConditionsAndListenersAware(&currentGateway)))
require.False(t, k8sutils.IsProgrammed(gatewayConditionsAndListenersAware(&currentGateway)))
condition, found := k8sutils.GetCondition(GatewayServiceType, gatewayConditionsAndListenersAware(&currentGateway))
require.True(t, found)
require.Equal(t, condition.Status, metav1.ConditionFalse)
Expand All @@ -200,7 +200,7 @@ func TestGatewayReconciler_Reconcile(t *testing.T) {
require.NoError(t, err, "reconciliation returned an error")
// the dataplane service now has a clusterIP assigned, the gateway must be ready
require.NoError(t, reconciler.Client.Get(ctx, gatewayReq.NamespacedName, &currentGateway))
require.True(t, k8sutils.IsReady(gatewayConditionsAndListenersAware(&currentGateway)))
require.True(t, k8sutils.IsProgrammed(gatewayConditionsAndListenersAware(&currentGateway)))
condition, found = k8sutils.GetCondition(GatewayServiceType, gatewayConditionsAndListenersAware(&currentGateway))
require.True(t, found)
require.Equal(t, condition.Status, metav1.ConditionTrue)
Expand Down Expand Up @@ -234,7 +234,7 @@ func TestGatewayReconciler_Reconcile(t *testing.T) {
_, err = reconciler.Reconcile(ctx, gatewayReq)
require.NoError(t, err, "reconciliation returned an error")
require.NoError(t, reconciler.Client.Get(ctx, gatewayReq.NamespacedName, &currentGateway))
require.True(t, k8sutils.IsReady(gatewayConditionsAndListenersAware(&currentGateway)))
require.True(t, k8sutils.IsProgrammed(gatewayConditionsAndListenersAware(&currentGateway)))
condition, found = k8sutils.GetCondition(GatewayServiceType, gatewayConditionsAndListenersAware(&currentGateway))
require.True(t, found)
require.Equal(t, condition.Status, metav1.ConditionTrue)
Expand Down Expand Up @@ -267,7 +267,7 @@ func TestGatewayReconciler_Reconcile(t *testing.T) {
_, err = reconciler.Reconcile(ctx, gatewayReq)
require.NoError(t, err, "reconciliation returned an error")
require.NoError(t, reconciler.Client.Get(ctx, gatewayReq.NamespacedName, &currentGateway))
require.True(t, k8sutils.IsReady(gatewayConditionsAndListenersAware(&currentGateway)))
require.True(t, k8sutils.IsProgrammed(gatewayConditionsAndListenersAware(&currentGateway)))
condition, found = k8sutils.GetCondition(GatewayServiceType, gatewayConditionsAndListenersAware(&currentGateway))
require.True(t, found)
require.Equal(t, condition.Status, metav1.ConditionTrue)
Expand All @@ -289,7 +289,7 @@ func TestGatewayReconciler_Reconcile(t *testing.T) {
require.NoError(t, reconciler.Client.Get(ctx, gatewayReq.NamespacedName, &currentGateway))
// the dataplane service has no clusterIP assigned, the gateway must be not ready
// and no addresses must be assigned
require.False(t, k8sutils.IsReady(gatewayConditionsAndListenersAware(&currentGateway)))
require.False(t, k8sutils.IsProgrammed(gatewayConditionsAndListenersAware(&currentGateway)))
condition, found = k8sutils.GetCondition(GatewayServiceType, gatewayConditionsAndListenersAware(&currentGateway))
require.True(t, found)
require.Equal(t, condition.Status, metav1.ConditionFalse)
Expand Down

0 comments on commit 453ad11

Please sign in to comment.