Skip to content

Commit

Permalink
fix(gatewayapi): correct ListenerReason for unresolved certificate re…
Browse files Browse the repository at this point in the history
…fs, enable ReferenceGrant conformance tests

Signed-off-by: Mike Beaumont <mjboamail@gmail.com>
  • Loading branch information
michaelbeaumont committed Aug 11, 2022
1 parent 308f420 commit d18f89f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func (r *GatewayReconciler) gapiToKumaGateway(
listener.Hostname = string(*l.Hostname)
}

var unresolvableRefs []string
var unresolvableCertRefs []string
if l.TLS != nil {
for _, certRef := range l.TLS.CertificateRefs {
policyRef := policy.PolicyReferenceSecret(policy.FromGatewayIn(gateway.Namespace), certRef)
Expand All @@ -222,11 +222,11 @@ func (r *GatewayReconciler) gapiToKumaGateway(

if !permitted {
message := fmt.Sprintf("%q %q", policyRef.GroupKindReferredTo().String(), policyRef.NamespacedNameReferredTo().String())
unresolvableRefs = append(unresolvableRefs, message)
unresolvableCertRefs = append(unresolvableCertRefs, message)
}
}

if len(unresolvableRefs) == 0 {
if len(unresolvableCertRefs) == 0 {
if l.TLS.Mode != nil && *l.TLS.Mode == gatewayapi.TLSModePassthrough {
continue // todo admission webhook should prevent this
}
Expand Down Expand Up @@ -272,7 +272,7 @@ func (r *GatewayReconciler) gapiToKumaGateway(

var resolvedRefConditions []kube_meta.Condition

if len(unresolvableRefs) == 0 {
if len(unresolvableCertRefs) == 0 {
listeners = append(listeners, listener)

resolvedRefConditions = []kube_meta.Condition{
Expand All @@ -292,8 +292,8 @@ func (r *GatewayReconciler) gapiToKumaGateway(
{
Type: string(gatewayapi.ListenerConditionResolvedRefs),
Status: kube_meta.ConditionFalse,
Reason: string(gatewayapi.ListenerReasonRefNotPermitted),
Message: fmt.Sprintf("references to %s not permitted by any ReferencePolicy", strings.Join(unresolvableRefs, ", ")),
Reason: string(gatewayapi.ListenerReasonInvalidCertificateRef),
Message: fmt.Sprintf("references to %s not permitted by any ReferencePolicy", strings.Join(unresolvableCertRefs, ", ")),
},
{
Type: string(gatewayapi.ListenerConditionReady),
Expand Down
8 changes: 6 additions & 2 deletions test/e2e/gateway/gatewayapi/conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ func TestConformance(t *testing.T) {
metadata.KumaSidecarInjectionAnnotation: metadata.AnnotationTrue,
},
ValidUniqueListenerPorts: validUniqueListenerPorts,
SupportedFeatures: []suite.SupportedFeature{
suite.SupportReferenceGrant,
},
})

conformanceSuite.Setup(t)
Expand All @@ -88,9 +91,10 @@ func TestConformance(t *testing.T) {
for _, test := range tests.ConformanceTests {
switch test.ShortName {
case tests.HTTPRouteDisallowedKind.ShortName, // TODO: we only support HTTPRoute so it's not yet possible to test this
tests.HTTPRouteInvalidCrossNamespaceBackendRef.ShortName,
tests.HTTPRouteInvalidCrossNamespaceBackendRef.ShortName, // The following fail due to #4597
tests.HTTPRouteInvalidBackendRefUnknownKind.ShortName,
tests.HTTPRouteInvalidNonExistentBackendRef.ShortName:
tests.HTTPRouteInvalidNonExistentBackendRef.ShortName,
tests.HTTPRouteInvalidReferenceGrant.ShortName:
continue
}
passingTests = append(passingTests, test)
Expand Down

0 comments on commit d18f89f

Please sign in to comment.