diff --git a/internal/gatewayapi/backendtrafficpolicy.go b/internal/gatewayapi/backendtrafficpolicy.go index 6babdfa81d8..41cb02ce112 100644 --- a/internal/gatewayapi/backendtrafficpolicy.go +++ b/internal/gatewayapi/backendtrafficpolicy.go @@ -247,7 +247,8 @@ func resolveBTPolicyGatewayTargetRef(policy *egv1a1.BackendTrafficPolicy, target // Check if another policy targeting the same Gateway exists if gateway.attached { - message := "Unable to target Gateway, another BackendTrafficPolicy has already attached to it" + message := fmt.Sprintf("Unable to target Gateway %s, another BackendTrafficPolicy has already attached to it", + string(target.Name)) return gateway.GatewayContext, &status.PolicyResolveError{ Reason: gwapiv1a2.PolicyReasonConflicted, @@ -291,8 +292,8 @@ func resolveBTPolicyRouteTargetRef(policy *egv1a1.BackendTrafficPolicy, target g // Check if another policy targeting the same xRoute exists if route.attached { - message := fmt.Sprintf("Unable to target %s, another BackendTrafficPolicy has already attached to it", - string(target.Kind)) + message := fmt.Sprintf("Unable to target %s %s, another BackendTrafficPolicy has already attached to it", + string(target.Kind), string(target.Name)) return route.RouteContext, &status.PolicyResolveError{ Reason: gwapiv1a2.PolicyReasonConflicted, diff --git a/internal/gatewayapi/clienttrafficpolicy.go b/internal/gatewayapi/clienttrafficpolicy.go index 7a25a661334..e7e91dbcade 100644 --- a/internal/gatewayapi/clienttrafficpolicy.go +++ b/internal/gatewayapi/clienttrafficpolicy.go @@ -110,7 +110,8 @@ func (t *Translator) ProcessClientTrafficPolicies( section := string(*(currTarget.SectionName)) s, ok := policyMap[key] if ok && s.Has(section) { - message := "Unable to target section, another ClientTrafficPolicy has already attached to it" + message := fmt.Sprintf("Unable to target section of %s, another ClientTrafficPolicy has already attached to it", + string(currTarget.Name)) resolveErr = &status.PolicyResolveError{ Reason: gwapiv1a2.PolicyReasonConflicted, @@ -206,7 +207,8 @@ func (t *Translator) ProcessClientTrafficPolicies( // Check if another policy targeting the same Gateway exists s, ok := policyMap[key] if ok && s.Has(AllSections) { - message := "Unable to target Gateway, another ClientTrafficPolicy has already attached to it" + message := fmt.Sprintf("Unable to target Gateway %s, another ClientTrafficPolicy has already attached to it", + string(currTarget.Name)) resolveErr = &status.PolicyResolveError{ Reason: gwapiv1a2.PolicyReasonConflicted, diff --git a/internal/gatewayapi/envoyextensionpolicy.go b/internal/gatewayapi/envoyextensionpolicy.go index 081e8f641a2..a0882b2deba 100644 --- a/internal/gatewayapi/envoyextensionpolicy.go +++ b/internal/gatewayapi/envoyextensionpolicy.go @@ -249,7 +249,8 @@ func resolveEEPolicyGatewayTargetRef(policy *egv1a1.EnvoyExtensionPolicy, target // Check if another policy targeting the same Gateway exists if gateway.attached { - message := "Unable to target Gateway, another EnvoyExtensionPolicy has already attached to it" + message := fmt.Sprintf("Unable to target Gateway %s, another EnvoyExtensionPolicy has already attached to it", + string(target.Name)) return gateway.GatewayContext, &status.PolicyResolveError{ Reason: gwapiv1a2.PolicyReasonConflicted, @@ -293,8 +294,8 @@ func resolveEEPolicyRouteTargetRef(policy *egv1a1.EnvoyExtensionPolicy, target g // Check if another policy targeting the same xRoute exists if route.attached { - message := fmt.Sprintf("Unable to target %s, another EnvoyExtensionPolicy has already attached to it", - string(target.Kind)) + message := fmt.Sprintf("Unable to target %s %s, another EnvoyExtensionPolicy has already attached to it", + string(target.Kind), string(target.Name)) return route.RouteContext, &status.PolicyResolveError{ Reason: gwapiv1a2.PolicyReasonConflicted, diff --git a/internal/gatewayapi/securitypolicy.go b/internal/gatewayapi/securitypolicy.go index 9a0fefbafc5..2aec807c7b7 100644 --- a/internal/gatewayapi/securitypolicy.go +++ b/internal/gatewayapi/securitypolicy.go @@ -279,7 +279,8 @@ func resolveSecurityPolicyGatewayTargetRef( // Check if another policy targeting the same Gateway exists if gateway.attached { - message := "Unable to target Gateway, another SecurityPolicy has already attached to it" + message := fmt.Sprintf("Unable to target Gateway %s, another SecurityPolicy has already attached to it", + string(target.Name)) return gateway.GatewayContext, &status.PolicyResolveError{ Reason: gwapiv1a2.PolicyReasonConflicted, @@ -331,8 +332,8 @@ func resolveSecurityPolicyRouteTargetRef( // Check if another policy targeting the same xRoute exists if route.attached { - message := fmt.Sprintf("Unable to target %s, another SecurityPolicy has already attached to it", - string(target.Kind)) + message := fmt.Sprintf("Unable to target %s %s, another SecurityPolicy has already attached to it", + string(target.Kind), string(target.Name)) return route.RouteContext, &status.PolicyResolveError{ Reason: gwapiv1a2.PolicyReasonConflicted, diff --git a/internal/gatewayapi/testdata/backendtrafficpolicy-status-conditions.out.yaml b/internal/gatewayapi/testdata/backendtrafficpolicy-status-conditions.out.yaml index b998fb86ec9..1a054712d80 100644 --- a/internal/gatewayapi/testdata/backendtrafficpolicy-status-conditions.out.yaml +++ b/internal/gatewayapi/testdata/backendtrafficpolicy-status-conditions.out.yaml @@ -44,8 +44,8 @@ backendTrafficPolicies: namespace: envoy-gateway conditions: - lastTransitionTime: null - message: Unable to target HTTPRoute, another BackendTrafficPolicy has already - attached to it + message: Unable to target HTTPRoute httproute-1, another BackendTrafficPolicy + has already attached to it reason: Conflicted status: "False" type: Accepted @@ -152,8 +152,8 @@ backendTrafficPolicies: namespace: envoy-gateway conditions: - lastTransitionTime: null - message: Unable to target Gateway, another BackendTrafficPolicy has already - attached to it + message: Unable to target Gateway gateway-1, another BackendTrafficPolicy + has already attached to it reason: Conflicted status: "False" type: Accepted diff --git a/internal/gatewayapi/testdata/clienttrafficpolicy-status-conditions.out.yaml b/internal/gatewayapi/testdata/clienttrafficpolicy-status-conditions.out.yaml index ba86d22b1a8..f4fcac96827 100644 --- a/internal/gatewayapi/testdata/clienttrafficpolicy-status-conditions.out.yaml +++ b/internal/gatewayapi/testdata/clienttrafficpolicy-status-conditions.out.yaml @@ -75,8 +75,8 @@ clientTrafficPolicies: sectionName: https conditions: - lastTransitionTime: null - message: Unable to target section, another ClientTrafficPolicy has already - attached to it + message: Unable to target section of gateway-2, another ClientTrafficPolicy + has already attached to it reason: Conflicted status: "False" type: Accepted @@ -153,8 +153,8 @@ clientTrafficPolicies: namespace: envoy-gateway conditions: - lastTransitionTime: null - message: Unable to target Gateway, another ClientTrafficPolicy has already - attached to it + message: Unable to target Gateway gateway-1, another ClientTrafficPolicy has + already attached to it reason: Conflicted status: "False" type: Accepted diff --git a/internal/gatewayapi/testdata/envoyextensionpolicy-status-conditions.out.yaml b/internal/gatewayapi/testdata/envoyextensionpolicy-status-conditions.out.yaml index 0c4264fd4b9..f4cc57f95ba 100644 --- a/internal/gatewayapi/testdata/envoyextensionpolicy-status-conditions.out.yaml +++ b/internal/gatewayapi/testdata/envoyextensionpolicy-status-conditions.out.yaml @@ -44,8 +44,8 @@ envoyExtensionPolicies: namespace: envoy-gateway conditions: - lastTransitionTime: null - message: Unable to target HTTPRoute, another EnvoyExtensionPolicy has already - attached to it + message: Unable to target HTTPRoute httproute-1, another EnvoyExtensionPolicy + has already attached to it reason: Conflicted status: "False" type: Accepted @@ -152,8 +152,8 @@ envoyExtensionPolicies: namespace: envoy-gateway conditions: - lastTransitionTime: null - message: Unable to target Gateway, another EnvoyExtensionPolicy has already - attached to it + message: Unable to target Gateway gateway-1, another EnvoyExtensionPolicy + has already attached to it reason: Conflicted status: "False" type: Accepted diff --git a/internal/gatewayapi/testdata/securitypolicy-status-conditions.out.yaml b/internal/gatewayapi/testdata/securitypolicy-status-conditions.out.yaml index 33fcb6a5e63..607330a824c 100644 --- a/internal/gatewayapi/testdata/securitypolicy-status-conditions.out.yaml +++ b/internal/gatewayapi/testdata/securitypolicy-status-conditions.out.yaml @@ -286,8 +286,8 @@ securityPolicies: namespace: envoy-gateway conditions: - lastTransitionTime: null - message: Unable to target HTTPRoute, another SecurityPolicy has already attached - to it + message: Unable to target HTTPRoute httproute-1, another SecurityPolicy has + already attached to it reason: Conflicted status: "False" type: Accepted @@ -381,8 +381,8 @@ securityPolicies: namespace: envoy-gateway conditions: - lastTransitionTime: null - message: Unable to target Gateway, another SecurityPolicy has already attached - to it + message: Unable to target Gateway gateway-1, another SecurityPolicy has already + attached to it reason: Conflicted status: "False" type: Accepted