mirror of https://github.com/status-im/consul.git
Sort peer list in expander (#20167)
This commit is contained in:
parent
3fa4a21edd
commit
10baf87421
|
@ -5,6 +5,7 @@ package expander_ce
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"github.com/hashicorp/consul/internal/controller"
|
"github.com/hashicorp/consul/internal/controller"
|
||||||
expanderTypes "github.com/hashicorp/consul/internal/multicluster/internal/controllers/exportedservices/expander/types"
|
expanderTypes "github.com/hashicorp/consul/internal/multicluster/internal/controllers/exportedservices/expander/types"
|
||||||
|
@ -28,15 +29,17 @@ func (sg *SamenessGroupExpander) Expand(consumers []*pbmulticluster.ExportedServ
|
||||||
for _, c := range consumers {
|
for _, c := range consumers {
|
||||||
switch c.ConsumerTenancy.(type) {
|
switch c.ConsumerTenancy.(type) {
|
||||||
case *pbmulticluster.ExportedServicesConsumer_Peer:
|
case *pbmulticluster.ExportedServicesConsumer_Peer:
|
||||||
_, ok := peersMap[c.GetPeer()]
|
|
||||||
if !ok {
|
|
||||||
peers = append(peers, c.GetPeer())
|
|
||||||
peersMap[c.GetPeer()] = struct{}{}
|
peersMap[c.GetPeer()] = struct{}{}
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
panic("unexpected consumer tenancy type")
|
panic("unexpected consumer tenancy type")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for peer := range peersMap {
|
||||||
|
peers = append(peers, peer)
|
||||||
|
}
|
||||||
|
sort.Strings(peers)
|
||||||
|
|
||||||
return &expanderTypes.ExpandedConsumers{
|
return &expanderTypes.ExpandedConsumers{
|
||||||
Peers: peers,
|
Peers: peers,
|
||||||
}, nil
|
}, nil
|
||||||
|
|
Loading…
Reference in New Issue