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

printing name of the target when a policy fails to attach #3943

Merged
merged 4 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 4 additions & 3 deletions internal/gatewayapi/backendtrafficpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions internal/gatewayapi/clienttrafficpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions internal/gatewayapi/envoyextensionpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions internal/gatewayapi/securitypolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ backendTrafficPolicies:
namespace: envoy-gateway
conditions:
- lastTransitionTime: null
message: Unable to target HTTPRoute, another BackendTrafficPolicy has already
message: Unable to target HTTPRoute httproute-1, another BackendTrafficPolicy has already
attached to it
reason: Conflicted
status: "False"
Expand Down Expand Up @@ -152,7 +152,7 @@ backendTrafficPolicies:
namespace: envoy-gateway
conditions:
- lastTransitionTime: null
message: Unable to target Gateway, another BackendTrafficPolicy has already
message: Unable to target Gateway gateway-1, another BackendTrafficPolicy has already
attached to it
reason: Conflicted
status: "False"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ clientTrafficPolicies:
sectionName: https
conditions:
- lastTransitionTime: null
message: Unable to target section, another ClientTrafficPolicy has already
message: Unable to target section of gateway-2, another ClientTrafficPolicy has already
attached to it
reason: Conflicted
status: "False"
Expand Down Expand Up @@ -153,7 +153,7 @@ clientTrafficPolicies:
namespace: envoy-gateway
conditions:
- lastTransitionTime: null
message: Unable to target Gateway, another ClientTrafficPolicy has already
message: Unable to target Gateway gateway-1, another ClientTrafficPolicy has already
attached to it
reason: Conflicted
status: "False"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ envoyExtensionPolicies:
namespace: envoy-gateway
conditions:
- lastTransitionTime: null
message: Unable to target HTTPRoute, another EnvoyExtensionPolicy has already
message: Unable to target HTTPRoute httproute-1, another EnvoyExtensionPolicy has already
attached to it
reason: Conflicted
status: "False"
Expand Down Expand Up @@ -152,7 +152,7 @@ envoyExtensionPolicies:
namespace: envoy-gateway
conditions:
- lastTransitionTime: null
message: Unable to target Gateway, another EnvoyExtensionPolicy has already
message: Unable to target Gateway gateway-1, another EnvoyExtensionPolicy has already
attached to it
reason: Conflicted
status: "False"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ securityPolicies:
namespace: envoy-gateway
conditions:
- lastTransitionTime: null
message: Unable to target HTTPRoute, another SecurityPolicy has already attached
message: Unable to target HTTPRoute httproute-1, another SecurityPolicy has already attached
zirain marked this conversation as resolved.
Show resolved Hide resolved
to it
reason: Conflicted
status: "False"
Expand Down Expand Up @@ -381,7 +381,7 @@ securityPolicies:
namespace: envoy-gateway
conditions:
- lastTransitionTime: null
message: Unable to target Gateway, another SecurityPolicy has already attached
message: Unable to target Gateway gateway-1, another SecurityPolicy has already attached
to it
reason: Conflicted
status: "False"
Expand Down
Loading