Skip to content

Commit

Permalink
use InvalidParameters
Browse files Browse the repository at this point in the history
Signed-off-by: zirain <[email protected]>
  • Loading branch information
zirain committed Jan 17, 2025
1 parent 29959e1 commit ec94671
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 17 deletions.
6 changes: 3 additions & 3 deletions internal/gatewayapi/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,21 +188,21 @@ func (t *Translator) processProxyObservability(gwCtx *GatewayContext, xdsIR *ir.

xdsIR.AccessLog, err = t.processAccessLog(envoyProxy, resources)
if err != nil {
status.UpdateGatewayListenersNotValidCondition(gwCtx.Gateway, gwapiv1.GatewayReasonInvalid, metav1.ConditionFalse,
status.SetGatewayAccepted(gwCtx.Gateway, false, gwapiv1.GatewayReasonInvalidParameters,
fmt.Sprintf("Invalid access log backendRefs: %v", err))
return
}

xdsIR.Tracing, err = t.processTracing(gwCtx.Gateway, envoyProxy, t.MergeGateways, resources)
if err != nil {
status.UpdateGatewayListenersNotValidCondition(gwCtx.Gateway, gwapiv1.GatewayReasonInvalid, metav1.ConditionFalse,
status.SetGatewayAccepted(gwCtx.Gateway, false, gwapiv1.GatewayReasonInvalidParameters,
fmt.Sprintf("Invalid tracing backendRefs: %v", err))
return
}

xdsIR.Metrics, err = t.processMetrics(envoyProxy, resources)
if err != nil {
status.UpdateGatewayListenersNotValidCondition(gwCtx.Gateway, gwapiv1.GatewayReasonInvalid, metav1.ConditionFalse,
status.SetGatewayAccepted(gwCtx.Gateway, false, gwapiv1.GatewayReasonInvalidParameters,
fmt.Sprintf("Invalid metrics backendRefs: %v", err))
return
}
Expand Down
6 changes: 0 additions & 6 deletions internal/gatewayapi/status/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ import (
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
)

func UpdateGatewayListenersNotValidCondition(gw *gwapiv1.Gateway, reason gwapiv1.GatewayConditionReason, status metav1.ConditionStatus, msg string) *gwapiv1.Gateway {
cond := newCondition(string(gwapiv1.GatewayReasonListenersNotValid), status, string(reason), msg, time.Now(), gw.Generation)
gw.Status.Conditions = MergeConditions(gw.Status.Conditions, cond)
return gw
}

// SetGatewayAccepted set the status condition for the provided Gateway based on the accepted state.
func SetGatewayAccepted(gw *gwapiv1.Gateway, accepted bool, reason gwapiv1.GatewayConditionReason, message string) *gwapiv1.Gateway {
status := metav1.ConditionFalse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ gateways:
- lastTransitionTime: null
message: 'Invalid access log backendRefs: Service monitoring/service-not-found
not found'
reason: Invalid
reason: InvalidParameters
status: "False"
type: ListenersNotValid
type: Accepted
listeners:
- attachedRoutes: 0
conditions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ gateways:
conditions:
- lastTransitionTime: null
message: 'Invalid access log backendRefs: invalid CEL expression: )++++'
reason: Invalid
reason: InvalidParameters
status: "False"
type: ListenersNotValid
type: Accepted
listeners:
- attachedRoutes: 0
conditions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ gateways:
- lastTransitionTime: null
message: 'Invalid metrics backendRefs: Service monitoring/service-not-found
not found'
reason: Invalid
reason: InvalidParameters
status: "False"
type: ListenersNotValid
type: Accepted
listeners:
- attachedRoutes: 0
conditions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ gateways:
- lastTransitionTime: null
message: 'Invalid tracing backendRefs: Service monitoring/service-not-found
not found'
reason: Invalid
reason: InvalidParameters
status: "False"
type: ListenersNotValid
type: Accepted
listeners:
- attachedRoutes: 0
conditions:
Expand Down

0 comments on commit ec94671

Please sign in to comment.