Skip to content

Commit 74aea55

Browse files
authored
fix: update observedGeneration on Gateway-API route status conditions (apache/apisix-ingress-controller#2768) (#418)
1 parent fbd0841 commit 74aea55

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

internal/provider/api7ee/status.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ func (d *api7eeProvider) updateStatus(nnk types.NamespacedNameKind, condition me
122122
Resource: &gatewayv1.HTTPRoute{},
123123
Mutator: status.MutatorFunc(func(obj client.Object) client.Object {
124124
cp := obj.(*gatewayv1.HTTPRoute).DeepCopy()
125+
condition.ObservedGeneration = cp.GetGeneration()
125126
gatewayNs := cp.GetNamespace()
126127
for i, ref := range cp.Status.Parents {
127128
ns := gatewayNs
@@ -157,6 +158,7 @@ func (d *api7eeProvider) updateStatus(nnk types.NamespacedNameKind, condition me
157158
Resource: &gatewayv1alpha2.UDPRoute{},
158159
Mutator: status.MutatorFunc(func(obj client.Object) client.Object {
159160
cp := obj.(*gatewayv1alpha2.UDPRoute).DeepCopy()
161+
condition.ObservedGeneration = cp.GetGeneration()
160162
gatewayNs := cp.GetNamespace()
161163
for i, ref := range cp.Status.Parents {
162164
ns := gatewayNs
@@ -192,6 +194,7 @@ func (d *api7eeProvider) updateStatus(nnk types.NamespacedNameKind, condition me
192194
Resource: &gatewayv1alpha2.TCPRoute{},
193195
Mutator: status.MutatorFunc(func(obj client.Object) client.Object {
194196
cp := obj.(*gatewayv1alpha2.TCPRoute).DeepCopy()
197+
condition.ObservedGeneration = cp.GetGeneration()
195198
gatewayNs := cp.GetNamespace()
196199
for i, ref := range cp.Status.Parents {
197200
ns := gatewayNs
@@ -227,6 +230,7 @@ func (d *api7eeProvider) updateStatus(nnk types.NamespacedNameKind, condition me
227230
Resource: &gatewayv1.GRPCRoute{},
228231
Mutator: status.MutatorFunc(func(obj client.Object) client.Object {
229232
cp := obj.(*gatewayv1.GRPCRoute).DeepCopy()
233+
condition.ObservedGeneration = cp.GetGeneration()
230234
gatewayNs := cp.GetNamespace()
231235
for i, ref := range cp.Status.Parents {
232236
ns := gatewayNs

internal/provider/apisix/status.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ func (d *apisixProvider) updateStatus(nnk types.NamespacedNameKind, condition me
123123
Resource: &gatewayv1.HTTPRoute{},
124124
Mutator: status.MutatorFunc(func(obj client.Object) client.Object {
125125
cp := obj.(*gatewayv1.HTTPRoute).DeepCopy()
126+
condition.ObservedGeneration = cp.GetGeneration()
126127
gatewayNs := cp.GetNamespace()
127128
for i, ref := range cp.Status.Parents {
128129
ns := gatewayNs
@@ -158,6 +159,7 @@ func (d *apisixProvider) updateStatus(nnk types.NamespacedNameKind, condition me
158159
Resource: &gatewayv1alpha2.UDPRoute{},
159160
Mutator: status.MutatorFunc(func(obj client.Object) client.Object {
160161
cp := obj.(*gatewayv1alpha2.UDPRoute).DeepCopy()
162+
condition.ObservedGeneration = cp.GetGeneration()
161163
gatewayNs := cp.GetNamespace()
162164
for i, ref := range cp.Status.Parents {
163165
ns := gatewayNs
@@ -193,6 +195,7 @@ func (d *apisixProvider) updateStatus(nnk types.NamespacedNameKind, condition me
193195
Resource: &gatewayv1alpha2.TCPRoute{},
194196
Mutator: status.MutatorFunc(func(obj client.Object) client.Object {
195197
cp := obj.(*gatewayv1alpha2.TCPRoute).DeepCopy()
198+
condition.ObservedGeneration = cp.GetGeneration()
196199
gatewayNs := cp.GetNamespace()
197200
for i, ref := range cp.Status.Parents {
198201
ns := gatewayNs
@@ -228,6 +231,7 @@ func (d *apisixProvider) updateStatus(nnk types.NamespacedNameKind, condition me
228231
Resource: &gatewayv1.GRPCRoute{},
229232
Mutator: status.MutatorFunc(func(obj client.Object) client.Object {
230233
cp := obj.(*gatewayv1.GRPCRoute).DeepCopy()
234+
condition.ObservedGeneration = cp.GetGeneration()
231235
gatewayNs := cp.GetNamespace()
232236
for i, ref := range cp.Status.Parents {
233237
ns := gatewayNs

test/e2e/gatewayapi/status.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ spec:
173173
And(
174174
ContainSubstring(`status: "True"`),
175175
ContainSubstring(`reason: Accepted`),
176+
ContainSubstring(`observedGeneration: 1`),
176177
),
177178
)
178179

0 commit comments

Comments
 (0)