Skip to content

Commit f6332a7

Browse files
chore(gateway): tidy upstream cluster-naming and basePath comments
Use "URL-stable" instead of "EDS-stable" for the cluster-naming comments (the clusters are STRICT_DNS with inline endpoints, not EDS), and drop the PR-number references from the basePath comments so they read on their own.
1 parent a9d3477 commit f6332a7

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

gateway/gateway-controller/pkg/transform/restapi.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ type upstreamClusterResult struct {
389389
// ClusterKey is the internal key used in rdc.UpstreamClusters.
390390
ClusterKey string
391391
// EnvoyClusterName is the Envoy cluster name. For API-level upstreams it is
392-
// the EDS-stable hashed name "<env>_<16-hex>" (matching ClusterKey). For
392+
// the URL-stable hashed name "<env>_<16-hex>" (matching ClusterKey). For
393393
// per-op upstreams it is empty because the route resolves the cluster via
394394
// ClusterKey directly. This is the value Envoy knows the cluster by, so the
395395
// policy engine must use it for the x-target-upstream header.
@@ -429,7 +429,7 @@ func (t *RestAPITransformer) addUpstreamCluster(
429429
basePath = "/"
430430
}
431431

432-
// EDS-stable cluster naming: derived from sha256(apiID|env) so URL edits
432+
// URL-stable cluster naming: derived from sha256(apiID|env) so URL edits
433433
// propagate as endpoint updates rather than cluster recreates. ClusterKey and
434434
// EnvoyClusterName are intentionally the same string so the policy engine's
435435
// `default_upstream_cluster` metadata points at the actual Envoy cluster.
@@ -465,7 +465,7 @@ func (t *RestAPITransformer) addUpstreamCluster(
465465
// unconditionally (see the upstreamDefinition cluster loop in Transform), so a per-op
466466
// route reuses it rather than minting its own cluster. One cluster per definition
467467
// serves both the main and sandbox vhosts — the key carries no env component. Reuse
468-
// also means the route inherits the definition's authoritative basePath (#2065),
468+
// also means the route inherits the definition's authoritative basePath,
469469
// avoiding the URL-derived-basePath divergence a separate per-op cluster would have.
470470
func perOpDefinitionClusterKey(kind, uuid string, target *api.RestAPIOperationUpstreamTarget, upstreamDefinitions *[]api.UpstreamDefinition) (string, error) {
471471
def, err := upstreamref.FindByName(target.Ref, upstreamDefinitions)
@@ -489,7 +489,7 @@ func resolveUpstreamURL(name string, up *api.Upstream, defs *[]api.UpstreamDefin
489489
refName := strings.TrimSpace(*up.Ref)
490490
// Resolve through the shared upstreamref helper (one source of truth for ref
491491
// lookup, shared with the per-op transformer and the xDS translator), and return
492-
// the definition's base path (from basePath, #2065) so the caller rewrites the
492+
// the definition's base path (from basePath) so the caller rewrites the
493493
// upstream path correctly. The "no URLs" check stays here since FindByName
494494
// resolves the definition, not its endpoints.
495495
def, err := upstreamref.FindByName(refName, defs)

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ func (t *Translator) translateAPIConfig(cfg *models.StoredConfig, allConfigs []*
836836
}
837837
// Reuse the referenced upstreamDefinition's cluster (built unconditionally
838838
// below) instead of minting a per-op cluster. routeURLPath carries the
839-
// definition's base path (#2065) so the route's static rewrite prepends it
839+
// definition's base path so the route's static rewrite prepends it
840840
// exactly once. Keep cluster_header ON with that cluster as the default so a
841841
// dynamic-endpoint policy can still steer this operation. Precedence:
842842
// op-policy > api-policy > per-op ref > api-level upstream.
@@ -917,7 +917,7 @@ func (t *Translator) translateAPIConfig(cfg *models.StoredConfig, allConfigs []*
917917
return nil, nil, fmt.Errorf("per-op sandbox upstream for %s %s: %w", string(op.Method), op.Path, err)
918918
}
919919
// Reuse the referenced upstreamDefinition's cluster; routeURLPath carries
920-
// its base path (#2065). Keep cluster_header ON so a sandbox dynamic-endpoint
920+
// its base path. Keep cluster_header ON so a sandbox dynamic-endpoint
921921
// policy can override the per-op default — consistent with the API-level
922922
// sandbox routing fixed in #2059 (no static-pin bypass).
923923
sbRouteCluster = defClusterName
@@ -990,7 +990,7 @@ func (t *Translator) translateAPIConfig(cfg *models.StoredConfig, allConfigs []*
990990
// resolveUpstreamCluster validates an upstream (main or sandbox) and creates its cluster.
991991
// Returns clusterName, parsedURL, timeout (can be nil), and error.
992992
// The cluster name is derived from sha256(apiID|upstreamName), giving the
993-
// API-level main/sandbox cluster an EDS-stable identity: URL edits update
993+
// API-level main/sandbox cluster a URL-stable identity: URL edits update
994994
// endpoints in-place rather than destroying and recreating the cluster.
995995
func (t *Translator) resolveUpstreamCluster(apiID, upstreamName string, up *api.Upstream, upstreamDefinitions *[]api.UpstreamDefinition) (string, *url.URL, *resolvedTimeout, error) {
996996
var rawURL string
@@ -1052,18 +1052,18 @@ func (t *Translator) resolveUpstreamCluster(apiID, upstreamName string, up *api.
10521052
parsedURL.Path = *refBasePath
10531053
}
10541054

1055-
// Generate cluster name from EDS-stable hash (URL intentionally excluded).
1055+
// Generate cluster name from URL-stable hash (URL intentionally excluded).
10561056
clusterName := upstreamName + "_" + clusterkey.APILevel(apiID, upstreamName)
10571057

10581058
return clusterName, parsedURL, timeout, nil
10591059
}
10601060

10611061
// resolvePerOpDefinitionCluster resolves a ref-only per-op upstream target to the
1062-
// EXISTING upstreamDefinition cluster: its EDS cluster name
1062+
// EXISTING upstreamDefinition cluster: its stable cluster name
10631063
// (upstream_<kind>_<apiID>_<defName>) and base path. The definition's cluster is
10641064
// created unconditionally for every definition, so a per-op route reuses it rather
10651065
// than minting its own — one cluster per definition serves both vhosts (no env in
1066-
// the key). The base path comes from the definition's basePath field (#2065); the
1066+
// the key). The base path comes from the definition's basePath field; the
10671067
// caller passes it as the route's upstream path so the static rewrite prepends it.
10681068
func (t *Translator) resolvePerOpDefinitionCluster(kind, apiID string, target *api.RestAPIOperationUpstreamTarget, upstreamDefinitions *[]api.UpstreamDefinition) (string, string, *resolvedTimeout, error) {
10691069
refName := strings.TrimSpace(target.Ref)

0 commit comments

Comments
 (0)