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

fix: change existing resolvedRef condition to avoid duplicates #3386

Merged
merged 2 commits into from
Jan 16, 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ Adding a new version? You'll need three changes:
- Fixed the duplicate update of status of `HTTPRoute` caused by incorrect check
of whether status is changed.
[#3346](https://github.com/Kong/kubernetes-ingress-controller/pull/3346)
- Change existing `resolvedRefs` condition in status `HTTPRoute` if there is
already one to avoid multiple appearance of conditions with same type
[#3386](https://github.com/Kong/kubernetes-ingress-controller/pull/3386)

### Deprecated

Expand Down
26 changes: 15 additions & 11 deletions internal/controllers/gateway/httproute_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,24 +521,28 @@ func (r *HTTPRouteReconciler) setRouteConditionResolvedRefsCondition(

// iterate over all the parentStatuses conditions, and if no RouteConditionResolvedRefs is found,
// or if the condition is found but has to be changed, update the status and mark it to be updated
resolvedRefsCondition := metav1.Condition{
Type: string(gatewayv1beta1.RouteConditionResolvedRefs),
Status: resolvedRefsStatus,
ObservedGeneration: httpRoute.Generation,
LastTransitionTime: metav1.Now(),
Reason: string(reason),
}
for _, parentStatus := range parentStatuses {
var conditionFound bool
for _, cond := range parentStatus.Conditions {
if cond.Type == string(gatewayv1beta1.RouteConditionResolvedRefs) &&
cond.Status == resolvedRefsStatus &&
cond.Reason == string(reason) {
for i, cond := range parentStatus.Conditions {
if cond.Type == string(gatewayv1beta1.RouteConditionResolvedRefs) {
if !(cond.Status == resolvedRefsStatus &&
cond.Reason == string(reason)) {
parentStatus.Conditions[i] = resolvedRefsCondition
changed = true
}
conditionFound = true
break
}
}
if !conditionFound {
parentStatus.Conditions = append(parentStatus.Conditions, metav1.Condition{
Type: string(gatewayv1beta1.RouteConditionResolvedRefs),
Status: resolvedRefsStatus,
ObservedGeneration: httpRoute.Generation,
LastTransitionTime: metav1.Now(),
Reason: string(reason),
})
parentStatus.Conditions = append(parentStatus.Conditions, resolvedRefsCondition)
changed = true
}
}
Expand Down