Skip to content

Commit 2dceab3

Browse files
committed
fix status updater
Signed-off-by: zirain <zirain2009@gmail.com>
1 parent 229f0e3 commit 2dceab3

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

internal/provider/kubernetes/status.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,19 +175,20 @@ func (r *gatewayAPIReconciler) updateStatusFromSubscriptions(ctx context.Context
175175
}
176176
key := update.Key
177177
val := update.Value
178+
// For status updater, need to use storage version.
178179
r.statusUpdater.Send(Update{
179180
NamespacedName: key,
180-
Resource: new(gwapiv1a2.TLSRoute),
181+
Resource: new(gwapiv1a3.TLSRoute),
181182
Mutator: MutatorFunc(func(obj client.Object) client.Object {
182-
t, ok := obj.(*gwapiv1a2.TLSRoute)
183+
t, ok := obj.(*gwapiv1a3.TLSRoute)
183184
if !ok {
184185
err := fmt.Errorf("unsupported object type %T", obj)
185186
errChan <- err
186187
panic(err)
187188
}
188189
valCopy := val.DeepCopy()
189190
setLastTransitionTimeInConditionsForRouteStatus(&valCopy.RouteStatus, metav1.Now())
190-
tCopy := &gwapiv1a2.TLSRoute{
191+
tCopy := &gwapiv1a3.TLSRoute{
191192
TypeMeta: t.TypeMeta,
192193
ObjectMeta: t.ObjectMeta,
193194
Spec: t.Spec,
@@ -451,19 +452,20 @@ func (r *gatewayAPIReconciler) updateStatusFromSubscriptions(ctx context.Context
451452
}
452453
key := update.Key
453454
val := update.Value
455+
// For status updater, need to use storage version.
454456
r.statusUpdater.Send(Update{
455457
NamespacedName: key,
456-
Resource: new(gwapiv1a3.BackendTLSPolicy),
458+
Resource: new(gwapiv1.BackendTLSPolicy),
457459
Mutator: MutatorFunc(func(obj client.Object) client.Object {
458-
t, ok := obj.(*gwapiv1a3.BackendTLSPolicy)
460+
t, ok := obj.(*gwapiv1.BackendTLSPolicy)
459461
if !ok {
460462
err := fmt.Errorf("unsupported object type %T", obj)
461463
errChan <- err
462464
panic(err)
463465
}
464466
valCopy := val.DeepCopy()
465467
setLastTransitionTimeInConditionsForPolicyStatus(valCopy, metav1.Now())
466-
tCopy := &gwapiv1a3.BackendTLSPolicy{
468+
tCopy := &gwapiv1.BackendTLSPolicy{
467469
TypeMeta: t.TypeMeta,
468470
ObjectMeta: t.ObjectMeta,
469471
Spec: t.Spec,

internal/provider/kubernetes/status_updater.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package kubernetes
77

88
import (
99
"context"
10+
"fmt"
1011
"sync"
1112
"time"
1213

@@ -99,7 +100,7 @@ func (u *UpdateHandler) apply(update Update) {
99100
if kerrors.IsNotFound(err) {
100101
return nil
101102
}
102-
return err
103+
return fmt.Errorf("failed to get resource for status update: %w", err)
103104
}
104105

105106
newObj := update.Mutator.Mutate(obj)
@@ -113,7 +114,11 @@ func (u *UpdateHandler) apply(update Update) {
113114

114115
newObj.SetUID(obj.GetUID())
115116

116-
return u.client.Status().Update(context.Background(), newObj)
117+
err := u.client.Status().Update(context.Background(), newObj)
118+
if err != nil {
119+
return fmt.Errorf("failed to update status: %w", err)
120+
}
121+
return nil
117122
}); err != nil {
118123
log.Error(err, "unable to update status")
119124

0 commit comments

Comments
 (0)