Skip to content

Commit

Permalink
Remove --since-time Flag in IPFIX Collector Log Retrieval
Browse files Browse the repository at this point in the history
This commit addresses the unnecessary use of the --since-time flag when fetching logs from the IPFIX collector Pod in the e2e test. The decision is based on two considerations: first, we already employ the current time for flow record filtering, obviating the need for this flag; second, potential time differences between the testbed and Kubernetes nodes or the time difference between k8s nodes could result in undesired log filtering. Additionally, a 2-second waiting time has been introduced before sending traffic to mitigate time difference issues."

Besides, for flows requiring correlation, such as inter-node traffic, if the records aren't received from both nodes, the record will remain in the queue for up to 3 cycles of aggregatorActiveFlowRecordTimeout. We've set the timeout to exporterActiveFlowExportTimeout plus aggregatorActiveFlowRecordTimeout multiplied by 3 to ensure stability in the interNode test and facilitate the timely observation of removal messages.

Signed-off-by: Yun-Tang Hsu <hsuy@vmware.com>
  • Loading branch information
yuntanghsu committed Nov 20, 2023
1 parent 2f8441b commit 94ab3f2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/e2e/flowaggregator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,8 @@ func checkRecordsForFlows(t *testing.T, data *TestData, srcIP string, dstIP stri
cmdStr += fmt.Sprintf(" -p %d", iperfSvcPort)
}
timeNow := time.Now()
// wait 2 seconds to mitigate the possibility that there is a time difference between the K8s Nodes.
time.Sleep(2 * time.Second)
stdout, _, err := data.RunCommandFromPod(data.testNamespace, "perftest-a", "iperf", []string{"bash", "-c", cmdStr})
require.NoErrorf(t, err, "Error when running iperf3 client: %v", err)
bwSlice, srcPort, _ := getBandwidthAndPorts(stdout)
Expand Down Expand Up @@ -1383,13 +1385,13 @@ func getUint64FieldFromRecord(t *testing.T, record string, field string) uint64
func getCollectorOutput(t *testing.T, srcIP, dstIP, srcPort string, isDstService bool, checkAllRecords bool, isIPv6 bool, data *TestData, timeSince time.Time) (string, []string) {
var collectorOutput string
var recordSlices []string
// In the ToExternalFlows test, flow record will arrive 5.5s (exporterActiveFlowExportTimeout+aggregatorActiveFlowRecordTimeout) after executing wget command
// We set the timeout to 9s (5.5s plus one more aggregatorActiveFlowRecordTimeout) to make the ToExternalFlows test more stable
err := wait.PollImmediate(500*time.Millisecond, exporterActiveFlowExportTimeout+aggregatorActiveFlowRecordTimeout*2, func() (bool, error) {
// For flows requiring correlation, such as inter-node traffic, if records aren't received from both nodes, the record will remain in the queue for up to 3 cycles of aggregatorActiveFlowRecordTimeout.
// To ensure stability in the interNode test and facilitate the timely observation of removal messages, we've set the timeout to exporterActiveFlowExportTimeout plus aggregatorActiveFlowRecordTimeout multiplied by 3.
err := wait.PollImmediate(500*time.Millisecond, exporterActiveFlowExportTimeout+aggregatorActiveFlowRecordTimeout*3, func() (bool, error) {
var rc int
var err error
// `pod-running-timeout` option is added to cover scenarios where ipfix flow-collector has crashed after being deployed
rc, collectorOutput, _, err = data.RunCommandOnNode(controlPlaneNodeName(), fmt.Sprintf("kubectl logs --pod-running-timeout=%v ipfix-collector -n %s --since-time %s", aggregatorInactiveFlowRecordTimeout.String(), data.testNamespace, timeSince.Format(time.RFC3339)))
rc, collectorOutput, _, err = data.RunCommandOnNode(controlPlaneNodeName(), fmt.Sprintf("kubectl logs --pod-running-timeout=%v ipfix-collector -n %s", aggregatorInactiveFlowRecordTimeout.String(), data.testNamespace))
if err != nil || rc != 0 {
return false, err
}
Expand Down

0 comments on commit 94ab3f2

Please sign in to comment.