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: only check if condition contained in ensuring gateway associated of httproute #3346

Merged
merged 3 commits into from
Jan 9, 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 @@ -71,6 +71,9 @@ Adding a new version? You'll need three changes:

- Disabled non-functioning mesh reporting when `--watch-namespaces` flag set.
[#3336](https://github.com/Kong/kubernetes-ingress-controller/pull/3336)
- 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)

### Deprecated

Expand Down
13 changes: 6 additions & 7 deletions internal/controllers/gateway/httproute_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,12 @@ func (r *HTTPRouteReconciler) ensureGatewayReferenceStatusAdded(ctx context.Cont
// if the reference already exists and doesn't require any changes
// then just leave it alone.
if existingGatewayParentStatus, exists := parentStatuses[key]; exists {
// fake the time of the existing status as this wont be equal
for i := range existingGatewayParentStatus.Conditions {
existingGatewayParentStatus.Conditions[i].LastTransitionTime = gatewayParentStatus.Conditions[0].LastTransitionTime
}

// other than the condition timestamps, check if the statuses are equal
if reflect.DeepEqual(existingGatewayParentStatus, gatewayParentStatus) {
// check if the parentRef and controllerName are equal, and whether the new condition is present in existing conditions
if reflect.DeepEqual(existingGatewayParentStatus.ParentRef, gatewayParentStatus.ParentRef) &&
existingGatewayParentStatus.ControllerName == gatewayParentStatus.ControllerName &&
lo.ContainsBy(existingGatewayParentStatus.Conditions, func(condition metav1.Condition) bool {
return sameCondition(gatewayParentStatus.Conditions[0], condition)
}) {
continue
}
}
Expand Down
8 changes: 8 additions & 0 deletions internal/controllers/gateway/route_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,3 +630,11 @@ func isHTTPReferenceGranted(grantSpec gatewayv1alpha2.ReferenceGrantSpec, backen
}
return false
}

// sameCondition returns true if the conditions in parameter has the same type, status, reason and message.
func sameCondition(a, b metav1.Condition) bool {
return a.Type == b.Type &&
a.Status == b.Status &&
a.Reason == b.Reason &&
a.Message == b.Message
}