Skip to content

Commit 4b16d14

Browse files
authored
fix: only check if condition contained in ensuring gateway associated of httproute (#3346)
1 parent 60393e9 commit 4b16d14

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ Adding a new version? You'll need three changes:
7171

7272
- Disabled non-functioning mesh reporting when `--watch-namespaces` flag set.
7373
[#3336](https://github.com/Kong/kubernetes-ingress-controller/pull/3336)
74+
- Fixed the duplicate update of status of `HTTPRoute` caused by incorrect check
75+
of whether status is changed.
76+
[#3346](https://github.com/Kong/kubernetes-ingress-controller/pull/3346)
7477

7578
### Deprecated
7679

internal/controllers/gateway/httproute_controller.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -435,13 +435,12 @@ func (r *HTTPRouteReconciler) ensureGatewayReferenceStatusAdded(ctx context.Cont
435435
// if the reference already exists and doesn't require any changes
436436
// then just leave it alone.
437437
if existingGatewayParentStatus, exists := parentStatuses[key]; exists {
438-
// fake the time of the existing status as this wont be equal
439-
for i := range existingGatewayParentStatus.Conditions {
440-
existingGatewayParentStatus.Conditions[i].LastTransitionTime = gatewayParentStatus.Conditions[0].LastTransitionTime
441-
}
442-
443-
// other than the condition timestamps, check if the statuses are equal
444-
if reflect.DeepEqual(existingGatewayParentStatus, gatewayParentStatus) {
438+
// check if the parentRef and controllerName are equal, and whether the new condition is present in existing conditions
439+
if reflect.DeepEqual(existingGatewayParentStatus.ParentRef, gatewayParentStatus.ParentRef) &&
440+
existingGatewayParentStatus.ControllerName == gatewayParentStatus.ControllerName &&
441+
lo.ContainsBy(existingGatewayParentStatus.Conditions, func(condition metav1.Condition) bool {
442+
return sameCondition(gatewayParentStatus.Conditions[0], condition)
443+
}) {
445444
continue
446445
}
447446
}

internal/controllers/gateway/route_utils.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,3 +630,11 @@ func isHTTPReferenceGranted(grantSpec gatewayv1alpha2.ReferenceGrantSpec, backen
630630
}
631631
return false
632632
}
633+
634+
// sameCondition returns true if the conditions in parameter has the same type, status, reason and message.
635+
func sameCondition(a, b metav1.Condition) bool {
636+
return a.Type == b.Type &&
637+
a.Status == b.Status &&
638+
a.Reason == b.Reason &&
639+
a.Message == b.Message
640+
}

0 commit comments

Comments
 (0)