Skip to content
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
10 changes: 8 additions & 2 deletions internal/gatewayapi/status/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
package status

import (
"reflect"
"unicode"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -36,7 +37,7 @@ func MergeConditions(conditions []metav1.Condition, updates ...metav1.Condition)
for j := range conditions {
if conditions[j].Type == update.Type {
add = false
if !reflect.DeepEqual(conditions[j], update) {
if conditionChanged(&conditions[j], &update) {
conditions[j].Status = update.Status
conditions[j].Reason = update.Reason
conditions[j].Message = update.Message
Expand All @@ -53,6 +54,11 @@ func MergeConditions(conditions []metav1.Condition, updates ...metav1.Condition)
return conditions
}

func conditionChanged(a, b *metav1.Condition) bool {
opts := cmpopts.IgnoreFields(metav1.Condition{}, "Type", "LastTransitionTime")
return !cmp.Equal(*a, *b, opts)
}

func newCondition(t string, status metav1.ConditionStatus, reason, msg string, og int64) metav1.Condition {
return metav1.Condition{
Type: t,
Expand Down
17 changes: 15 additions & 2 deletions internal/gatewayapi/status/conditions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ package status

import (
"errors"
"reflect"
"strings"
"testing"

Expand All @@ -41,6 +40,20 @@ func TestConditionChanged(t *testing.T) {
a: metav1.Condition{},
b: metav1.Condition{},
},
{
name: "condition LastTransitionTime should be ignored",
expected: false,
a: metav1.Condition{
Type: string(gwapiv1.GatewayClassConditionStatusAccepted),
Status: metav1.ConditionTrue,
LastTransitionTime: metav1.Unix(0, 0),
},
b: metav1.Condition{
Type: string(gwapiv1.GatewayClassConditionStatusAccepted),
Status: metav1.ConditionTrue,
LastTransitionTime: metav1.Unix(1, 0),
},
},
{
name: "check condition reason differs",
expected: true,
Expand Down Expand Up @@ -70,7 +83,7 @@ func TestConditionChanged(t *testing.T) {
}

for _, tc := range testCases {
if got := !reflect.DeepEqual(tc.a, tc.b); got != tc.expected {
if got := conditionChanged(&tc.a, &tc.b); got != tc.expected {
assert.Equal(t, tc.expected, got, tc.name)
}
}
Expand Down
1 change: 1 addition & 0 deletions release-notes/current.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ bug fixes: |
Fixed ListenerSet and its listeners incorrectly setting `Accepted: False` for InvalidCertificateRef and RefNotPermitted, inconsistent with Gateway behavior and the Gateway API spec.
Fixed active HTTP health checks to use Backend endpoint hostnames before falling back to the effective Route hostname.
Fixed HTTPS listeners with overlapping hostnames but disjoint certificate SANs to preserve HTTP/2 ALPN by default.
Fixed Gateway getting stuck at `Programmed=False` after its LoadBalancer Service IP was restored, by ignoring `LastTransitionTime` when comparing status conditions.

# Enhancements that improve performance.
performance improvements: |
Expand Down