Skip to content

Commit

Permalink
internal/dag: default Listener ResolvedRefs to true (#5804)
Browse files Browse the repository at this point in the history
Sets Gateway Listeners' ResolvedRefs condition
to true by default, to pass updated conformance.

Closes #5648.

Signed-off-by: Steve Kriss <krisss@vmware.com>
  • Loading branch information
skriss authored Oct 5, 2023
1 parent b865f33 commit f03665e
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 260 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/5804-skriss-small.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Gateway API: set Listeners' `ResolvedRefs` condition to `true` by default.
36 changes: 29 additions & 7 deletions internal/dag/gatewayapi_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,9 @@ func (p *GatewayAPIProcessor) computeListener(
msg,
)
}
// set the listener's "Programmed" condition based on whether we've
// added any other conditions for the listener. The assumption
// here is that if another condition is set, the listener is
// invalid/not programmed.

// Set required Listener conditions (Programmed, Accepted, ResolvedRefs)
// if they haven't already been set.
defer func() {
listenerStatus := gwAccessor.ListenerStatus[string(listener.Name)]

Expand All @@ -450,27 +449,39 @@ func (p *GatewayAPIProcessor) computeListener(
gatewayapi_v1beta1.ListenerReasonAccepted,
"Listener accepted",
)
gwAccessor.AddListenerCondition(
string(listener.Name),
gatewayapi_v1beta1.ListenerConditionResolvedRefs,
metav1.ConditionTrue,
gatewayapi_v1beta1.ListenerReasonResolvedRefs,
"Listener references resolved",
)
} else {
programmedConditionExists := false
acceptedConditionExists := false
resolvedRefsConditionExists := false

for _, cond := range listenerStatus.Conditions {
if cond.Type == string(gatewayapi_v1beta1.ListenerConditionProgrammed) {
programmedConditionExists = true
}
if cond.Type == string(gatewayapi_v1beta1.ListenerConditionAccepted) {
acceptedConditionExists = true
}
if cond.Type == string(gatewayapi_v1beta1.ListenerConditionResolvedRefs) {
resolvedRefsConditionExists = true
}
}

// Only set the Programmed or Accepted conditions if
// Only set the required Listener conditions if
// they don't already exist in the status update, since
// if they do exist, they will contain more specific
// information in the reason, message, etc.
if !programmedConditionExists {
addInvalidListenerCondition("Invalid listener, see other listener conditions for details")
}
// Accepted condition is always true for now if not
// explicitly set.
// Set Accepted condition to true if not
// explicitly set otherwise.
if !acceptedConditionExists {
gwAccessor.AddListenerCondition(
string(listener.Name),
Expand All @@ -480,6 +491,17 @@ func (p *GatewayAPIProcessor) computeListener(
"Listener accepted",
)
}
// Set ResolvedRefs condition to true if not
// explicitly set otherwise.
if !resolvedRefsConditionExists {
gwAccessor.AddListenerCondition(
string(listener.Name),
gatewayapi_v1beta1.ListenerConditionResolvedRefs,
metav1.ConditionTrue,
gatewayapi_v1beta1.ListenerReasonResolvedRefs,
"Listener references resolved",
)
}
}
}()

Expand Down
Loading

0 comments on commit f03665e

Please sign in to comment.