Skip to content

Commit d740258

Browse files
fix(controller): rebuild Envoy xDS snapshot after wiring transformers
The initial Envoy snapshot was generated before SetTransformers ran, so it fell back to the legacy translation path — naming clusters "cluster_<scheme>_<host>" and routes without the header-hash discriminator. The policy engine's resources are built from the transformer path ("upstream_<name>_<host>_<port>" clusters, header-hashed route names), so the two disagreed until the first redeploy: cluster-header APIs failed with cluster_not_found and header-matched routes returned 500 "policy chain not found". - Regenerate the Envoy snapshot after transformers are wired and runtime configs are loaded, before the policy snapshot is built - Warn when TranslateConfigs silently falls back to the legacy path because no transformer is registered for a non-WebSub kind Signed-off-by: Renuka Fernando <renukapiyumal@gmail.com>
1 parent 4b5a7bc commit d740258

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

gateway/gateway-controller/cmd/controller/main.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,22 @@ func main() {
469469
slog.Int("total_apis", len(loadedAPIs)),
470470
slog.Int("configs_loaded", loadedCount))
471471

472+
// Regenerate the Envoy xDS snapshot now that the transformers are wired (above)
473+
// and runtime configs are loaded. The initial snapshot generated earlier ran
474+
// before SetTransformers, so it fell back to the legacy translation path — naming
475+
// clusters "cluster_<scheme>_<host>" and routes without the header-hash
476+
// discriminator. The policy engine's resources are keyed off the transformer path
477+
// ("upstream_<name>_<host>_<port>" clusters, header-hashed route names), so without
478+
// this rebuild Envoy and the policy engine disagree: cluster-header APIs fail with
479+
// cluster_not_found and header-matched routes 500 with "policy chain not found"
480+
// until the first redeploy happens to re-run the transformer path.
481+
log.Info("Regenerating xDS snapshot via transformer path after wiring transformers")
482+
ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
483+
if err := snapshotManager.UpdateSnapshot(ctx, ""); err != nil {
484+
log.Warn("Failed to regenerate xDS snapshot after transformer init", slog.Any("error", err))
485+
}
486+
cancel()
487+
472488
// Generate initial policy snapshot
473489
log.Info("Generating initial policy xDS snapshot")
474490
ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second)

gateway/gateway-controller/pkg/xds/translator.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,17 @@ func (t *Translator) TranslateConfigs(
747747
routesList, clusterList, err = t.eventGatewayHooks.TranslateWebSubAPI(t, cfg, configs)
748748
}
749749
} else {
750+
// No transformer produced routes for a non-WebSub kind. If the kind has
751+
// no transformer registered at all, we silently fell back here — a nil or
752+
// unwired transformer map returns ok=false at the check above, with no
753+
// error. Surface it, because the resulting Envoy snapshot uses legacy
754+
// cluster/route naming that the policy engine's transformer-path resources
755+
// don't match. (A transformer that errored is already logged above.)
756+
if _, ok := t.transformers[cfg.Kind]; !ok {
757+
log.Warn("No transformer registered for API kind; using legacy translation path",
758+
slog.String("kind", cfg.Kind),
759+
slog.String("id", cfg.UUID))
760+
}
750761
routesList, clusterList, err = t.translateAPIConfig(cfg, configs)
751762
}
752763
if err != nil {

0 commit comments

Comments
 (0)