Skip to content

Commit

Permalink
printing name of the target when a policy fails to attach (envoyproxy…
Browse files Browse the repository at this point in the history
…#3943)

* printing name of the target when a policy fails to attach

Signed-off-by: Viktor Sadovnikov <[email protected]>

* printing name of the target when a policy fails to attach

Signed-off-by: Viktor Sadovnikov <[email protected]>

* printing name of the target when a policy fails to attach

Signed-off-by: Viktor Sadovnikov <[email protected]>

---------

Signed-off-by: Viktor Sadovnikov <[email protected]>
  • Loading branch information
sadovnikov authored Jul 25, 2024
1 parent 46dbeb9 commit a0c0e48
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 27 deletions.
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,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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a0c0e48

Please sign in to comment.