Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions pkg/providers/apisix/apisix_upstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,14 @@ func (c *apisixUpstreamController) sync(ctx context.Context, ev *types.Event) er
c.recordStatus(au, utils.ResourceSyncAborted, err, metav1.ConditionFalse, au.GetGeneration())
return err
}
var newUps *apisixv1.Upstream
newUps := apisixv1.NewDefaultUpstream()
if au.Spec != nil && ev.Type != types.EventDelete {
cfg, ok := portLevelSettings[port.Port]
if !ok {
cfg = au.Spec.ApisixUpstreamConfig
}
// FIXME Same ApisixUpstreamConfig might be translated multiple times.
newUps, err = c.translator.TranslateUpstreamConfigV2(&cfg)
if err != nil {
if err = c.translator.TranslateUpstreamConfigV2(&cfg, newUps); err != nil {
log.Errorw("ApisixUpstream conversion cannot be completed, or the format is incorrect",
zap.Any("object", au),
zap.Error(err),
Expand All @@ -295,8 +294,6 @@ func (c *apisixUpstreamController) sync(ctx context.Context, ev *types.Event) er
c.recordStatus(au, utils.ResourceSyncAborted, err, metav1.ConditionFalse, au.GetGeneration())
return err
}
} else {
newUps = apisixv1.NewDefaultUpstream()
}

newUps.Metadata = ups.Metadata
Expand Down
6 changes: 1 addition & 5 deletions pkg/providers/apisix/translation/apisix_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ func (t *translator) translateTrafficSplitPlugin(ctx *translation.TranslateConte
)

for _, backend := range backends {
svcClusterIP, svcPort, err := t.GetServiceClusterIPAndPort(&backend, ns)
if err != nil {
return nil, err
}
ups, err := t.translateService(ns, backend.ServiceName, backend.Subset, backend.ResolveGranularity, svcClusterIP, svcPort)
ups, err := t.TranslateUpstream(ns, backend.ServiceName, backend.Subset, backend.ResolveGranularity, backend.ServicePort)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/providers/apisix/translation/apisix_plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ func TestTranslateTrafficSplitPluginBadCases(t *testing.T) {
cfg, err = tr.translateTrafficSplitPlugin(ctx, ar1.Namespace, 30, backends)
assert.Nil(t, cfg)
assert.NotNil(t, err)
assert.Equal(t, "service.spec.ports: port not defined", err.Error())
assert.Contains(t, err.Error(), "service.Spec.Ports: port port-not-found not found")

backends[1].ServicePort.StrVal = "port2"
backends[1].ResolveGranularity = "service"
Expand Down
Loading