Skip to content

Commit dacf790

Browse files
authored
enable supported conformance test (#7291)
* enable supported conformance test Signed-off-by: zirain <[email protected]> * enable BackendTLSPolicyInvalidKind Signed-off-by: zirain <[email protected]> * fix lint Signed-off-by: zirain <[email protected]> * enable BackendTLSPolicyInvalidCACertificateRef Signed-off-by: zirain <[email protected]> * enable BackendTLSPolicySANValidation Signed-off-by: zirain <[email protected]> * BackendTLSPolicy Signed-off-by: zirain <[email protected]> * fix gen Signed-off-by: zirain <[email protected]> * BackendTLSPolicyObservedGenerationBump Signed-off-by: zirain <[email protected]> * nit Signed-off-by: zirain <[email protected]> * update Signed-off-by: zirain <[email protected]> * update Signed-off-by: zirain <[email protected]> * fix gen Signed-off-by: zirain <[email protected]> --------- Signed-off-by: zirain <[email protected]>
1 parent 67f9b5d commit dacf790

File tree

38 files changed

+539
-87
lines changed

38 files changed

+539
-87
lines changed

internal/cmd/egctl/testdata/translate/out/backend-endpoint.all.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ backendTLSPolicies:
1919
kind: Gateway
2020
name: eg
2121
conditions:
22+
- lastTransitionTime: null
23+
message: Resolved all the Object references.
24+
reason: ResolvedRefs
25+
status: "True"
26+
type: ResolvedRefs
2227
- lastTransitionTime: null
2328
message: Policy has been accepted.
2429
reason: Accepted

internal/gatewayapi/backendtlspolicy.go

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
package gatewayapi
77

88
import (
9+
"errors"
910
"fmt"
1011
"reflect"
1112

13+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1214
"k8s.io/apimachinery/pkg/types"
1315
"k8s.io/utils/ptr"
1416
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
@@ -19,6 +21,8 @@ import (
1921
"github.com/envoyproxy/gateway/internal/ir"
2022
)
2123

24+
var ErrBackendTLSPolicyInvalidKind = fmt.Errorf("no CA bundle found in referenced ConfigMap, Secret, or ClusterTrustBundle")
25+
2226
// ProcessBackendTLSPolicyStatus is called to post-process Backend TLS Policy status
2327
// after they were applied in all relevant translations.
2428
func (t *Translator) ProcessBackendTLSPolicyStatus(btlsp []*gwapiv1.BackendTLSPolicy) {
@@ -158,14 +162,42 @@ func (t *Translator) processBackendTLSPolicy(
158162
ancestorRefs = append(ancestorRefs, &parent)
159163

160164
if err != nil {
161-
status.SetTranslationErrorForPolicyAncestors(&policy.Status,
165+
status.SetConditionForPolicyAncestors(&policy.Status,
162166
ancestorRefs,
163167
t.GatewayControllerName,
168+
gwapiv1.PolicyConditionAccepted,
169+
metav1.ConditionFalse,
170+
gwapiv1.BackendTLSPolicyReasonNoValidCACertificate,
171+
status.Error2ConditionMsg(err),
164172
policy.Generation,
173+
)
174+
175+
reason := gwapiv1.BackendTLSPolicyReasonInvalidCACertificateRef
176+
if errors.Is(err, ErrBackendTLSPolicyInvalidKind) {
177+
reason = gwapiv1.BackendTLSPolicyReasonInvalidKind
178+
}
179+
180+
status.SetConditionForPolicyAncestors(&policy.Status,
181+
ancestorRefs,
182+
t.GatewayControllerName,
183+
gwapiv1.BackendTLSPolicyConditionResolvedRefs,
184+
metav1.ConditionFalse,
185+
reason,
165186
status.Error2ConditionMsg(err),
187+
policy.Generation,
166188
)
189+
167190
return nil, err
168191
}
192+
status.SetConditionForPolicyAncestors(&policy.Status,
193+
ancestorRefs,
194+
t.GatewayControllerName,
195+
gwapiv1.BackendTLSPolicyConditionResolvedRefs,
196+
metav1.ConditionTrue,
197+
gwapiv1.BackendTLSPolicyReasonResolvedRefs,
198+
"Resolved all the Object references.",
199+
policy.Generation,
200+
)
169201
status.SetAcceptedForPolicyAncestors(&policy.Status, ancestorRefs, t.GatewayControllerName, policy.Generation)
170202
return tlsBundle, nil
171203
}
@@ -345,7 +377,7 @@ func getCaCertsFromCARefs(namespace string, caCertificates []gwapiv1.LocalObject
345377
}
346378

347379
if ca == "" {
348-
return nil, fmt.Errorf("no ca found in referred ConfigMap or Secret")
380+
return nil, ErrBackendTLSPolicyInvalidKind
349381
}
350382
return []byte(ca), nil
351383
}

internal/gatewayapi/conformance/suite.go

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,20 @@ import (
1414

1515
// SkipTests is a list of tests that are skipped in the conformance suite.
1616
func SkipTests(gatewayNamespaceMode bool) []suite.ConformanceTest {
17-
if gatewayNamespaceMode {
18-
return []suite.ConformanceTest{
19-
tests.GatewayStaticAddresses,
20-
21-
tests.BackendTLSPolicyInvalidCACertificateRef,
22-
tests.BackendTLSPolicyInvalidKind,
23-
tests.BackendTLSPolicySANValidation,
24-
tests.BackendTLSPolicyConflictResolution,
25-
tests.BackendTLSPolicy,
26-
tests.BackendTLSPolicyObservedGenerationBump,
27-
tests.TLSRouteInvalidReferenceGrant,
28-
tests.TLSRouteSimpleSameNamespace,
29-
}
30-
}
31-
32-
return []suite.ConformanceTest{
17+
skipTests := []suite.ConformanceTest{
3318
tests.GatewayStaticAddresses,
34-
tests.GatewayInfrastructure,
3519

36-
tests.BackendTLSPolicyInvalidCACertificateRef,
37-
tests.BackendTLSPolicyInvalidKind,
38-
tests.BackendTLSPolicySANValidation,
20+
// TODO: fix me
3921
tests.BackendTLSPolicyConflictResolution,
40-
tests.BackendTLSPolicy,
41-
tests.BackendTLSPolicyObservedGenerationBump,
42-
tests.TLSRouteInvalidReferenceGrant,
43-
tests.TLSRouteSimpleSameNamespace,
4422
}
23+
24+
if gatewayNamespaceMode {
25+
return skipTests
26+
}
27+
28+
skipTests = append(skipTests, tests.GatewayInfrastructure)
29+
30+
return skipTests
4531
}
4632

4733
// SkipFeatures is a list of features that are skipped in the conformance report.

internal/gatewayapi/route.go

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,6 +1598,25 @@ func (t *Translator) processDestination(name string, backendRefContext BackendRe
15981598

15991599
protocol := inspectAppProtocolByRouteKind(routeType)
16001600

1601+
// Process BackendTLSPolicy first to ensure status is set.
1602+
tls, tlsErr := t.applyBackendTLSSetting(
1603+
backendRef.BackendObjectReference,
1604+
backendNamespace,
1605+
gwapiv1.ParentReference{
1606+
Group: parentRef.Group,
1607+
Kind: parentRef.Kind,
1608+
Namespace: parentRef.Namespace,
1609+
Name: parentRef.Name,
1610+
SectionName: parentRef.SectionName,
1611+
Port: parentRef.Port,
1612+
},
1613+
resources,
1614+
envoyProxy,
1615+
)
1616+
if tlsErr != nil {
1617+
return nil, nil, status.NewRouteStatusError(tlsErr, status.RouteReasonInvalidBackendTLS)
1618+
}
1619+
16011620
switch KindDerefOr(backendRef.Kind, resource.KindService) {
16021621
case resource.KindServiceImport:
16031622
ds, err = t.processServiceImportDestinationSetting(name, backendRef.BackendObjectReference, backendNamespace, protocol, resources, envoyProxy)
@@ -1612,7 +1631,6 @@ func (t *Translator) processDestination(name string, backendRefContext BackendRe
16121631
svc := resources.GetService(backendNamespace, string(backendRef.Name))
16131632
ds.IPFamily = getServiceIPFamily(svc)
16141633
ds.PreferLocal = processPreferLocalZone(svc)
1615-
16161634
case egv1a1.KindBackend:
16171635
ds = t.processBackendDestinationSetting(name, backendRef.BackendObjectReference, backendNamespace, protocol, resources)
16181636
default:
@@ -1640,24 +1658,7 @@ func (t *Translator) processDestination(name string, backendRefContext BackendRe
16401658
}
16411659
}
16421660

1643-
var tlsErr error
1644-
ds.TLS, tlsErr = t.applyBackendTLSSetting(
1645-
backendRef.BackendObjectReference,
1646-
backendNamespace,
1647-
gwapiv1.ParentReference{
1648-
Group: parentRef.Group,
1649-
Kind: parentRef.Kind,
1650-
Namespace: parentRef.Namespace,
1651-
Name: parentRef.Name,
1652-
SectionName: parentRef.SectionName,
1653-
Port: parentRef.Port,
1654-
},
1655-
resources,
1656-
envoyProxy,
1657-
)
1658-
if tlsErr != nil {
1659-
return nil, nil, status.NewRouteStatusError(tlsErr, status.RouteReasonInvalidBackendTLS)
1660-
}
1661+
ds.TLS = tls
16611662

16621663
var filtersErr error
16631664
ds.Filters, filtersErr = t.processDestinationFilters(routeType, backendRefContext, parentRef, route, resources)

internal/gatewayapi/testdata/backend-tls-settings-invalid.out.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ backendTLSPolicies:
2626
name: gateway-1
2727
namespace: envoy-gateway
2828
conditions:
29+
- lastTransitionTime: null
30+
message: Resolved all the Object references.
31+
reason: ResolvedRefs
32+
status: "True"
33+
type: ResolvedRefs
2934
- lastTransitionTime: null
3035
message: Policy has been accepted.
3136
reason: Accepted

internal/gatewayapi/testdata/backend-tls-settings.out.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ backendTLSPolicies:
2323
name: gateway-1
2424
namespace: envoy-gateway
2525
conditions:
26+
- lastTransitionTime: null
27+
message: Resolved all the Object references.
28+
reason: ResolvedRefs
29+
status: "True"
30+
type: ResolvedRefs
2631
- lastTransitionTime: null
2732
message: Policy has been accepted.
2833
reason: Accepted
@@ -48,6 +53,11 @@ backendTLSPolicies:
4853
name: gateway-1
4954
namespace: envoy-gateway
5055
conditions:
56+
- lastTransitionTime: null
57+
message: Resolved all the Object references.
58+
reason: ResolvedRefs
59+
status: "True"
60+
type: ResolvedRefs
5161
- lastTransitionTime: null
5262
message: Policy has been accepted.
5363
reason: Accepted
@@ -74,6 +84,11 @@ backendTLSPolicies:
7484
name: gateway-1
7585
namespace: envoy-gateway
7686
conditions:
87+
- lastTransitionTime: null
88+
message: Resolved all the Object references.
89+
reason: ResolvedRefs
90+
status: "True"
91+
type: ResolvedRefs
7792
- lastTransitionTime: null
7893
message: Policy has been accepted.
7994
reason: Accepted

internal/gatewayapi/testdata/backend-with-auto-san-sni.out.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ backendTLSPolicies:
3030
namespace: envoy-gateway
3131
sectionName: http
3232
conditions:
33+
- lastTransitionTime: null
34+
message: Resolved all the Object references.
35+
reason: ResolvedRefs
36+
status: "True"
37+
type: ResolvedRefs
3338
- lastTransitionTime: null
3439
message: Policy has been accepted.
3540
reason: Accepted

internal/gatewayapi/testdata/backend-with-skip-tls-verify.out.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ backendTLSPolicies:
2222
namespace: envoy-gateway
2323
sectionName: http
2424
conditions:
25+
- lastTransitionTime: null
26+
message: Resolved all the Object references.
27+
reason: ResolvedRefs
28+
status: "True"
29+
type: ResolvedRefs
2530
- lastTransitionTime: null
2631
message: Policy has been accepted.
2732
reason: Accepted

internal/gatewayapi/testdata/backendtlspolicy-ca-clustertrustbundle.out.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ backendTLSPolicies:
2323
namespace: envoy-gateway
2424
sectionName: http
2525
conditions:
26+
- lastTransitionTime: null
27+
message: Resolved all the Object references.
28+
reason: ResolvedRefs
29+
status: "True"
30+
type: ResolvedRefs
2631
- lastTransitionTime: null
2732
message: Policy has been accepted.
2833
reason: Accepted

internal/gatewayapi/testdata/backendtlspolicy-ca-only-secret.out.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ backendTLSPolicies:
2323
namespace: envoy-gateway
2424
sectionName: http
2525
conditions:
26+
- lastTransitionTime: null
27+
message: Resolved all the Object references.
28+
reason: ResolvedRefs
29+
status: "True"
30+
type: ResolvedRefs
2631
- lastTransitionTime: null
2732
message: Policy has been accepted.
2833
reason: Accepted

0 commit comments

Comments
 (0)