Record project continuation changes
This commit is contained in:
@@ -385,32 +385,37 @@ func (s *FabricFlowScheduler) ConfigureAdaptivePolicy(policy FabricServiceChanne
|
||||
}
|
||||
|
||||
func (s *FabricFlowScheduler) ScheduleClientPackets(packets [][]byte) []FabricScheduledPacketBatch {
|
||||
return s.scheduleClientPackets("", "", packets)
|
||||
scheduled, _ := s.scheduleClientPackets("", "", packets)
|
||||
return scheduled
|
||||
}
|
||||
|
||||
func (s *FabricFlowScheduler) ScheduleClientPacketsForConnection(vpnConnectionID string, packets [][]byte) []FabricScheduledPacketBatch {
|
||||
return s.scheduleClientPackets(vpnConnectionID, "", packets)
|
||||
scheduled, _ := s.scheduleClientPackets(vpnConnectionID, "", packets)
|
||||
return scheduled
|
||||
}
|
||||
|
||||
func (s *FabricFlowScheduler) ScheduleClientPacketsForConnectionClass(vpnConnectionID string, trafficClass string, packets [][]byte) []FabricScheduledPacketBatch {
|
||||
return s.scheduleClientPackets(vpnConnectionID, trafficClass, packets)
|
||||
scheduled, _ := s.scheduleClientPackets(vpnConnectionID, trafficClass, packets)
|
||||
return scheduled
|
||||
}
|
||||
|
||||
func (s *FabricFlowScheduler) scheduleClientPackets(vpnConnectionID string, trafficClass string, packets [][]byte) []FabricScheduledPacketBatch {
|
||||
func (s *FabricFlowScheduler) scheduleClientPackets(vpnConnectionID string, trafficClass string, packets [][]byte) ([]FabricScheduledPacketBatch, uint64) {
|
||||
packets = cleanPacketBatch(packets)
|
||||
if len(packets) == 0 {
|
||||
return nil
|
||||
return nil, 0
|
||||
}
|
||||
if s == nil {
|
||||
s = NewFabricFlowScheduler(0, 0)
|
||||
}
|
||||
trafficClass = normalizeFabricTrafficClass(trafficClass)
|
||||
grouped := map[string]*FabricScheduledPacketBatch{}
|
||||
var droppedCount uint64
|
||||
for _, packet := range packets {
|
||||
flowID, shard := classifyPacketFlow(packet, s.shardCountValue())
|
||||
channelID := fabricFlowChannelIDForClass(vpnConnectionID, trafficClass, shard)
|
||||
queueDepth, dropped := s.enqueue(channelID, trafficClass)
|
||||
if dropped {
|
||||
droppedCount++
|
||||
continue
|
||||
}
|
||||
batch := grouped[channelID]
|
||||
@@ -433,7 +438,7 @@ func (s *FabricFlowScheduler) scheduleClientPackets(vpnConnectionID string, traf
|
||||
out = append(out, *batch)
|
||||
}
|
||||
s.sortScheduledBatches(out)
|
||||
return out
|
||||
return out, droppedCount
|
||||
}
|
||||
|
||||
func fabricFlowChannelID(vpnConnectionID string, shard int) string {
|
||||
@@ -1441,11 +1446,9 @@ func (i *FabricClientPacketIngress) SendClientPacketBatchWithTrafficClass(ctx co
|
||||
}
|
||||
i.recordSendBatch(len(packets))
|
||||
scheduler := i.flowScheduler()
|
||||
droppedBefore := scheduler.Dropped()
|
||||
scheduled := scheduler.ScheduleClientPacketsForConnectionClass(vpnConnectionID, trafficClass, packets)
|
||||
droppedAfter := scheduler.Dropped()
|
||||
if droppedAfter > droppedBefore {
|
||||
i.recordFlowDropped(droppedAfter - droppedBefore)
|
||||
scheduled, droppedCount := scheduler.scheduleClientPackets(vpnConnectionID, trafficClass, packets)
|
||||
if droppedCount > 0 {
|
||||
i.recordFlowDropped(droppedCount)
|
||||
}
|
||||
if len(scheduled) == 0 {
|
||||
i.recordError(mesh.ErrSyntheticRelayQueueFull)
|
||||
@@ -1657,8 +1660,10 @@ func (i *FabricClientPacketIngress) routeCandidatesWithPreference(clusterID stri
|
||||
if i == nil || routesFunc == nil {
|
||||
return nil
|
||||
}
|
||||
localClusterID := i.clusterID()
|
||||
localNodeID := i.localNodeID()
|
||||
if clusterID == "" {
|
||||
clusterID = i.ClusterID
|
||||
clusterID = localClusterID
|
||||
}
|
||||
now := time.Now().UTC()
|
||||
var preferred []fabricClientRouteCandidate
|
||||
@@ -1676,7 +1681,7 @@ func (i *FabricClientPacketIngress) routeCandidatesWithPreference(clusterID stri
|
||||
}
|
||||
}
|
||||
for _, route := range routesFunc() {
|
||||
if route.ClusterID != clusterID || route.SourceNodeID != i.LocalNodeID || !containsString(route.AllowedChannels, mesh.ProductionChannelVPNPacket) {
|
||||
if route.ClusterID != clusterID || route.SourceNodeID != localNodeID || !containsString(route.AllowedChannels, mesh.ProductionChannelVPNPacket) {
|
||||
continue
|
||||
}
|
||||
if manager.isWithdrawn(route.RouteID) {
|
||||
@@ -1685,8 +1690,8 @@ func (i *FabricClientPacketIngress) routeCandidatesWithPreference(clusterID stri
|
||||
if !route.ExpiresAt.IsZero() && !route.ExpiresAt.After(now) {
|
||||
continue
|
||||
}
|
||||
nextHop := nextHopAfter(route.Hops, i.LocalNodeID, route.DestinationNodeID)
|
||||
if nextHop == "" || nextHop == i.LocalNodeID {
|
||||
nextHop := nextHopAfter(route.Hops, localNodeID, route.DestinationNodeID)
|
||||
if nextHop == "" || nextHop == localNodeID {
|
||||
continue
|
||||
}
|
||||
candidate := fabricClientRouteCandidate{Route: route, NextHop: nextHop}
|
||||
@@ -2024,7 +2029,7 @@ func (i *FabricClientPacketIngress) routeProvenance(clusterID string) map[string
|
||||
if i == nil || routesFunc == nil {
|
||||
return out
|
||||
}
|
||||
localNodeID := strings.TrimSpace(i.LocalNodeID)
|
||||
localNodeID := i.localNodeID()
|
||||
for _, route := range routesFunc() {
|
||||
if strings.TrimSpace(route.RouteID) == "" {
|
||||
continue
|
||||
@@ -2322,6 +2327,24 @@ func (i *FabricClientPacketIngress) routesFunc() func() []mesh.SyntheticRoute {
|
||||
return i.Routes
|
||||
}
|
||||
|
||||
func (i *FabricClientPacketIngress) clusterID() string {
|
||||
if i == nil {
|
||||
return ""
|
||||
}
|
||||
i.mu.Lock()
|
||||
defer i.mu.Unlock()
|
||||
return strings.TrimSpace(i.ClusterID)
|
||||
}
|
||||
|
||||
func (i *FabricClientPacketIngress) localNodeID() string {
|
||||
if i == nil {
|
||||
return ""
|
||||
}
|
||||
i.mu.Lock()
|
||||
defer i.mu.Unlock()
|
||||
return strings.TrimSpace(i.LocalNodeID)
|
||||
}
|
||||
|
||||
func (i *FabricClientPacketIngress) flowScheduler() *FabricFlowScheduler {
|
||||
if i == nil {
|
||||
return NewFabricFlowScheduler(0, 0)
|
||||
|
||||
Reference in New Issue
Block a user