Skip to content

Commit 5fe8c4e

Browse files
committed
Restore envoyproxy status checks
Signed-off-by: Karol Szwaj <[email protected]>
1 parent 5cf95f4 commit 5fe8c4e

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

internal/provider/kubernetes/controller.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,9 @@ func (r *gatewayAPIReconciler) processParamsRef(ctx context.Context, gc *gwapiv1
14581458
return nil
14591459
}
14601460

1461+
found := false
1462+
valid := false
1463+
var validationErr error
14611464
for i := range epList.Items {
14621465
ep := epList.Items[i]
14631466
r.log.Info("processing envoyproxy", "namespace", ep.Namespace, "name", ep.Name)
@@ -1470,9 +1473,12 @@ func (r *gatewayAPIReconciler) processParamsRef(ctx context.Context, gc *gwapiv1
14701473
}
14711474
return nil
14721475
}
1476+
found = true
14731477
if err := validation.ValidateEnvoyProxy(&ep); err != nil {
1474-
return fmt.Errorf("invalid gatewayclass %s: %v", gc.Name, err)
1478+
validationErr = fmt.Errorf("invalid envoyproxy: %v", err)
1479+
continue
14751480
}
1481+
valid = true
14761482

14771483
if err := r.addFinalizer(ctx, &ep); err != nil {
14781484
r.log.Error(err, fmt.Sprintf("failed adding finalizer to envoy proxy %s",
@@ -1484,6 +1490,7 @@ func (r *gatewayAPIReconciler) processParamsRef(ctx context.Context, gc *gwapiv1
14841490
break
14851491
}
14861492

1493+
// Remove finalizer from EnvoyProxy when GatewayClass stops referencing it
14871494
if slice.ContainsString(ep.Finalizers, gatewayClassFinalizer) {
14881495
if err := r.removeFinalizer(ctx, &ep); err != nil {
14891496
r.log.Error(err, fmt.Sprintf("failed to remove finalizer from envoy proxy %s",
@@ -1494,6 +1501,14 @@ func (r *gatewayAPIReconciler) processParamsRef(ctx context.Context, gc *gwapiv1
14941501
}
14951502
}
14961503

1504+
if !found {
1505+
return fmt.Errorf("failed to find envoyproxy referenced by gatewayclass: %s", gc.Name)
1506+
}
1507+
1508+
if !valid {
1509+
return fmt.Errorf("invalid gatewayclass %s: %v", gc.Name, validationErr)
1510+
}
1511+
14971512
return nil
14981513
}
14991514

internal/provider/kubernetes/controller_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,30 @@ func TestProcessParamsRef(t *testing.T) {
496496
},
497497
expected: false,
498498
},
499+
{
500+
name: "referenced envoyproxy does not exist",
501+
gc: &gwapiv1b1.GatewayClass{
502+
ObjectMeta: metav1.ObjectMeta{
503+
Name: "test",
504+
},
505+
Spec: gwapiv1b1.GatewayClassSpec{
506+
ControllerName: gcCtrlName,
507+
ParametersRef: &gwapiv1b1.ParametersReference{
508+
Group: gwapiv1b1.Group(egcfgv1a1.GroupVersion.Group),
509+
Kind: gwapiv1b1.Kind(egcfgv1a1.KindEnvoyProxy),
510+
Name: "non-exist",
511+
Namespace: gatewayapi.NamespacePtr(config.DefaultNamespace),
512+
},
513+
},
514+
},
515+
ep: &egcfgv1a1.EnvoyProxy{
516+
ObjectMeta: metav1.ObjectMeta{
517+
Namespace: config.DefaultNamespace,
518+
Name: "test",
519+
},
520+
},
521+
expected: false,
522+
},
499523
{
500524
name: "invalid gatewayclass parameters ref",
501525
gc: &gwapiv1b1.GatewayClass{

0 commit comments

Comments
 (0)