Skip to content

Commit

Permalink
Bug fix for inter-node traffic
Browse files Browse the repository at this point in the history
In this commit, we do:

1. Set ReadyToSend to true for flows don’t need correlation.
2. Set areCorrelatedFieldsFilled to true for flows don’t belong to inter-node traffic. For flows need to do correlation, its areCorrelatedFieldsFilled will be set to true once the correlation job is finished.

Signed-off-by: Yun-Tang Hsu <hsuy@vmware.com>
  • Loading branch information
yuntanghsu committed Dec 18, 2023
1 parent 837050b commit e7eda4e
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions pkg/intermediate/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,22 @@ func (a *AggregationProcess) addOrUpdateRecordInMap(flowKey *FlowKey, record ent
klog.Warning("FlowType does not exist in current record.")
}
correlationRequired := isCorrelationRequired(flowType, record)

currTime := time.Now()
aggregationRecord, exist := a.flowKeyRecordMap[*flowKey]
if exist {
if flowTypeIE, _, exist := aggregationRecord.Record.GetInfoElementWithValue("flowType"); exist {
flowType = flowTypeIE.GetUnsigned8Value()
} else {
klog.Warning("FlowType does not exist in current record.")
}
prevCorrelationRequired := isCorrelationRequired(flowType, aggregationRecord.Record)
if prevCorrelationRequired && !correlationRequired {
delete(a.flowKeyRecordMap, *flowKey)
exist = false
} else if !prevCorrelationRequired && correlationRequired {
return nil
}
}
currTime := time.Now()
if exist {
if correlationRequired {
// Do correlation of records if record belongs to inter-node flow and
Expand Down Expand Up @@ -411,14 +424,9 @@ func (a *AggregationProcess) addOrUpdateRecordInMap(flowKey *FlowKey, record ent

if !correlationRequired {
aggregationRecord.ReadyToSend = true
// If no correlation is required for an Inter-Node record, K8s metadata is
// expected to be not completely filled. For Intra-Node flows and ToExternal
// flows, areCorrelatedFieldsFilled is set to true by default.
if flowType == registry.FlowTypeInterNode {
aggregationRecord.areCorrelatedFieldsFilled = false
} else {
aggregationRecord.areCorrelatedFieldsFilled = true
}
}
if flowType != registry.FlowTypeInterNode {
aggregationRecord.areCorrelatedFieldsFilled = true
}
aggregationRecord.areExternalFieldsFilled = false
// Push the record to the priority queue.
Expand Down

0 comments on commit e7eda4e

Please sign in to comment.