Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exporter benchmark failures #2994

Merged
merged 1 commit into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cmd/antrea-agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ func run(o *Options) error {
v4GroupCounter := proxytypes.NewGroupCounter(false, groupIDUpdates)
v6GroupCounter := proxytypes.NewGroupCounter(true, groupIDUpdates)

v4Enabled := config.IsIPv4Enabled(nodeConfig, networkConfig.TrafficEncapMode)
v6Enabled := config.IsIPv6Enabled(nodeConfig, networkConfig.TrafficEncapMode)
var proxier proxy.Proxier
if features.DefaultFeatureGate.Enabled(features.AntreaProxy) {
v4Enabled := config.IsIPv4Enabled(nodeConfig, networkConfig.TrafficEncapMode)
v6Enabled := config.IsIPv6Enabled(nodeConfig, networkConfig.TrafficEncapMode)
proxyAll := o.config.AntreaProxy.ProxyAll
skipServices := o.config.AntreaProxy.SkipServices

Expand Down Expand Up @@ -370,9 +370,11 @@ func run(o *Options) error {
nodeRouteController,
networkConfig.TrafficEncapMode,
nodeConfig,
v4Enabled,
v6Enabled,
serviceCIDRNet,
serviceCIDRNetv6,
&ovsDatapathType,
ovsDatapathType,
features.DefaultFeatureGate.Enabled(features.AntreaProxy),
networkPolicyController,
flowExporterOptions)
Expand Down
9 changes: 3 additions & 6 deletions pkg/agent/flowexporter/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ func prepareExporterInputArgs(collectorAddr, collectorProto, nodeName string) ex
}

func NewFlowExporter(ifaceStore interfacestore.InterfaceStore, proxier proxy.Proxier, k8sClient kubernetes.Interface, nodeRouteController *noderoute.Controller,
trafficEncapMode config.TrafficEncapModeType, nodeConfig *config.NodeConfig, serviceCIDRNet, serviceCIDRNetv6 *net.IPNet, ovsDatapathType *ovsconfig.OVSDatapathType,
proxyEnabled bool, npQuerier querier.AgentNetworkPolicyInfoQuerier, o *flowexporter.FlowExporterOptions) (*FlowExporter, error) {
trafficEncapMode config.TrafficEncapModeType, nodeConfig *config.NodeConfig, v4Enabled, v6Enabled bool, serviceCIDRNet, serviceCIDRNetv6 *net.IPNet,
ovsDatapathType ovsconfig.OVSDatapathType, proxyEnabled bool, npQuerier querier.AgentNetworkPolicyInfoQuerier, o *flowexporter.FlowExporterOptions) (*FlowExporter, error) {
// Initialize IPFIX registry
registry := ipfix.NewIPFIXRegistry()
registry.LoadRegistry()
Expand All @@ -162,10 +162,7 @@ func NewFlowExporter(ifaceStore interfacestore.InterfaceStore, proxier proxy.Pro
}
expInput := prepareExporterInputArgs(o.FlowCollectorAddr, o.FlowCollectorProto, nodeName)

v4Enabled := config.IsIPv4Enabled(nodeConfig, trafficEncapMode)
v6Enabled := config.IsIPv6Enabled(nodeConfig, trafficEncapMode)

connTrackDumper := connections.InitializeConnTrackDumper(nodeConfig, serviceCIDRNet, serviceCIDRNetv6, *ovsDatapathType, proxyEnabled)
connTrackDumper := connections.InitializeConnTrackDumper(nodeConfig, serviceCIDRNet, serviceCIDRNetv6, ovsDatapathType, proxyEnabled)
denyConnStore := connections.NewDenyConnectionStore(ifaceStore, proxier, o)
conntrackConnStore := connections.NewConntrackConnectionStore(connTrackDumper, v4Enabled, v6Enabled, npQuerier, ifaceStore, proxier, o)

Expand Down
38 changes: 36 additions & 2 deletions pkg/agent/flowexporter/exporter/exporter_perf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ import (
"time"

"github.com/golang/mock/gomock"
ipfixentities "github.com/vmware/go-ipfix/pkg/entities"
"github.com/vmware/go-ipfix/pkg/registry"
"k8s.io/klog/v2"

"antrea.io/antrea/pkg/agent/config"
"antrea.io/antrea/pkg/agent/flowexporter"
"antrea.io/antrea/pkg/agent/flowexporter/connections"
"antrea.io/antrea/pkg/agent/flowexporter/priorityqueue"
"antrea.io/antrea/pkg/ipfix"
)

const (
Expand Down Expand Up @@ -145,6 +146,39 @@ func BenchmarkExportDenyConns(b *testing.B) {

}

func NewFlowExporterForTest(o *flowexporter.FlowExporterOptions) *FlowExporter {
// Initialize IPFIX registry
registry := ipfix.NewIPFIXRegistry()
registry.LoadRegistry()

// Prepare input args for IPFIX exporting process.
nodeName := "test-node"
expInput := prepareExporterInputArgs(o.FlowCollectorAddr, o.FlowCollectorProto, nodeName)

v4Enabled := true
v6Enabled := false

denyConnStore := connections.NewDenyConnectionStore(nil, nil, o)
conntrackConnStore := connections.NewConntrackConnectionStore(nil, v4Enabled, v6Enabled, nil, nil, nil, o)

return &FlowExporter{
conntrackConnStore: conntrackConnStore,
denyConnStore: denyConnStore,
registry: registry,
v4Enabled: v4Enabled,
v6Enabled: v6Enabled,
exporterInput: expInput,
ipfixSet: ipfixentities.NewSet(false),
k8sClient: nil,
nodeRouteController: nil,
isNetworkPolicyOnly: false,
nodeName: nodeName,
conntrackPriorityQueue: conntrackConnStore.GetPriorityQueue(),
denyPriorityQueue: denyConnStore.GetPriorityQueue(),
expiredConns: make([]flowexporter.Connection, 0, maxConnsToExport*2),
}
}

func setupExporter(isConntrackConn bool) (*FlowExporter, error) {
var err error
collectorAddr, err := startLocalServer()
Expand All @@ -160,7 +194,7 @@ func setupExporter(isConntrackConn bool) (*FlowExporter, error) {
IdleFlowTimeout: testIdleFlowTimeout,
StaleConnectionTimeout: 1,
PollInterval: 1}
exp, _ := NewFlowExporter(nil, nil, nil, nil, config.TrafficEncapModeEncap, nil, nil, nil, nil, false, nil, o)
exp := NewFlowExporterForTest(o)
if isConntrackConn {
addConns(exp.conntrackConnStore, exp.conntrackConnStore.GetPriorityQueue())
} else {
Expand Down