Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ metadata:
categories: Integration & Delivery
console.openshift.io/plugins: '["kuadrant-console-plugin"]'
containerImage: quay.io/kuadrant/kuadrant-operator:latest
createdAt: "2026-05-25T14:07:27Z"
createdAt: "2026-06-22T15:16:38Z"
description: A Kubernetes Operator to manage the lifecycle of the Kuadrant system
operators.operatorframework.io/builder: operator-sdk-v1.33.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v4
Expand Down Expand Up @@ -502,6 +502,12 @@ spec:
- patch
- update
- watch
- apiGroups:
- extensions.istio.io
resources:
- wasmplugins
verbs:
- delete
- apiGroups:
- extensions.kuadrant.io
resources:
Expand Down
6 changes: 6 additions & 0 deletions charts/kuadrant-operator/templates/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14346,6 +14346,12 @@ rules:
- patch
- update
- watch
- apiGroups:
- extensions.istio.io
resources:
- wasmplugins
verbs:
- delete
- apiGroups:
- extensions.kuadrant.io
resources:
Expand Down
6 changes: 6 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ rules:
- patch
- update
- watch
- apiGroups:
- extensions.istio.io
resources:
- wasmplugins
verbs:
- delete
- apiGroups:
- extensions.kuadrant.io
resources:
Expand Down
19 changes: 15 additions & 4 deletions internal/controller/istio_extension_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
istioapinetworkingv1alpha3 "istio.io/api/networking/v1alpha3"
istiov1beta1 "istio.io/api/type/v1beta1"
istioclientgonetworkingv1alpha3 "istio.io/client-go/pkg/apis/networking/v1alpha3"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
k8stypes "k8s.io/apimachinery/pkg/types"
Expand All @@ -35,6 +36,7 @@ import (
"github.com/kuadrant/kuadrant-operator/internal/wasm"
)

//+kubebuilder:rbac:groups=extensions.istio.io,resources=wasmplugins,verbs=delete
//+kubebuilder:rbac:groups=networking.istio.io,resources=envoyfilters,verbs=get;list;watch;create;update;patch;delete

// IstioExtensionReconciler reconciles Istio EnvoyFilter custom resources for wasm plugin injection
Expand Down Expand Up @@ -95,6 +97,7 @@ func (r *IstioExtensionReconciler) Reconcile(ctx context.Context, _ []controller
}

modifiedGateways := make([]string, 0, len(gateways))
var reconcileErr error

for _, gateway := range gateways {
gatewayKey := k8stypes.NamespacedName{Name: gateway.GetName(), Namespace: gateway.GetNamespace()}
Expand Down Expand Up @@ -122,22 +125,30 @@ func (r *IstioExtensionReconciler) Reconcile(ctx context.Context, _ []controller
desiredEnvoyFilterUnstructured, err := controller.Destruct(desiredEnvoyFilter)
if err != nil {
logger.Error(err, "failed to destruct envoyfilter object", "gateway", gatewayKey.String(), "envoyfilter", desiredEnvoyFilter)
reconcileErr = errors.Join(reconcileErr, fmt.Errorf("failed to destruct envoyfilter %s/%s: %w", gateway.GetNamespace(), desiredEnvoyFilter.GetName(), err))
continue
}
if _, err = resource.Create(ctx, desiredEnvoyFilterUnstructured, metav1.CreateOptions{}); err != nil {
logger.Error(err, "failed to create envoyfilter object", "gateway", gatewayKey.String(), "envoyfilter", desiredEnvoyFilterUnstructured.Object)
// TODO: handle error
reconcileErr = errors.Join(reconcileErr, fmt.Errorf("failed to create envoyfilter %s/%s: %w", gateway.GetNamespace(), desiredEnvoyFilter.GetName(), err))
}
continue
}

// Clean up old WasmPlugin for this specific gateway - temporary to be removed
wasmPluginName := wasm.ExtensionName(gateway.GetName())
if err := r.client.Resource(kuadrantistio.WasmPluginsResource).Namespace(gateway.GetNamespace()).Delete(ctx, wasmPluginName, metav1.DeleteOptions{}); err != nil && !apierrors.IsNotFound(err) {
logger.Error(err, "failed to delete wasmplugin", "gateway", gatewayKey.String(), "wasmplugin", wasmPluginName)
reconcileErr = errors.Join(reconcileErr, fmt.Errorf("failed to delete wasmplugin %s/%s: %w", gateway.GetNamespace(), wasmPluginName, err))
Comment thread
adam-cattermole marked this conversation as resolved.
}

existingEnvoyFilter := existingEnvoyFilterObj.(*controller.RuntimeObject).Object.(*istioclientgonetworkingv1alpha3.EnvoyFilter)

// delete
if utils.IsObjectTaggedToDelete(desiredEnvoyFilter) && !utils.IsObjectTaggedToDelete(existingEnvoyFilter) {
if err := resource.Delete(ctx, existingEnvoyFilter.GetName(), metav1.DeleteOptions{}); err != nil {
logger.Error(err, "failed to delete envoyfilter object", "gateway", gatewayKey.String(), "envoyfilter", fmt.Sprintf("%s/%s", existingEnvoyFilter.GetNamespace(), existingEnvoyFilter.GetName()))
// TODO: handle error
reconcileErr = errors.Join(reconcileErr, fmt.Errorf("failed to delete envoyfilter %s/%s: %w", existingEnvoyFilter.GetNamespace(), existingEnvoyFilter.GetName(), err))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly worried about the proliferation of this pattern in the STOW reconciliation workflow. Failing the entire workflow because one task returned an error won't automatically trigger a retry as one coming from a controller-runtime background would expect.

I sincerely believe we should give #2043 some attention.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recalled seeing that PR but that's my mistake for not investigating what it was doing before returning the error here. What would you advise to proceed here - a follow up removing the errors or leaving as is for the imminent patch release?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the error handling is not required for the patch which is more about deleting the WasmPlugin leftovers, right? I would rollback ed89ee9.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, luckily I kept the changes separate here so here's a follow up to revert that commit only #2067

}
continue
}
Expand All @@ -159,13 +170,13 @@ func (r *IstioExtensionReconciler) Reconcile(ctx context.Context, _ []controller
}
if _, err = resource.Update(ctx, existingEnvoyFilterUnstructured, metav1.UpdateOptions{}); err != nil {
logger.Error(err, "failed to update envoyfilter object", "gateway", gatewayKey.String(), "envoyfilter", existingEnvoyFilterUnstructured.Object)
// TODO: handle error
reconcileErr = errors.Join(reconcileErr, fmt.Errorf("failed to update envoyfilter %s/%s: %w", existingEnvoyFilter.GetNamespace(), existingEnvoyFilter.GetName(), err))
}
}

state.Store(StateIstioExtensionsModified, modifiedGateways)

return nil
return reconcileErr
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}

func (r *IstioExtensionReconciler) reconcileUpstreamClusters(ctx context.Context, topology *machinery.Topology, gateways []*machinery.Gateway) {
Expand Down
Loading