mirror of
https://github.com/alibaba/higress.git
synced 2026-06-10 05:07:30 +08:00
fix mcp destination bug (#968)
This commit is contained in:
@@ -17,7 +17,6 @@ package ingress
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/alibaba/higress/pkg/cert"
|
|
||||||
"path"
|
"path"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
@@ -25,6 +24,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/alibaba/higress/pkg/cert"
|
||||||
|
|
||||||
"github.com/hashicorp/go-multierror"
|
"github.com/hashicorp/go-multierror"
|
||||||
networking "istio.io/api/networking/v1alpha3"
|
networking "istio.io/api/networking/v1alpha3"
|
||||||
"istio.io/istio/pilot/pkg/model"
|
"istio.io/istio/pilot/pkg/model"
|
||||||
@@ -890,15 +891,28 @@ func (c *controller) storeBackendTrafficPolicy(wrapper *common.WrapperConfig, ba
|
|||||||
}
|
}
|
||||||
if common.ValidateBackendResource(backend.Resource) && wrapper.AnnotationsConfig.Destination != nil {
|
if common.ValidateBackendResource(backend.Resource) && wrapper.AnnotationsConfig.Destination != nil {
|
||||||
for _, dest := range wrapper.AnnotationsConfig.Destination.McpDestination {
|
for _, dest := range wrapper.AnnotationsConfig.Destination.McpDestination {
|
||||||
|
portNumber := dest.Destination.GetPort().GetNumber()
|
||||||
serviceKey := common.ServiceKey{
|
serviceKey := common.ServiceKey{
|
||||||
Namespace: "mcp",
|
Namespace: "mcp",
|
||||||
Name: dest.Destination.Host,
|
Name: dest.Destination.Host,
|
||||||
|
Port: int32(portNumber),
|
||||||
ServiceFQDN: dest.Destination.Host,
|
ServiceFQDN: dest.Destination.Host,
|
||||||
}
|
}
|
||||||
if _, exist := store[serviceKey]; !exist {
|
if _, exist := store[serviceKey]; !exist {
|
||||||
store[serviceKey] = &common.WrapperTrafficPolicy{
|
if serviceKey.Port != 0 {
|
||||||
TrafficPolicy: &networking.TrafficPolicy{},
|
store[serviceKey] = &common.WrapperTrafficPolicy{
|
||||||
WrapperConfig: wrapper,
|
PortTrafficPolicy: &networking.TrafficPolicy_PortTrafficPolicy{
|
||||||
|
Port: &networking.PortSelector{
|
||||||
|
Number: uint32(serviceKey.Port),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
WrapperConfig: wrapper,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
store[serviceKey] = &common.WrapperTrafficPolicy{
|
||||||
|
TrafficPolicy: &networking.TrafficPolicy{},
|
||||||
|
WrapperConfig: wrapper,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -891,15 +891,28 @@ func (c *controller) storeBackendTrafficPolicy(wrapper *common.WrapperConfig, ba
|
|||||||
}
|
}
|
||||||
if common.ValidateBackendResource(backend.Resource) && wrapper.AnnotationsConfig.Destination != nil {
|
if common.ValidateBackendResource(backend.Resource) && wrapper.AnnotationsConfig.Destination != nil {
|
||||||
for _, dest := range wrapper.AnnotationsConfig.Destination.McpDestination {
|
for _, dest := range wrapper.AnnotationsConfig.Destination.McpDestination {
|
||||||
|
portNumber := dest.Destination.GetPort().GetNumber()
|
||||||
serviceKey := common.ServiceKey{
|
serviceKey := common.ServiceKey{
|
||||||
Namespace: "mcp",
|
Namespace: "mcp",
|
||||||
Name: dest.Destination.Host,
|
Name: dest.Destination.Host,
|
||||||
|
Port: int32(portNumber),
|
||||||
ServiceFQDN: dest.Destination.Host,
|
ServiceFQDN: dest.Destination.Host,
|
||||||
}
|
}
|
||||||
if _, exist := store[serviceKey]; !exist {
|
if _, exist := store[serviceKey]; !exist {
|
||||||
store[serviceKey] = &common.WrapperTrafficPolicy{
|
if serviceKey.Port != 0 {
|
||||||
TrafficPolicy: &networking.TrafficPolicy{},
|
store[serviceKey] = &common.WrapperTrafficPolicy{
|
||||||
WrapperConfig: wrapper,
|
PortTrafficPolicy: &networking.TrafficPolicy_PortTrafficPolicy{
|
||||||
|
Port: &networking.PortSelector{
|
||||||
|
Number: uint32(serviceKey.Port),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
WrapperConfig: wrapper,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
store[serviceKey] = &common.WrapperTrafficPolicy{
|
||||||
|
TrafficPolicy: &networking.TrafficPolicy{},
|
||||||
|
WrapperConfig: wrapper,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user