mirror of
https://github.com/alibaba/higress.git
synced 2026-03-17 00:40:48 +08:00
optimize destinationRule generate (#782)
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
@@ -673,6 +674,18 @@ func (m *IngressConfig) convertDestinationRule(configs []common.WrapperConfig) [
|
|||||||
|
|
||||||
out := make([]config.Config, 0, len(destinationRules))
|
out := make([]config.Config, 0, len(destinationRules))
|
||||||
for _, dr := range destinationRules {
|
for _, dr := range destinationRules {
|
||||||
|
sort.SliceStable(dr.DestinationRule.TrafficPolicy.PortLevelSettings, func(i, j int) bool {
|
||||||
|
portI := dr.DestinationRule.TrafficPolicy.PortLevelSettings[i].Port
|
||||||
|
portJ := dr.DestinationRule.TrafficPolicy.PortLevelSettings[j].Port
|
||||||
|
if portI == nil && portJ == nil {
|
||||||
|
return true
|
||||||
|
} else if portI == nil {
|
||||||
|
return true
|
||||||
|
} else if portJ == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return portI.Number < portJ.Number
|
||||||
|
})
|
||||||
drName := util.CreateDestinationRuleName(m.clusterId, dr.ServiceKey.Namespace, dr.ServiceKey.Name)
|
drName := util.CreateDestinationRuleName(m.clusterId, dr.ServiceKey.Namespace, dr.ServiceKey.Name)
|
||||||
out = append(out, config.Config{
|
out = append(out, config.Config{
|
||||||
Meta: config.Meta{
|
Meta: config.Meta{
|
||||||
|
|||||||
@@ -65,7 +65,12 @@ func (u upstreamTLS) Parse(annotations Annotations, config *Ingress, _ *GlobalCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
config.UpstreamTLS = upstreamTLSConfig
|
if upstreamTLSConfig.BackendProtocol == defaultBackendProtocol {
|
||||||
|
// no need destination rule when use HTTP protocol
|
||||||
|
config.UpstreamTLS = nil
|
||||||
|
} else {
|
||||||
|
config.UpstreamTLS = upstreamTLSConfig
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if proto, err := annotations.ParseStringASAP(backendProtocol); err == nil {
|
if proto, err := annotations.ParseStringASAP(backendProtocol); err == nil {
|
||||||
|
|||||||
@@ -33,6 +33,12 @@ func TestUpstreamTLSParse(t *testing.T) {
|
|||||||
input: Annotations{},
|
input: Annotations{},
|
||||||
expect: nil,
|
expect: nil,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
input: Annotations{
|
||||||
|
buildNginxAnnotationKey(backendProtocol): "HTTP",
|
||||||
|
},
|
||||||
|
expect: nil,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
input: Annotations{
|
input: Annotations{
|
||||||
buildNginxAnnotationKey(proxySSLSecret): "",
|
buildNginxAnnotationKey(proxySSLSecret): "",
|
||||||
|
|||||||
Reference in New Issue
Block a user