From e9d9b3978e36941e477ba7f2f8c0050e2f81e023 Mon Sep 17 00:00:00 2001 From: Yongming Ding Date: Thu, 25 Mar 2021 17:12:17 -0700 Subject: [PATCH] Add flowType field for Flow Exporter In this PR, we implemented the logic of flowType value assignment. We distinguished Pod-To-Pod flows and Pod-To-External flows using the podCIDRs of all nodes in the k8s cluster. --- .../elk-flow-collector/logstash/ipfix.yml | 3 + ci/kind/test-e2e-kind.sh | 2 +- cmd/antrea-agent/agent.go | 3 +- docs/network-flow-visibility.md | 1 + go.mod | 3 +- go.sum | 8 +- .../noderoute/node_route_controller.go | 44 ++++++++++- .../noderoute/node_route_controller_test.go | 79 +++++++++++++++++-- pkg/agent/flowexporter/exporter/exporter.go | 32 +++++++- pkg/flowaggregator/flowaggregator.go | 2 + plugins/octant/go.sum | 6 +- test/e2e/flowaggregator_test.go | 9 +++ test/e2e/framework.go | 2 +- 13 files changed, 173 insertions(+), 21 deletions(-) diff --git a/build/yamls/elk-flow-collector/logstash/ipfix.yml b/build/yamls/elk-flow-collector/logstash/ipfix.yml index eb3c93d57d2..ea0ac1e1bb8 100644 --- a/build/yamls/elk-flow-collector/logstash/ipfix.yml +++ b/build/yamls/elk-flow-collector/logstash/ipfix.yml @@ -4118,3 +4118,6 @@ 135: - :uint64 - :reverseOctetDeltaCountFromDestinationNode + 137: + - :uint8 + - :flowType diff --git a/ci/kind/test-e2e-kind.sh b/ci/kind/test-e2e-kind.sh index f6ff3400f91..37c4dd35873 100755 --- a/ci/kind/test-e2e-kind.sh +++ b/ci/kind/test-e2e-kind.sh @@ -101,7 +101,7 @@ if $np; then manifest_args="$manifest_args --np --tun vxlan" fi -COMMON_IMAGES_LIST=("gcr.io/kubernetes-e2e-test-images/agnhost:2.8" "projects.registry.vmware.com/library/busybox" "projects.registry.vmware.com/antrea/nginx" "projects.registry.vmware.com/antrea/perftool" "projects.registry.vmware.com/antrea/ipfix-collector:v0.4.3") +COMMON_IMAGES_LIST=("gcr.io/kubernetes-e2e-test-images/agnhost:2.8" "projects.registry.vmware.com/library/busybox" "projects.registry.vmware.com/antrea/nginx" "projects.registry.vmware.com/antrea/perftool" "projects.registry.vmware.com/antrea/ipfix-collector:v0.4.7") for image in "${COMMON_IMAGES_LIST[@]}"; do docker pull $image done diff --git a/cmd/antrea-agent/agent.go b/cmd/antrea-agent/agent.go index 9265d92e96e..a73b9132d3f 100644 --- a/cmd/antrea-agent/agent.go +++ b/cmd/antrea-agent/agent.go @@ -365,7 +365,8 @@ func run(o *Options) error { o.config.EnableTLSToFlowAggregator, v4Enabled, v6Enabled, - k8sClient) + k8sClient, + nodeRouteController) if err != nil { return fmt.Errorf("error when creating IPFIX flow exporter: %v", err) } diff --git a/docs/network-flow-visibility.md b/docs/network-flow-visibility.md index e43b6ab3425..66e9ce3afa8 100644 --- a/docs/network-flow-visibility.md +++ b/docs/network-flow-visibility.md @@ -159,6 +159,7 @@ the flow. All the IEs used by the Antrea Flow Exporter are listed below: | ingressNetworkPolicyNamespace| 56506 | 111 | string | | egressNetworkPolicyName | 56506 | 112 | string | | egressNetworkPolicyNamespace | 56506 | 113 | string | +| flowType | 56506 | 137 | unsigned8 | ### Supported capabilities diff --git a/go.mod b/go.mod index 86e5210c24c..23b08d6634e 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,6 @@ require ( github.com/golang/protobuf v1.3.2 github.com/google/uuid v1.1.1 github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd - github.com/kr/text v0.2.0 // indirect github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect github.com/pkg/errors v0.9.1 github.com/prometheus/common v0.4.1 @@ -42,7 +41,7 @@ require ( github.com/stretchr/testify v1.6.1 github.com/ti-mo/conntrack v0.3.0 github.com/vishvananda/netlink v1.1.0 - github.com/vmware/go-ipfix v0.4.5 + github.com/vmware/go-ipfix v0.4.7 golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a golang.org/x/exp v0.0.0-20190312203227-4b39c73a6495 golang.org/x/mod v0.4.0 diff --git a/go.sum b/go.sum index b1ec43a9692..f5ca730d7e3 100644 --- a/go.sum +++ b/go.sum @@ -102,7 +102,6 @@ github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwc github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/d2g/dhcp4 v0.0.0-20170904100407-a1d1b6c41b1c/go.mod h1:Ct2BUK8SB0YC1SMSibvLzxjeJLnrYEVLULFNiHY9YfQ= github.com/d2g/dhcp4client v1.0.0/go.mod h1:j0hNfjhrt2SxUOw55nL0ATM/z4Yt3t2Kd1mW34z5W5s= github.com/d2g/dhcp4server v0.0.0-20181031114812-7d4a0a7f59a5/go.mod h1:Eo87+Kg/IX2hfWJfwxMzLyuSZyxSoAug2nGa1G2QAi8= @@ -251,9 +250,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE= github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= @@ -407,8 +405,8 @@ github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYp github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc/go.mod h1:ZjcWmFBXmLKZu9Nxj3WKYEafiSqer2rnvPr0en9UNpI= github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df h1:OviZH7qLw/7ZovXvuNyL3XQl8UFofeikI1NW1Gypu7k= github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= -github.com/vmware/go-ipfix v0.4.5 h1:EwG2bQXKT72IzMOsCcbvP1Po2PncLoSoPuYrHf3YrsI= -github.com/vmware/go-ipfix v0.4.5/go.mod h1:lQz3f4r2pZWo0q8s8BtZ0xo5fPSOYsYteqJgBASP69o= +github.com/vmware/go-ipfix v0.4.7 h1:zyKpsifh19Mdmo6FE3C2GooAWiiThX2JV+X4VdzqeZY= +github.com/vmware/go-ipfix v0.4.7/go.mod h1:lQz3f4r2pZWo0q8s8BtZ0xo5fPSOYsYteqJgBASP69o= github.com/wenyingd/ofnet v0.0.0-20210318032909-171b6795a2da h1:ragN21nQa4zKuCwR2UEbTXEAh3L2YN/Id5SCVkjjwdY= github.com/wenyingd/ofnet v0.0.0-20210318032909-171b6795a2da/go.mod h1:8mMMWAYBNUeTGXYKizOLETfN3WIbu3P5DgvS2jiXKdI= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8= diff --git a/pkg/agent/controller/noderoute/node_route_controller.go b/pkg/agent/controller/noderoute/node_route_controller.go index 4c0060c8a01..41f3650a691 100644 --- a/pkg/agent/controller/noderoute/node_route_controller.go +++ b/pkg/agent/controller/noderoute/node_route_controller.go @@ -52,6 +52,11 @@ const ( ovsExternalIDNodeName = "node-name" nodeRouteInfoPodCIDRIndexName = "podCIDR" + + defaultPodIPv4CIDRMaskSize = 24 + IPv4BitLen = 32 + defaultPodIPv6CIDRMaskSize = 64 + IPv6BitLen = 128 ) // Controller is responsible for setting up necessary IP routes and Openflow entries for inter-node traffic. @@ -97,7 +102,8 @@ func NewNodeRouteController( nodeLister: nodeInformer.Lister(), nodeListerSynced: nodeInformer.Informer().HasSynced, queue: workqueue.NewNamedRateLimitingQueue(workqueue.NewItemExponentialFailureRateLimiter(minRetryDelay, maxRetryDelay), "noderoute"), - installedNodes: cache.NewIndexer(nodeRouteInfoKeyFunc, cache.Indexers{nodeRouteInfoPodCIDRIndexName: nodeRouteInfoPodCIDRIndexFunc})} + installedNodes: cache.NewIndexer(nodeRouteInfoKeyFunc, cache.Indexers{nodeRouteInfoPodCIDRIndexName: nodeRouteInfoPodCIDRIndexFunc}), + } nodeInformer.Informer().AddEventHandlerWithResyncPeriod( cache.ResourceEventHandlerFuncs{ AddFunc: func(cur interface{}) { @@ -615,3 +621,39 @@ func GetNodeAddr(node *corev1.Node) (net.IP, error) { } return ipAddr, nil } + +func (c *Controller) IPInPodSubnets(ip net.IP) bool { + var ipCIDR *net.IPNet + var curNodeCIDRStr string + if ip.To4() != nil { + var podIPv4CIDRMaskSize int + if c.nodeConfig.PodIPv4CIDR != nil { + curNodeCIDRStr = c.nodeConfig.PodIPv4CIDR.String() + podIPv4CIDRMaskSize, _ = c.nodeConfig.PodIPv4CIDR.Mask.Size() + } else { + podIPv4CIDRMaskSize = defaultPodIPv4CIDRMaskSize + } + v4Mask := net.CIDRMask(podIPv4CIDRMaskSize, IPv4BitLen) + ipCIDR = &net.IPNet{ + IP: ip.Mask(v4Mask), + Mask: v4Mask, + } + + } else { + var podIPv6CIDRMaskSize int + if c.nodeConfig.PodIPv6CIDR != nil { + curNodeCIDRStr = c.nodeConfig.PodIPv6CIDR.String() + podIPv6CIDRMaskSize, _ = c.nodeConfig.PodIPv6CIDR.Mask.Size() + } else { + podIPv6CIDRMaskSize = defaultPodIPv6CIDRMaskSize + } + v6Mask := net.CIDRMask(podIPv6CIDRMaskSize, IPv6BitLen) + ipCIDR = &net.IPNet{ + IP: ip.Mask(v6Mask), + Mask: v6Mask, + } + } + ipCIDRStr := ipCIDR.String() + nodeInCluster, _ := c.installedNodes.ByIndex(nodeRouteInfoPodCIDRIndexName, ipCIDRStr) + return len(nodeInCluster) > 0 || ipCIDRStr == curNodeCIDRStr +} diff --git a/pkg/agent/controller/noderoute/node_route_controller_test.go b/pkg/agent/controller/noderoute/node_route_controller_test.go index 26ed85c1d77..adf43e72861 100644 --- a/pkg/agent/controller/noderoute/node_route_controller_test.go +++ b/pkg/agent/controller/noderoute/node_route_controller_test.go @@ -22,6 +22,7 @@ import ( "github.com/containernetworking/plugins/pkg/ip" "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/informers" @@ -35,11 +36,13 @@ import ( ) var ( - gatewayMAC, _ = net.ParseMAC("00:00:00:00:00:01") - _, podCIDR, _ = net.ParseCIDR("1.1.1.0/24") - podCIDRGateway = ip.NextIP(podCIDR.IP) - nodeIP1 = net.ParseIP("10.10.10.10") - nodeIP2 = net.ParseIP("10.10.10.11") + gatewayMAC, _ = net.ParseMAC("00:00:00:00:00:01") + _, podCIDR, _ = net.ParseCIDR("1.1.1.0/24") + _, podCIDR2, _ = net.ParseCIDR("1.1.2.0/24") + podCIDRGateway = ip.NextIP(podCIDR.IP) + podCIDR2Gateway = ip.NextIP(podCIDR2.IP) + nodeIP1 = net.ParseIP("10.10.10.10") + nodeIP2 = net.ParseIP("10.10.10.11") ) type fakeController struct { @@ -158,3 +161,69 @@ func TestControllerWithDuplicatePodCIDR(t *testing.T) { case <-finishCh: } } + +func TestIPInPodSubnets(t *testing.T) { + c, closeFn := newController(t) + defer closeFn() + defer c.queue.ShutDown() + + stopCh := make(chan struct{}) + defer close(stopCh) + c.informerFactory.Start(stopCh) + // Must wait for cache sync, otherwise resource creation events will be missing if the resources are created + // in-between list and watch call of an informer. This is because fake clientset doesn't support watching with + // resourceVersion. A watcher of fake clientset only gets events that happen after the watcher is created. + c.informerFactory.WaitForCacheSync(stopCh) + + node1 := &corev1.Node{ + ObjectMeta: metav1.ObjectMeta{ + Name: "node1", + }, + Spec: corev1.NodeSpec{ + PodCIDR: podCIDR.String(), + PodCIDRs: []string{podCIDR.String()}, + }, + Status: corev1.NodeStatus{ + Addresses: []corev1.NodeAddress{ + { + Type: corev1.NodeInternalIP, + Address: nodeIP1.String(), + }, + }, + }, + } + node2 := &corev1.Node{ + ObjectMeta: metav1.ObjectMeta{ + Name: "node2", + }, + Spec: corev1.NodeSpec{ + PodCIDR: podCIDR2.String(), + PodCIDRs: []string{podCIDR2.String()}, + }, + Status: corev1.NodeStatus{ + Addresses: []corev1.NodeAddress{ + { + Type: corev1.NodeInternalIP, + Address: nodeIP2.String(), + }, + }, + }, + } + + c.clientset.CoreV1().Nodes().Create(context.TODO(), node1, metav1.CreateOptions{}) + // The 2nd argument is Any() because the argument is unpredictable when it uses pointer as the key of map. + // The argument type is map[*net.IPNet]net.IP. + c.ofClient.EXPECT().InstallNodeFlows("node1", gomock.Any(), nodeIP1, uint32(0)).Times(1) + c.routeClient.EXPECT().AddRoutes(podCIDR, "node1", nodeIP1, podCIDRGateway).Times(1) + c.processNextWorkItem() + + c.clientset.CoreV1().Nodes().Create(context.TODO(), node2, metav1.CreateOptions{}) + c.ofClient.EXPECT().InstallNodeFlows("node2", gomock.Any(), nodeIP2, uint32(0)).Times(1) + c.routeClient.EXPECT().AddRoutes(podCIDR2, "node2", nodeIP2, podCIDR2Gateway).Times(1) + c.processNextWorkItem() + + assert.Equal(t, true, c.Controller.IPInPodSubnets(net.ParseIP("1.1.1.1"))) + assert.Equal(t, true, c.Controller.IPInPodSubnets(net.ParseIP("1.1.2.1"))) + assert.Equal(t, false, c.Controller.IPInPodSubnets(net.ParseIP("10.10.10.10"))) + assert.Equal(t, false, c.Controller.IPInPodSubnets(net.ParseIP("8.8.8.8"))) +} diff --git a/pkg/agent/flowexporter/exporter/exporter.go b/pkg/agent/flowexporter/exporter/exporter.go index e9789a8e1c1..c9a29a12aa8 100644 --- a/pkg/agent/flowexporter/exporter/exporter.go +++ b/pkg/agent/flowexporter/exporter/exporter.go @@ -27,9 +27,11 @@ import ( "k8s.io/client-go/kubernetes" "k8s.io/klog" + "github.com/vmware-tanzu/antrea/pkg/agent/controller/noderoute" "github.com/vmware-tanzu/antrea/pkg/agent/flowexporter" "github.com/vmware-tanzu/antrea/pkg/agent/flowexporter/connections" "github.com/vmware-tanzu/antrea/pkg/agent/flowexporter/flowrecords" + "github.com/vmware-tanzu/antrea/pkg/agent/openflow" "github.com/vmware-tanzu/antrea/pkg/ipfix" "github.com/vmware-tanzu/antrea/pkg/util/env" ) @@ -69,6 +71,7 @@ var ( "ingressNetworkPolicyNamespace", "egressNetworkPolicyName", "egressNetworkPolicyNamespace", + "flowType", } AntreaInfoElementsIPv4 = append(antreaInfoElementsCommon, []string{"destinationClusterIPv4"}...) AntreaInfoElementsIPv6 = append(antreaInfoElementsCommon, []string{"destinationClusterIPv6"}...) @@ -97,6 +100,7 @@ type flowExporter struct { idleFlowTimeout time.Duration enableTLSToFlowAggregator bool k8sClient kubernetes.Interface + nodeRouteController *noderoute.Controller } func genObservationID() (uint32, error) { @@ -126,7 +130,8 @@ func prepareExporterInputArgs(collectorAddr, collectorProto string) (exporter.Ex func NewFlowExporter(connStore connections.ConnectionStore, records *flowrecords.FlowRecords, collectorAddr string, collectorProto string, activeFlowTimeout time.Duration, idleFlowTimeout time.Duration, - enableTLSToFlowAggregator bool, v4Enabled bool, v6Enabled bool, k8sClient kubernetes.Interface) (*flowExporter, error) { + enableTLSToFlowAggregator bool, v4Enabled bool, v6Enabled bool, k8sClient kubernetes.Interface, + nodeRouteController *noderoute.Controller) (*flowExporter, error) { // Initialize IPFIX registry registry := ipfix.NewIPFIXRegistry() registry.LoadRegistry() @@ -136,6 +141,7 @@ func NewFlowExporter(connStore connections.ConnectionStore, records *flowrecords if err != nil { return nil, err } + return &flowExporter{ connStore: connStore, flowRecords: records, @@ -148,6 +154,7 @@ func NewFlowExporter(connStore connections.ConnectionStore, records *flowrecords ipfixSet: ipfix.NewSet(false), enableTLSToFlowAggregator: enableTLSToFlowAggregator, k8sClient: k8sClient, + nodeRouteController: nodeRouteController, }, nil } @@ -517,6 +524,8 @@ func (exp *flowExporter) addRecordToSet(record flowexporter.FlowRecord) error { ie.Value = record.Conn.EgressNetworkPolicyName case "egressNetworkPolicyNamespace": ie.Value = record.Conn.EgressNetworkPolicyNamespace + case "flowType": + ie.Value = exp.findFlowType(record) } } @@ -539,3 +548,24 @@ func (exp *flowExporter) sendDataSet() (int, error) { klog.V(4).Infof("Data set sent successfully. Bytes sent: %d", sentBytes) return sentBytes, nil } + +func (exp *flowExporter) findFlowType(record flowexporter.FlowRecord) uint8 { + if exp.nodeRouteController == nil { + klog.Warningf("Can't find flowType without nodeRouteController") + return 0 + } + if exp.nodeRouteController.IPInPodSubnets(record.Conn.TupleOrig.SourceAddress) { + if record.Conn.Mark == openflow.ServiceCTMark || exp.nodeRouteController.IPInPodSubnets(record.Conn.TupleOrig.DestinationAddress) { + if record.Conn.SourcePodName == "" || record.Conn.DestinationPodName == "" { + return ipfixregistry.InterNode + } + return ipfixregistry.IntraNode + } else { + return ipfixregistry.ToExternal + } + } else { + // We do not support External-To-Pod flows for now. + klog.Warningf("Source IP: %s doesn't exist in PodCIDRs", record.Conn.TupleOrig.SourceAddress.String()) + return 0 + } +} diff --git a/pkg/flowaggregator/flowaggregator.go b/pkg/flowaggregator/flowaggregator.go index 929dd9a957d..f62b10a4f13 100644 --- a/pkg/flowaggregator/flowaggregator.go +++ b/pkg/flowaggregator/flowaggregator.go @@ -64,6 +64,7 @@ var ( "ingressNetworkPolicyNamespace", "egressNetworkPolicyName", "egressNetworkPolicyNamespace", + "flowType", } antreaInfoElementsIPv4 = append(antreaInfoElementsCommon, []string{"destinationClusterIPv4"}...) antreaInfoElementsIPv6 = append(antreaInfoElementsCommon, []string{"destinationClusterIPv6"}...) @@ -75,6 +76,7 @@ var ( nonStatsElementList = []string{ "flowEndSeconds", + "flowEndReason", } statsElementList = []string{ "octetDeltaCount", diff --git a/plugins/octant/go.sum b/plugins/octant/go.sum index 112ae582b03..02d78d7798d 100644 --- a/plugins/octant/go.sum +++ b/plugins/octant/go.sum @@ -137,7 +137,6 @@ github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfc github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/d2g/dhcp4 v0.0.0-20170904100407-a1d1b6c41b1c/go.mod h1:Ct2BUK8SB0YC1SMSibvLzxjeJLnrYEVLULFNiHY9YfQ= github.com/d2g/dhcp4client v1.0.0/go.mod h1:j0hNfjhrt2SxUOw55nL0ATM/z4Yt3t2Kd1mW34z5W5s= github.com/d2g/dhcp4server v0.0.0-20181031114812-7d4a0a7f59a5/go.mod h1:Eo87+Kg/IX2hfWJfwxMzLyuSZyxSoAug2nGa1G2QAi8= @@ -401,9 +400,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE= github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= @@ -591,7 +589,7 @@ github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc/go.mod h1:ZjcWmF github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= github.com/vmware-tanzu/octant v0.16.1 h1:fkofB9oZ4yTqOaKf0JEhdibnIGBEOJ4OYOZL4Kli74A= github.com/vmware-tanzu/octant v0.16.1/go.mod h1:FhWXp2v0bgOQEwuOMOE49DXUu+uwWt8lXh7aOHtrA8A= -github.com/vmware/go-ipfix v0.4.5/go.mod h1:lQz3f4r2pZWo0q8s8BtZ0xo5fPSOYsYteqJgBASP69o= +github.com/vmware/go-ipfix v0.4.7/go.mod h1:lQz3f4r2pZWo0q8s8BtZ0xo5fPSOYsYteqJgBASP69o= github.com/wenyingd/ofnet v0.0.0-20201109024835-6fd225d8c8d1/go.mod h1:8mMMWAYBNUeTGXYKizOLETfN3WIbu3P5DgvS2jiXKdI= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xlab/handysort v0.0.0-20150421192137-fb3537ed64a1/go.mod h1:QcJo0QPSfTONNIgpN5RA8prR7fF8nkF6cTWTcNerRO8= diff --git a/test/e2e/flowaggregator_test.go b/test/e2e/flowaggregator_test.go index decc0f316c8..95af3997225 100644 --- a/test/e2e/flowaggregator_test.go +++ b/test/e2e/flowaggregator_test.go @@ -24,6 +24,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + ipfixregistry "github.com/vmware/go-ipfix/pkg/registry" corev1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1" networkingv1 "k8s.io/api/networking/v1" @@ -242,8 +243,10 @@ func checkRecordsForFlows(t *testing.T, data *TestData, srcIP string, dstIP stri // Check if record has both Pod name of source and destination pod. if isIntraNode { checkPodAndNodeData(t, record, "perftest-a", controlPlaneNodeName(), "perftest-b", controlPlaneNodeName()) + checkFlowType(t, record, ipfixregistry.IntraNode) } else { checkPodAndNodeData(t, record, "perftest-a", controlPlaneNodeName(), "perftest-c", workerNodeName(1)) + checkFlowType(t, record, ipfixregistry.InterNode) } if checkService { @@ -336,6 +339,12 @@ func checkBandwidthFromRecord(t *testing.T, record, bandwidth string) { } } +func checkFlowType(t *testing.T, record string, flowType uint8) { + if !strings.Contains(record, fmt.Sprintf("%s: %d", "flowType", flowType)) { + t.Errorf("Record does not have correct flowType") + } +} + func getRecordsFromOutput(output string) []string { re := regexp.MustCompile("(?m)^.*" + "#" + ".*$[\r\n]+") output = re.ReplaceAllString(output, "") diff --git a/test/e2e/framework.go b/test/e2e/framework.go index 7c712c3c9b0..ffd58b78494 100644 --- a/test/e2e/framework.go +++ b/test/e2e/framework.go @@ -98,7 +98,7 @@ const ( busyboxImage = "projects.registry.vmware.com/library/busybox" nginxImage = "projects.registry.vmware.com/antrea/nginx" perftoolImage = "projects.registry.vmware.com/antrea/perftool" - ipfixCollectorImage = "projects.registry.vmware.com/antrea/ipfix-collector:v0.4.3" + ipfixCollectorImage = "projects.registry.vmware.com/antrea/ipfix-collector:v0.4.7" ipfixCollectorPort = "4739" nginxLBService = "nginx-loadbalancer"