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

fix(gatewayapi): ListenerReason for unresolved certificate refs, enable ReferenceGrant conformance tests #4806

Merged
merged 2 commits into from
Aug 12, 2022
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 @@ -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
6 changes: 4 additions & 2 deletions test/e2e/gateway/gatewayapi/conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func TestConformance(t *testing.T) {
ValidUniqueListenerPorts: validUniqueListenerPorts,
SupportedFeatures: []suite.SupportedFeature{
suite.SupportHTTPRouteQueryParamMatching,
suite.SupportReferenceGrant,
},
})

Expand All @@ -100,9 +101,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