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

internal/dag: default Listener ResolvedRefs to true #5804

Merged
merged 2 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
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