Skip to content

Commit 04ee6c0

Browse files
authored
fix error when updating invalid gateway status (#7415)
* fix error when updating invalid gateway status Signed-off-by: zirain <[email protected]>
1 parent ea42fea commit 04ee6c0

File tree

4 files changed

+4
-9
lines changed

4 files changed

+4
-9
lines changed

internal/gatewayapi/contexts.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ func (g *GatewayContext) ResetListeners(resources *resource.Resources, epMap map
4444
listenerStatusIdx: i,
4545
}
4646
}
47-
48-
g.attachEnvoyProxy(resources, epMap)
4947
}
5048

5149
func (g *GatewayContext) attachEnvoyProxy(resources *resource.Resources, epMap map[types.NamespacedName]*egv1a1.EnvoyProxy) {

internal/gatewayapi/testdata/envoyproxy-gateway-accesslog-with-bad-sinks.out.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,5 @@ gateways:
2727
reason: InvalidParameters
2828
status: "False"
2929
type: Accepted
30-
listeners:
31-
- attachedRoutes: 0
32-
conditions: null
33-
name: http
34-
supportedKinds: null
3530
infraIR: {}
3631
xdsIR: {}

internal/gatewayapi/translator.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ func (t *Translator) GetRelevantGateways(resources *resource.Resources) (
386386
gCtx := &GatewayContext{
387387
Gateway: gateway,
388388
}
389+
gCtx.attachEnvoyProxy(resources, envoyproxyMap)
389390

390391
// Gateways that are not accepted by the controller because they reference an invalid EnvoyProxy.
391392
if status.GatewayNotAccepted(gCtx.Gateway) {
@@ -394,7 +395,6 @@ func (t *Translator) GetRelevantGateways(resources *resource.Resources) (
394395
continue
395396
}
396397

397-
gCtx.ResetListeners(resources, envoyproxyMap)
398398
if ep := gCtx.envoyProxy; ep != nil {
399399
key := utils.NamespacedName(ep)
400400
if err, exits := envoyproxyValidationErrorMap[key]; exits {
@@ -406,6 +406,8 @@ func (t *Translator) GetRelevantGateways(resources *resource.Resources) (
406406
}
407407
}
408408

409+
// we cannot do this early, otherwise there's an error when updating status.
410+
gCtx.ResetListeners(resources, envoyproxyMap)
409411
acceptedGateways = append(acceptedGateways, gCtx)
410412
}
411413
return

internal/infrastructure/runner/runner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func (r *Runner) updateProxyInfraFromSubscription(ctx context.Context, sub <-cha
106106
// Subscribe to resources
107107
message.HandleSubscription(message.Metadata{Runner: r.Name(), Message: message.InfraIRMessageName}, sub,
108108
func(update message.Update[string, *ir.Infra], errChan chan error) {
109-
r.Logger.Info("received an update")
109+
r.Logger.Info("received an update", "key", update.Key, "delete", update.Delete)
110110
val := update.Value
111111

112112
if update.Delete {

0 commit comments

Comments
 (0)