Skip to content

Commit 07bcc69

Browse files
authored
fix: missing upstream name in gateway-api routes (#1754) (#1756)
* fix: missing upstream name in gateway-api routes * fmt imports --------- Signed-off-by: Ling Samuel <[email protected]>
1 parent df04324 commit 07bcc69

File tree

5 files changed

+220
-119
lines changed

5 files changed

+220
-119
lines changed

pkg/providers/gateway/translation/gateway_httproute.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,20 @@ func (t *translator) TranslateGatewayHTTPRouteV1beta1(httpRoute *gatewayv1beta1.
192192
if err != nil {
193193
return nil, errors.Wrap(err, fmt.Sprintf("failed to translate Rules[%v].BackendRefs[%v]", i, j))
194194
}
195-
name := apisixv1.ComposeUpstreamName(ns, string(backend.Name), "", int32(*backend.Port), types.ResolveGranularity.Endpoint)
195+
ups.Name = apisixv1.ComposeUpstreamName(ns, string(backend.Name), "", int32(*backend.Port), types.ResolveGranularity.Endpoint)
196196

197197
// APISIX limits max length of label value
198198
// https://github.com/apache/apisix/blob/5b95b85faea3094d5e466ee2d39a52f1f805abbb/apisix/schema_def.lua#L85
199199
ups.Labels["meta_namespace"] = utils.TruncateString(ns, 64)
200200
ups.Labels["meta_backend"] = utils.TruncateString(string(backend.Name), 64)
201201
ups.Labels["meta_port"] = fmt.Sprintf("%v", int32(*backend.Port))
202202

203-
ups.ID = id.GenID(name)
203+
ups.ID = id.GenID(ups.Name)
204+
log.Debugw("translated HTTPRoute upstream",
205+
zap.Int("backendRefs_index", j),
206+
zap.String("backendRefs_name", string(backend.Name)),
207+
zap.String("name", ups.Name),
208+
)
204209
ctx.AddUpstream(ups)
205210
ruleUpstreams = append(ruleUpstreams, ups)
206211

0 commit comments

Comments
 (0)