Skip to content

Commit 9b7b73d

Browse files
committed
fix: transfer resolveGranularity to ApisixUpstream to fix errors
Signed-off-by: Ashish Tiwari <[email protected]>
1 parent 57b5aee commit 9b7b73d

File tree

15 files changed

+57
-141
lines changed

15 files changed

+57
-141
lines changed

pkg/kube/apisix/apis/config/v2/types.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,6 @@ type ApisixRouteHTTPBackend struct {
8787
ServiceName string `json:"serviceName" yaml:"serviceName"`
8888
// The service port, could be the name or the port number.
8989
ServicePort intstr.IntOrString `json:"servicePort" yaml:"servicePort"`
90-
// The resolve granularity, can be "endpoints" or "service",
91-
// when set to "endpoints", the pod ips will be used; other
92-
// wise, the service ClusterIP or ExternalIP will be used,
93-
// default is endpoints.
94-
ResolveGranularity string `json:"resolveGranularity,omitempty" yaml:"resolveGranularity,omitempty"`
9590
// Weight of this backend.
9691
Weight *int `json:"weight" yaml:"weight"`
9792
// Subset specifies a subset for the target Service. The subset should be pre-defined
@@ -257,11 +252,6 @@ type ApisixRouteStreamBackend struct {
257252
ServiceName string `json:"serviceName" yaml:"serviceName"`
258253
// The service port, could be the name or the port number.
259254
ServicePort intstr.IntOrString `json:"servicePort" yaml:"servicePort"`
260-
// The resolve granularity, can be "endpoints" or "service",
261-
// when set to "endpoints", the pod ips will be used; other
262-
// wise, the service ClusterIP or ExternalIP will be used,
263-
// default is endpoints.
264-
ResolveGranularity string `json:"resolveGranularity,omitempty" yaml:"resolveGranularity,omitempty"`
265255
// Subset specifies a subset for the target Service. The subset should be pre-defined
266256
// in ApisixUpstream about this service.
267257
Subset string `json:"subset,omitempty" yaml:"subset,omitempty"`
@@ -515,6 +505,7 @@ type ApisixUpstreamSpec struct {
515505
// ApisixUpstreamConfig contains rich features on APISIX Upstream, for instance
516506
// load balancer, health check, etc.
517507
type ApisixUpstreamConfig struct {
508+
Granularity string `json:"granularity,omitempty" yaml:"scheme,omitempty"`
518509
// LoadBalancer represents the load balancer configuration for Kubernetes Service.
519510
// The default strategy is round robin.
520511
// +optional

pkg/providers/apisix/apisix_upstream.go

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package apisix
1616

1717
import (
1818
"context"
19+
"errors"
1920
"fmt"
2021
"reflect"
2122
"strconv"
@@ -191,6 +192,12 @@ func (c *apisixUpstreamController) sync(ctx context.Context, ev *types.Event) er
191192
if au.Spec == nil {
192193
return nil
193194
}
195+
svc, err := c.SvcLister.Services(namespace).Get(name)
196+
if err != nil {
197+
log.Errorf("failed to get service %s: %s", key, err)
198+
errRecord = err
199+
goto updateStatus
200+
}
194201

195202
// We will prioritize ExternalNodes and Discovery.
196203
if len(au.Spec.ExternalNodes) != 0 || au.Spec.Discovery != nil {
@@ -221,7 +228,7 @@ func (c *apisixUpstreamController) sync(ctx context.Context, ev *types.Event) er
221228
}
222229
// updateUpstream for real
223230
upsName := apisixv1.ComposeExternalUpstreamName(au.Namespace, au.Name)
224-
errRecord = c.updateUpstream(ctx, upsName, &au.Spec.ApisixUpstreamConfig, ev.Type.IsSyncEvent())
231+
errRecord = c.updateUpstream(ctx, upsName, &au.Spec.ApisixUpstreamConfig, ev.Type.IsSyncEvent(), svc.Spec.ClusterIP)
225232
if err == apisix.ErrNotFound {
226233
errRecord = fmt.Errorf("%s", "upstream doesn't exist. It will be created after ApisixRoute is created referencing it.")
227234
}
@@ -235,14 +242,6 @@ func (c *apisixUpstreamController) sync(ctx context.Context, ev *types.Event) er
235242
portLevelSettings[port.Port] = port.ApisixUpstreamConfig
236243
}
237244
}
238-
239-
svc, err := c.SvcLister.Services(namespace).Get(name)
240-
if err != nil {
241-
log.Errorf("failed to get service %s: %s", key, err)
242-
errRecord = err
243-
goto updateStatus
244-
}
245-
246245
var subsets []configv2.ApisixUpstreamSubset
247246
subsets = append(subsets, configv2.ApisixUpstreamSubset{})
248247
if len(au.Spec.Subsets) > 0 {
@@ -258,16 +257,7 @@ func (c *apisixUpstreamController) sync(ctx context.Context, ev *types.Event) er
258257
cfg = au.Spec.ApisixUpstreamConfig
259258
}
260259
}
261-
err := c.updateUpstream(ctx, apisixv1.ComposeUpstreamName(namespace, name, subset.Name, port.Port, types.ResolveGranularity.Endpoint), &cfg, ev.Type.IsSyncEvent())
262-
if err != nil {
263-
if err == apisix.ErrNotFound {
264-
errRecord = fmt.Errorf("%s", "upstream doesn't exist. It will be created after ApisixRoute is created referencing it.")
265-
} else {
266-
errRecord = err
267-
}
268-
goto updateStatus
269-
}
270-
err = c.updateUpstream(ctx, apisixv1.ComposeUpstreamName(namespace, name, subset.Name, port.Port, types.ResolveGranularity.Service), &cfg, ev.Type.IsSyncEvent())
260+
err := c.updateUpstream(ctx, apisixv1.ComposeUpstreamName(namespace, name, subset.Name, port.Port), &cfg, ev.Type.IsSyncEvent(), svc.Spec.ClusterIP)
271261
if err != nil {
272262
if err == apisix.ErrNotFound {
273263
errRecord = fmt.Errorf("%s", "upstream doesn't exist. It will be created after ApisixRoute is created referencing it.")
@@ -335,7 +325,7 @@ func (c *apisixUpstreamController) updateStatus(obj kube.ApisixUpstream, statusE
335325
}
336326
}
337327

338-
func (c *apisixUpstreamController) updateUpstream(ctx context.Context, upsName string, cfg *configv2.ApisixUpstreamConfig, shouldCompare bool) error {
328+
func (c *apisixUpstreamController) updateUpstream(ctx context.Context, upsName string, cfg *configv2.ApisixUpstreamConfig, shouldCompare bool, svcClusterIP string) error {
339329
// TODO: multi cluster
340330
clusterName := c.Config.APISIX.DefaultClusterName
341331

@@ -358,7 +348,24 @@ func (c *apisixUpstreamController) updateUpstream(ctx context.Context, upsName s
358348
}
359349

360350
newUps.Metadata = ups.Metadata
361-
newUps.Nodes = ups.Nodes
351+
352+
if cfg.Granularity == types.ResolveGranularity.Service {
353+
if svcClusterIP == "" {
354+
log.Errorw("ApisixRoute refers to a headless service but want to use the service level resolve granularity",
355+
zap.String("ApisixUpstream name", upsName),
356+
)
357+
return errors.New("conflict headless service and backend resolve granularity")
358+
}
359+
for _, node := range ups.Nodes {
360+
newUps.Nodes = append(newUps.Nodes, apisixv1.UpstreamNode{
361+
Host: svcClusterIP,
362+
Port: node.Port,
363+
Weight: node.Weight,
364+
})
365+
}
366+
} else {
367+
newUps.Nodes = ups.Nodes
368+
}
362369
log.Debugw("updating upstream since ApisixUpstream changed",
363370
zap.Any("upstream", newUps),
364371
zap.String("ApisixUpstream name", upsName),

pkg/providers/apisix/translation/apisix_plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (t *translator) translateTrafficSplitPlugin(ctx *translation.TranslateConte
4949
if err != nil {
5050
return nil, err
5151
}
52-
ups, err := t.translateService(ns, backend.ServiceName, backend.Subset, backend.ResolveGranularity, svcClusterIP, svcPort)
52+
ups, err := t.translateService(ns, backend.ServiceName, backend.Subset, svcClusterIP, svcPort)
5353
if err != nil {
5454
return nil, err
5555
}

pkg/providers/apisix/translation/apisix_plugin_test.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ func TestTranslateTrafficSplitPlugin(t *testing.T) {
146146
Type: intstr.Int,
147147
IntVal: 443,
148148
},
149-
ResolveGranularity: "service",
150-
Weight: &weight20,
149+
Weight: &weight20,
151150
},
152151
}
153152

@@ -543,14 +542,6 @@ func TestTranslateTrafficSplitPluginBadCases(t *testing.T) {
543542
assert.Nil(t, cfg)
544543
assert.NotNil(t, err)
545544
assert.Equal(t, "service.spec.ports: port not defined", err.Error())
546-
547-
backends[1].ServicePort.StrVal = "port2"
548-
backends[1].ResolveGranularity = "service"
549-
ctx = &translation.TranslateContext{UpstreamMap: make(map[string]struct{})}
550-
cfg, err = tr.translateTrafficSplitPlugin(ctx, ar1.Namespace, 30, backends)
551-
assert.Nil(t, cfg)
552-
assert.NotNil(t, err)
553-
assert.Equal(t, "conflict headless service and backend resolve granularity", err.Error())
554545
}
555546

556547
func TestTranslateConsumerKeyAuthPluginWithInPlaceValue(t *testing.T) {

pkg/providers/apisix/translation/apisix_route.go

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func (t *translator) translateHTTPRouteV2(ctx *translation.TranslateContext, ar
202202
return err
203203
}
204204

205-
upstreamName := apisixv1.ComposeUpstreamName(ar.Namespace, backend.ServiceName, backend.Subset, svcPort, backend.ResolveGranularity)
205+
upstreamName := apisixv1.ComposeUpstreamName(ar.Namespace, backend.ServiceName, backend.Subset, svcPort)
206206
route.UpstreamId = id.GenID(upstreamName)
207207

208208
if len(backends) > 0 {
@@ -221,7 +221,7 @@ func (t *translator) translateHTTPRouteV2(ctx *translation.TranslateContext, ar
221221
route.Plugins["traffic-split"] = plugin
222222
}
223223
if !ctx.CheckUpstreamExist(upstreamName) {
224-
ups, err := t.translateService(ar.Namespace, backend.ServiceName, backend.Subset, backend.ResolveGranularity, svcClusterIP, svcPort)
224+
ups, err := t.translateService(ar.Namespace, backend.ServiceName, backend.Subset, svcClusterIP, svcPort)
225225
if err != nil {
226226
return err
227227
}
@@ -484,9 +484,9 @@ func (t *translator) generateHTTPRouteV2DeleteMark(ctx *translation.TranslateCon
484484
// others will be configured in traffic-split plugin.
485485
backend := backends[0]
486486

487-
upstreamName := apisixv1.ComposeUpstreamName(ar.Namespace, backend.ServiceName, backend.Subset, backend.ServicePort.IntVal, backend.ResolveGranularity)
487+
upstreamName := apisixv1.ComposeUpstreamName(ar.Namespace, backend.ServiceName, backend.Subset, backend.ServicePort.IntVal)
488488
if !ctx.CheckUpstreamExist(upstreamName) {
489-
ups, err := t.generateUpstreamDeleteMark(ar.Namespace, backend.ServiceName, backend.Subset, backend.ServicePort.IntVal, backend.ResolveGranularity)
489+
ups, err := t.generateUpstreamDeleteMark(ar.Namespace, backend.ServiceName, backend.Subset, backend.ServicePort.IntVal)
490490
if err != nil {
491491
return err
492492
}
@@ -560,7 +560,7 @@ func (t *translator) translateStreamRouteV2(ctx *translation.TranslateContext, a
560560
sr.ID = id.GenID(name)
561561
sr.ServerPort = part.Match.IngressPort
562562
sr.SNI = part.Match.Host
563-
ups, err := t.translateService(ar.Namespace, backend.ServiceName, backend.Subset, backend.ResolveGranularity, svcClusterIP, svcPort)
563+
ups, err := t.translateService(ar.Namespace, backend.ServiceName, backend.Subset, svcClusterIP, svcPort)
564564
if err != nil {
565565
return err
566566
}
@@ -584,7 +584,7 @@ func (t *translator) generateStreamRouteDeleteMarkV2(ctx *translation.TranslateC
584584
sr.ID = id.GenID(name)
585585
sr.ServerPort = part.Match.IngressPort
586586
sr.SNI = part.Match.Host
587-
ups, err := t.generateUpstreamDeleteMark(ar.Namespace, backend.ServiceName, backend.Subset, backend.ServicePort.IntVal, backend.ResolveGranularity)
587+
ups, err := t.generateUpstreamDeleteMark(ar.Namespace, backend.ServiceName, backend.Subset, backend.ServicePort.IntVal)
588588
if err != nil {
589589
return err
590590
}
@@ -603,13 +603,6 @@ func (t *translator) GetServiceClusterIPAndPort(backend *configv2.ApisixRouteHTT
603603
return "", 0, err
604604
}
605605
svcPort := int32(-1)
606-
if backend.ResolveGranularity == "service" && svc.Spec.ClusterIP == "" {
607-
log.Errorw("ApisixRoute refers to a headless service but want to use the service level resolve granularity",
608-
zap.Any("namespace", ns),
609-
zap.Any("service", svc),
610-
)
611-
return "", 0, errors.New("conflict headless service and backend resolve granularity")
612-
}
613606
loop:
614607
for _, port := range svc.Spec.Ports {
615608
switch backend.ServicePort.Type {
@@ -643,13 +636,6 @@ func (t *translator) getStreamServiceClusterIPAndPortV2(backend configv2.ApisixR
643636
return "", 0, err
644637
}
645638
svcPort := int32(-1)
646-
if backend.ResolveGranularity == "service" && svc.Spec.ClusterIP == "" {
647-
log.Errorw("ApisixRoute refers to a headless service but want to use the service level resolve granularity",
648-
zap.String("ApisixRoute namespace", ns),
649-
zap.Any("service", svc),
650-
)
651-
return "", 0, errors.New("conflict headless service and backend resolve granularity")
652-
}
653639
loop:
654640
for _, port := range svc.Spec.Ports {
655641
switch backend.ServicePort.Type {

pkg/providers/apisix/translation/apisix_upstream.go

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,23 @@ import (
2525
v2 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2"
2626
"github.com/apache/apisix-ingress-controller/pkg/providers/translation"
2727
"github.com/apache/apisix-ingress-controller/pkg/providers/utils"
28-
"github.com/apache/apisix-ingress-controller/pkg/types"
2928
apisixv1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
3029
)
3130

3231
// generateUpstreamDeleteMark translates Upstream nodes with a loose way, only generate ID and Name for delete Event.
33-
func (t *translator) generateUpstreamDeleteMark(namespace, svcName, subset string, svcPort int32, resolveGranularity string) (*apisixv1.Upstream, error) {
32+
func (t *translator) generateUpstreamDeleteMark(namespace, svcName, subset string, svcPort int32) (*apisixv1.Upstream, error) {
3433
ups := &apisixv1.Upstream{}
35-
ups.Name = apisixv1.ComposeUpstreamName(namespace, svcName, subset, svcPort, resolveGranularity)
34+
ups.Name = apisixv1.ComposeUpstreamName(namespace, svcName, subset, svcPort)
3635
ups.ID = id.GenID(ups.Name)
3736
return ups, nil
3837
}
3938

40-
func (t *translator) translateService(namespace, svcName, subset, svcResolveGranularity, svcClusterIP string, svcPort int32) (*apisixv1.Upstream, error) {
39+
func (t *translator) translateService(namespace, svcName, subset, _ string, svcPort int32) (*apisixv1.Upstream, error) {
4140
ups, err := t.TranslateService(namespace, svcName, subset, svcPort)
4241
if err != nil {
4342
return nil, err
4443
}
45-
if svcResolveGranularity == types.ResolveGranularity.Service {
46-
ups.Nodes = apisixv1.UpstreamNodes{
47-
{
48-
Host: svcClusterIP,
49-
Port: int(svcPort),
50-
Weight: translation.DefaultWeight,
51-
},
52-
}
53-
}
54-
ups.Name = apisixv1.ComposeUpstreamName(namespace, svcName, subset, svcPort, svcResolveGranularity)
44+
ups.Name = apisixv1.ComposeUpstreamName(namespace, svcName, subset, svcPort)
5545
ups.ID = id.GenID(ups.Name)
5646
return ups, nil
5747
}

pkg/providers/gateway/translation/gateway_httproute.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"github.com/apache/apisix-ingress-controller/pkg/log"
2929
"github.com/apache/apisix-ingress-controller/pkg/providers/translation"
3030
"github.com/apache/apisix-ingress-controller/pkg/providers/utils"
31-
"github.com/apache/apisix-ingress-controller/pkg/types"
3231
apisixv1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
3332
)
3433

@@ -194,7 +193,7 @@ func (t *translator) TranslateGatewayHTTPRouteV1beta1(httpRoute *gatewayv1beta1.
194193
if err != nil {
195194
return nil, errors.Wrap(err, fmt.Sprintf("failed to translate Rules[%v].BackendRefs[%v]", i, j))
196195
}
197-
ups.Name = apisixv1.ComposeUpstreamName(ns, string(backend.Name), "", int32(*backend.Port), types.ResolveGranularity.Endpoint)
196+
ups.Name = apisixv1.ComposeUpstreamName(ns, string(backend.Name), "", int32(*backend.Port))
198197

199198
// APISIX limits max length of label value
200199
// https://github.com/apache/apisix/blob/5b95b85faea3094d5e466ee2d39a52f1f805abbb/apisix/schema_def.lua#L85

pkg/providers/gateway/translation/gateway_tcproute.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (t *translator) TranslateGatewayTCPRouteV1Alpha2(tcpRoute *gatewayv1alpha2.
4444
if err != nil {
4545
return nil, err
4646
}
47-
ups.Name = apisixv1.ComposeUpstreamName(ns, string(backend.Name), "", int32(*backend.Port), "")
47+
ups.Name = apisixv1.ComposeUpstreamName(ns, string(backend.Name), "", int32(*backend.Port))
4848
ups.ID = id.GenID(ups.Name)
4949
sr.UpstreamId = ups.ID
5050
ctx.AddStreamRoute(sr)

pkg/providers/gateway/translation/gateway_tlsroute.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"github.com/apache/apisix-ingress-controller/pkg/log"
2929
"github.com/apache/apisix-ingress-controller/pkg/providers/translation"
3030
"github.com/apache/apisix-ingress-controller/pkg/providers/utils"
31-
"github.com/apache/apisix-ingress-controller/pkg/types"
3231
apisixv1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
3332
)
3433

@@ -90,7 +89,7 @@ func (t *translator) TranslateGatewayTLSRouteV1Alpha2(tlsRoute *gatewayv1alpha2.
9089
if err != nil {
9190
return nil, errors.Wrap(err, fmt.Sprintf("failed to translate Rules[%v].BackendRefs[%v]", i, j))
9291
}
93-
ups.Name = apisixv1.ComposeUpstreamName(ns, string(backend.Name), "", int32(*backend.Port), types.ResolveGranularity.Endpoint)
92+
ups.Name = apisixv1.ComposeUpstreamName(ns, string(backend.Name), "", int32(*backend.Port))
9493

9594
ups.Labels["meta_namespace"] = utils.TruncateString(ns, 64)
9695
ups.Labels["meta_backend"] = utils.TruncateString(string(backend.Name), 64)

pkg/providers/gateway/translation/gateway_udproute.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"github.com/apache/apisix-ingress-controller/pkg/id"
2828
"github.com/apache/apisix-ingress-controller/pkg/log"
2929
"github.com/apache/apisix-ingress-controller/pkg/providers/translation"
30-
"github.com/apache/apisix-ingress-controller/pkg/types"
3130
apisixv1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
3231
)
3332

@@ -79,7 +78,7 @@ func (t *translator) TranslateGatewayUDPRouteV1Alpha2(udpRoute *gatewayv1alpha2.
7978
return nil, errors.Wrap(err, fmt.Sprintf("failed to translate Rules[%v].BackendRefs[%v]", i, j))
8079
}
8180
ups.Scheme = apisixv1.SchemeUDP
82-
ups.Name = apisixv1.ComposeUpstreamName(ns, string(backend.Name), "", int32(*backend.Port), types.ResolveGranularity.Endpoint)
81+
ups.Name = apisixv1.ComposeUpstreamName(ns, string(backend.Name), "", int32(*backend.Port))
8382
ups.ID = id.GenID(ups.Name)
8483

8584
sr.UpstreamId = ups.ID

pkg/providers/ingress/translation/translator.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ import (
4141
"github.com/apache/apisix-ingress-controller/pkg/log"
4242
apisixtranslation "github.com/apache/apisix-ingress-controller/pkg/providers/apisix/translation"
4343
"github.com/apache/apisix-ingress-controller/pkg/providers/translation"
44-
"github.com/apache/apisix-ingress-controller/pkg/types"
4544
apisixv1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
4645
)
4746

@@ -430,7 +429,7 @@ func (t *translator) translateDefaultUpstreamFromIngressV1(namespace string, bac
430429
portNumber = backend.Port.Number
431430
}
432431
ups := apisixv1.NewDefaultUpstream()
433-
ups.Name = apisixv1.ComposeUpstreamName(namespace, backend.Name, "", portNumber, types.ResolveGranularity.Endpoint)
432+
ups.Name = apisixv1.ComposeUpstreamName(namespace, backend.Name, "", portNumber)
434433
ups.ID = id.GenID(ups.Name)
435434
return ups
436435
}
@@ -460,7 +459,7 @@ func (t *translator) translateUpstreamFromIngressV1(namespace string, backend *n
460459
if err != nil {
461460
return nil, err
462461
}
463-
ups.Name = apisixv1.ComposeUpstreamName(namespace, backend.Name, "", svcPort, types.ResolveGranularity.Endpoint)
462+
ups.Name = apisixv1.ComposeUpstreamName(namespace, backend.Name, "", svcPort)
464463
ups.ID = id.GenID(ups.Name)
465464
return ups, nil
466465
}
@@ -483,7 +482,7 @@ func (t *translator) translateDefaultUpstreamFromIngressV1beta1(namespace string
483482
portNumber = svcPort.IntVal
484483
}
485484
ups := apisixv1.NewDefaultUpstream()
486-
ups.Name = apisixv1.ComposeUpstreamName(namespace, svcName, "", portNumber, types.ResolveGranularity.Endpoint)
485+
ups.Name = apisixv1.ComposeUpstreamName(namespace, svcName, "", portNumber)
487486
ups.ID = id.GenID(ups.Name)
488487
return ups
489488
}
@@ -514,7 +513,7 @@ func (t *translator) translateUpstreamFromIngressV1beta1(namespace string, svcNa
514513
if err != nil {
515514
return nil, err
516515
}
517-
ups.Name = apisixv1.ComposeUpstreamName(namespace, svcName, "", portNumber, types.ResolveGranularity.Endpoint)
516+
ups.Name = apisixv1.ComposeUpstreamName(namespace, svcName, "", portNumber)
518517
ups.ID = id.GenID(ups.Name)
519518
return ups, nil
520519
}

pkg/providers/k8s/endpoint/base.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
"github.com/apache/apisix-ingress-controller/pkg/providers/translation"
3232
providertypes "github.com/apache/apisix-ingress-controller/pkg/providers/types"
3333
"github.com/apache/apisix-ingress-controller/pkg/providers/utils"
34-
"github.com/apache/apisix-ingress-controller/pkg/types"
3534
apisixv1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1"
3635
)
3736

@@ -90,7 +89,7 @@ func (c *baseEndpointController) syncEndpoint(ctx context.Context, ep kube.Endpo
9089
zap.Int32("port", port.Port),
9190
)
9291
}
93-
name := apisixv1.ComposeUpstreamName(namespace, svcName, subset.Name, port.Port, types.ResolveGranularity.Endpoint)
92+
name := apisixv1.ComposeUpstreamName(namespace, svcName, subset.Name, port.Port)
9493
for _, cluster := range clusters {
9594
if err := c.SyncUpstreamNodesChangeToCluster(ctx, cluster, nodes, name); err != nil {
9695
return err

0 commit comments

Comments
 (0)