Skip to content

Commit

Permalink
Merge branch 'main' into helm-upgrade-tests-verify-dataplane-deployme…
Browse files Browse the repository at this point in the history
…nt-patch
  • Loading branch information
pmalek authored May 8, 2024
2 parents 0276d98 + b9f7515 commit fb2ba43
Show file tree
Hide file tree
Showing 9 changed files with 8,827 additions and 23 deletions.
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Builder
# ------------------------------------------------------------------------------

FROM --platform=$BUILDPLATFORM golang:1.22.2 as builder
FROM --platform=$BUILDPLATFORM golang:1.22.3 as builder

WORKDIR /workspace
ARG GOPATH
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,15 @@ check.rbacs: kic-role-generator
CONTROLLER_GEN_CRD_OPTIONS ?= "+crd:generateEmbeddedObjectMeta=true"
CONTROLLER_GEN_PATHS_RAW := ./pkg/utils/kubernetes/resources/clusterroles/ ./pkg/utils/kubernetes/reduce/ ./controller/... ./$(API_DIR)/...
CONTROLLER_GEN_PATHS := $(patsubst %,%;,$(strip $(CONTROLLER_GEN_PATHS_RAW)))
CONFIG_CRD_PATH = config/crd
CONFIG_CRD_BASE_PATH = $(CONFIG_CRD_PATH)/bases

.PHONY: manifests
manifests: controller-gen manifests.versions ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) paths="$(CONTROLLER_GEN_PATHS)" rbac:roleName=manager-role output:rbac:dir=config/rbac/role
$(CONTROLLER_GEN) paths="$(CONTROLLER_GEN_PATHS)" webhook
$(CONTROLLER_GEN) paths="$(CONTROLLER_GEN_PATHS)" $(CONTROLLER_GEN_CRD_OPTIONS) +output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) paths="$(CONTROLLER_GEN_PATHS)" $(CONTROLLER_GEN_CRD_OPTIONS) +output:crd:artifacts:config=$(CONFIG_CRD_BASE_PATH)
cp $(CONFIG_CRD_BASE_PATH)/gateway-operator.konghq.com_dataplanes.yaml $(CONFIG_CRD_PATH)/dataplane/

# manifests.versions ensures that image versions are set in the manifests according to the current version.
.PHONY: manifests.versions
Expand Down
8,797 changes: 8,797 additions & 0 deletions config/crd/dataplane/gateway-operator.konghq.com_dataplanes.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion config/crd/dataplane/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../bases/gateway-operator.konghq.com_dataplanes.yaml
- gateway-operator.konghq.com_dataplanes.yaml
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
2 changes: 1 addition & 1 deletion debug.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Debug image
# ------------------------------------------------------------------------------

FROM --platform=$BUILDPLATFORM golang:1.22.2 as debug
FROM --platform=$BUILDPLATFORM golang:1.22.3 as debug

ARG GOPATH
ARG GOCACHE
Expand Down

0 comments on commit fb2ba43

Please sign in to comment.