@@ -26,19 +26,41 @@ func (t *Translator) ProcessEnvoyPatchPolicies(envoyPatchPolicies []*egv1a1.Envo
2626 resolveErr * status.PolicyResolveError
2727 targetKind string
2828 irKey string
29+ gwXdsIR * ir.Xds
30+ ok bool
2931 )
3032
31- refKind , refName := policy .Spec .TargetRef .Kind , policy .Spec .TargetRef .Name
33+ refGroup , refKind , refName := policy . Spec . TargetRef . Group , policy .Spec .TargetRef .Kind , policy .Spec .TargetRef .Name
3234 if t .MergeGateways {
3335 targetKind = resource .KindGatewayClass
34- // if ref GatewayClass name is not same as t.GatewayClassName, it will be skipped in L53 .
36+ // if ref GatewayClass name is not same as t.GatewayClassName, it will be skipped in L74 .
3537 irKey = string (refName )
3638 ancestorRef = gwapiv1.ParentReference {
3739 Group : GroupPtr (gwapiv1 .GroupName ),
3840 Kind : KindPtr (targetKind ),
3941 Name : refName ,
4042 }
4143
44+ gwXdsIR , ok = xdsIR [irKey ]
45+ if ! ok {
46+ // The TargetRef GatewayClass is not an accepted GatewayClass, then skip processing.
47+ message := fmt .Sprintf (
48+ "TargetRef.Group:%s TargetRef.Kind:%s TargetRef.Namespace:%s TargetRef.Name:%s not found or not accepted (MergeGateways=%t)." ,
49+ refGroup , refKind , policy .Namespace , string (refName ), t .MergeGateways ,
50+ )
51+ resolveErr = & status.PolicyResolveError {
52+ Reason : gwapiv1 .PolicyReasonInvalid ,
53+ Message : message ,
54+ }
55+ status .SetResolveErrorForPolicyAncestor (& policy .Status ,
56+ & ancestorRef ,
57+ t .GatewayControllerName ,
58+ policy .Generation ,
59+ resolveErr ,
60+ )
61+ continue
62+ }
63+
4264 } else {
4365 targetKind = resource .KindGateway
4466 gatewayNN := types.NamespacedName {
@@ -47,12 +69,12 @@ func (t *Translator) ProcessEnvoyPatchPolicies(envoyPatchPolicies []*egv1a1.Envo
4769 }
4870 irKey = t .IRKey (gatewayNN )
4971 ancestorRef = getAncestorRefForPolicy (gatewayNN , nil )
50- }
5172
52- gwXdsIR , ok := xdsIR [irKey ]
53- if ! ok {
54- // The TargetRef Gateway is not an accepted Gateway, then skip processing.
55- continue
73+ gwXdsIR , ok = xdsIR [irKey ]
74+ if ! ok {
75+ // The TargetRef Gateway is not an accepted Gateway, then skip processing.
76+ continue
77+ }
5678 }
5779
5880 // Create the IR with the context need to publish the status later
@@ -82,9 +104,9 @@ func (t *Translator) ProcessEnvoyPatchPolicies(envoyPatchPolicies []*egv1a1.Envo
82104 }
83105
84106 // Ensure EnvoyPatchPolicy is targeting to a support type
85- if policy . Spec . TargetRef . Group != gwapiv1 .GroupName || string (refKind ) != targetKind {
107+ if refGroup != gwapiv1 .GroupName || string (refKind ) != targetKind {
86108 message := fmt .Sprintf ("TargetRef.Group:%s TargetRef.Kind:%s, only TargetRef.Group:%s and TargetRef.Kind:%s is supported." ,
87- policy . Spec . TargetRef . Group , policy .Spec .TargetRef .Kind , gwapiv1 .GroupName , targetKind )
109+ refGroup , policy .Spec .TargetRef .Kind , gwapiv1 .GroupName , targetKind )
88110
89111 resolveErr = & status.PolicyResolveError {
90112 Reason : gwapiv1 .PolicyReasonInvalid ,
0 commit comments