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

chore: remove Gateway's Ready status condition #246

Merged
merged 2 commits into from
May 8, 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
`apis` -> `api` and `controllers` -> `controller`.
[#84](https://github.com/Kong/gateway-operator/pull/84)

### Changes

- `Gateway` do not have their `Ready` status condition set anymore.
This aligns with Gateway API and its conformance test suite.
[#246](https://github.com/Kong/gateway-operator/pull/246)

### Fixes

- Fix enforcing up to date `ControlPlane`'s `ValidatingWebhookConfiguration`
Expand Down
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
Loading