Skip to content

Commit

Permalink
cherry-pick #1331: fix: Using different protocols at the same time in…
Browse files Browse the repository at this point in the history
… ApisixUpstream (#1464)

Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com>
  • Loading branch information
tao12345666333 committed Nov 16, 2022
1 parent dd5acd3 commit a288408
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions pkg/ingress/apisix_upstream.go
Expand Up @@ -142,11 +142,11 @@ func (c *apisixUpstreamController) sync(ctx context.Context, ev *types.Event) er
case config.ApisixV2beta3:
au := multiVersioned.V2beta3()

var portLevelSettings map[int32]*configv2beta3.ApisixUpstreamConfig
var portLevelSettings map[int32]configv2beta3.ApisixUpstreamConfig
if au.Spec != nil && len(au.Spec.PortLevelSettings) > 0 {
portLevelSettings = make(map[int32]*configv2beta3.ApisixUpstreamConfig, len(au.Spec.PortLevelSettings))
portLevelSettings = make(map[int32]configv2beta3.ApisixUpstreamConfig, len(au.Spec.PortLevelSettings))
for _, port := range au.Spec.PortLevelSettings {
portLevelSettings[port.Port] = &port.ApisixUpstreamConfig
portLevelSettings[port.Port] = port.ApisixUpstreamConfig
}
}

Expand Down Expand Up @@ -182,10 +182,10 @@ func (c *apisixUpstreamController) sync(ctx context.Context, ev *types.Event) er
if au.Spec != nil && ev.Type != types.EventDelete {
cfg, ok := portLevelSettings[port.Port]
if !ok {
cfg = &au.Spec.ApisixUpstreamConfig
cfg = au.Spec.ApisixUpstreamConfig
}
// FIXME Same ApisixUpstreamConfig might be translated multiple times.
newUps, err = c.controller.translator.TranslateUpstreamConfigV2beta3(cfg)
newUps, err = c.controller.translator.TranslateUpstreamConfigV2beta3(&cfg)
if err != nil {
log.Errorw("found malformed ApisixUpstream",
zap.Any("object", au),
Expand Down Expand Up @@ -226,11 +226,11 @@ func (c *apisixUpstreamController) sync(ctx context.Context, ev *types.Event) er
case config.ApisixV2:
au := multiVersioned.V2()

var portLevelSettings map[int32]*configv2.ApisixUpstreamConfig
var portLevelSettings map[int32]configv2.ApisixUpstreamConfig
if au.Spec != nil && len(au.Spec.PortLevelSettings) > 0 {
portLevelSettings = make(map[int32]*configv2.ApisixUpstreamConfig, len(au.Spec.PortLevelSettings))
portLevelSettings = make(map[int32]configv2.ApisixUpstreamConfig, len(au.Spec.PortLevelSettings))
for _, port := range au.Spec.PortLevelSettings {
portLevelSettings[port.Port] = &port.ApisixUpstreamConfig
portLevelSettings[port.Port] = port.ApisixUpstreamConfig
}
}

Expand Down Expand Up @@ -266,10 +266,10 @@ func (c *apisixUpstreamController) sync(ctx context.Context, ev *types.Event) er
if au.Spec != nil && ev.Type != types.EventDelete {
cfg, ok := portLevelSettings[port.Port]
if !ok {
cfg = &au.Spec.ApisixUpstreamConfig
cfg = au.Spec.ApisixUpstreamConfig
}
// FIXME Same ApisixUpstreamConfig might be translated multiple times.
newUps, err = c.controller.translator.TranslateUpstreamConfigV2(cfg)
newUps, err = c.controller.translator.TranslateUpstreamConfigV2(&cfg)
if err != nil {
log.Errorw("found malformed ApisixUpstream",
zap.Any("object", au),
Expand Down

0 comments on commit a288408

Please sign in to comment.