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 flaky integration test #169

Open
wants to merge 56 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
bd45b32
Add plural exception for NodeLatencyStats in stats API (#6490)
antoninbas Jun 27, 2024
bd0c2fe
Use create reactor for NodeLatencyStats fake client (#6492)
antoninbas Jun 27, 2024
7dc11be
Bump codecov/codecov-action from 3 to 4 (#5489)
dependabot[bot] Jun 27, 2024
a77f1e6
Support shared LoadBalancerIP for multiple Services (#6480)
tnqn Jun 28, 2024
3a18bab
Fix some typos and remove unused variables in ci/kind scripts (#6494)
hongliangl Jun 28, 2024
d029557
Fix codecov upload for Jenkins CI scripts (#6493)
antoninbas Jun 28, 2024
fc40157
[Windows] Optimize the containerized OVS installation (#6383)
wenyingd Jun 28, 2024
75699cf
Fix cleanup in TestOVSOtherConfig integration test (#6496)
antoninbas Jul 2, 2024
0d6f201
Update cloud job cleanup scripts for correct secret access (#6503)
XinShuYang Jul 5, 2024
68ab657
Fix install_cni_chaining not creating CNI conf correctly in some case…
tnqn Jul 8, 2024
1a76c5b
Remove references to VMware CLA in github-labels.md (#6495)
antoninbas Jul 8, 2024
19f54d0
Fix Prometheus metrics doc (#6514)
tnqn Jul 9, 2024
f73d2f0
Bump the golang-org-x group across 1 directory with 5 updates (#6512)
dependabot[bot] Jul 9, 2024
5dbb806
To support running ipv4 e2e tests in Kind (#6463)
KMAnju-2021 Jul 9, 2024
ff3f7a6
Exclude terminated Pods from group members (#6508)
tnqn Jul 9, 2024
67cd120
Update Antrea Windows requirements for containerd and Kubernetes (#6462)
XinShuYang Jul 10, 2024
f4ef620
Attach host interface to secondary bridge after clearing flow-restore…
wenyingd Jul 10, 2024
42a0aaa
Support building local kind Node image (#6399)
hjiajing Jul 11, 2024
5cee770
Ensure full functionality of AntreaProxy with proxyAll enabled when k…
hongliangl Jul 11, 2024
6e4ff87
[Windows] Fix access denied issue in OVS cert import (#6529)
wenyingd Jul 18, 2024
288ce62
Fix NodePortLocal rules being deleted incorrectly due to PodIP recycl…
tnqn Jul 18, 2024
63b8117
Update documents to replace AntreaProxy with Antrea Proxy (#6515)
hongliangl Jul 18, 2024
943d9b3
Support deploying one FRR container in Kind network (#6488)
hongliangl Jul 22, 2024
b8e6153
Bump aquasecurity/trivy-action from 0.23.0 to 0.24.0 (#6522)
dependabot[bot] Jul 22, 2024
70c4a09
Upgrade Helm from v3.8.1 to v3.15.2 (#6498)
luolanzone Jul 22, 2024
51fef50
Bump google.golang.org/grpc from 1.64.0 to 1.65.0 (#6502)
dependabot[bot] Jul 22, 2024
b5bfc5e
Update network-requirements.md for BGPPolicy requirements (#6482)
hongliangl Jul 23, 2024
e921a6e
Use "Topology Aware Routing" feature name in documentation (#6542)
rajnkamr Jul 24, 2024
96b876d
Bump github.com/osrg/gobgp/v3 from 3.27.0 to 3.28.0 (#6500)
dependabot[bot] Jul 25, 2024
0ca0a01
Add documentation for BGPPolicy API (#6524)
hongliangl Jul 25, 2024
905a8a6
Implement the controller for API BGPPolicy (#6203)
hongliangl Jul 25, 2024
fa1ceb7
Add BGPPolicy to docs/api.md (#6457)
hongliangl Jul 25, 2024
4d9953f
Add nodelatencystats REST implementation (#6479)
IRONICBo Jul 25, 2024
0a72491
Fix NodeLatencyMonitor not starting (#6552)
antoninbas Jul 26, 2024
1456fe0
Add e2e tests for BGPPolicy (#6523)
hongliangl Jul 26, 2024
d0ceaf9
e2e: run BGPPolicy test in kind job test-e2e-encap-all-features-enabl…
tnqn Jul 26, 2024
b71f6f1
Only try to build local image if K8s version is specified (#6555)
tnqn Jul 26, 2024
55b21e8
Update CHANGELOG for v2.1.0 release (#6556)
antrea-bot Jul 26, 2024
54f2684
Set VERSION to v2.2.0-dev (#6557)
tnqn Jul 26, 2024
a03c850
Bump github.com/onsi/gomega from 1.33.1 to 1.34.0 (#6553)
dependabot[bot] Jul 26, 2024
1907856
Use appropriate docker driver in Github worfklows (#6559)
antoninbas Jul 29, 2024
31665fd
Bump github.com/onsi/ginkgo/v2 from 2.19.0 to 2.19.1 (#6564)
dependabot[bot] Jul 30, 2024
6c05655
Add documentation for NodeLatencyMonitor feature (#6561)
antoninbas Jul 30, 2024
d2c7d1a
Bump github.com/onsi/gomega from 1.34.0 to 1.34.1 (#6572)
dependabot[bot] Jul 30, 2024
e9990f8
Add logs collection for the kind tests in jenkins (#6543)
KMAnju-2021 Jul 30, 2024
c414b1c
antctl: fix cluster checker image (#6565)
tnqn Aug 2, 2024
f5a9a2b
Improve L7Listener code in FlowExporter (#6576)
antoninbas Aug 2, 2024
f48b61e
antctl: unify checker image and make it configurable (#6579)
tnqn Aug 5, 2024
167b728
test: support go test arguments and interuptting containerized tests …
tnqn Aug 5, 2024
29f947c
Log Flow Aggregator version on start (#6581)
antoninbas Aug 5, 2024
bcc7505
Doc: ACNP Egress Rule Doesn't Support "from" (#6588)
edwardbadboy Aug 5, 2024
73bdda3
e2e: fix feature-gates being overridden when specified multiple times…
tnqn Aug 5, 2024
5979885
Bump the golang-org-x group with 4 updates (#6584)
dependabot[bot] Aug 5, 2024
ffa1af6
Use same MTU as uplink for bridge port (#6577)
antoninbas Aug 6, 2024
40eb055
Bump github.com/osrg/gobgp/v3 from 3.28.0 to 3.29.0 (#6585)
dependabot[bot] Aug 6, 2024
7c78d7b
Add error output to integration test TestGoBGPLifecycle
hongliangl Jun 27, 2024
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
Prev Previous commit
Next Next commit
Attach host interface to secondary bridge after clearing flow-restore…
…-wait flag

Antrea uses a global configuration flow-restore-wait='true' to ensure that OVS
OpenFlow entries can start working after the dependencies are ready. A
connectivity issue exists if a setup uses a Node's primary interface as the uplink
of the secondary network OVS bridge, before the flow-restore-wait option of
OVS is removed by antrea-agent.
This commit ensures agent attaches a host interface to the secondary OVS
bridge after the global flow-restore-wait option is removed.

Signed-off-by: Wenying Dong <wenyingd@vmware.com>
  • Loading branch information
wenyingd authored Jul 10, 2024
commit f4ef620b145f83d6d5a0d531818a4ca3ad880fd4
22 changes: 16 additions & 6 deletions cmd/antrea-agent/agent.go
Original file line number Diff line number Diff line change
@@ -731,14 +731,15 @@ func run(o *Options) error {
go ipamController.Run(stopCh)
}

var secondaryNetworkController *secondarynetwork.Controller
if features.DefaultFeatureGate.Enabled(features.SecondaryNetwork) {
defer secondarynetwork.RestoreHostInterfaceConfiguration(&o.config.SecondaryNetwork)
if err := secondarynetwork.Initialize(
secondaryNetworkController, err = secondarynetwork.NewController(
o.config.ClientConnection, o.config.KubeAPIServerOverride,
k8sClient, localPodInformer.Get(), nodeConfig.Name,
podUpdateChannel, stopCh,
&o.config.SecondaryNetwork, ovsdbConnection); err != nil {
return fmt.Errorf("failed to initialize secondary network: %v", err)
k8sClient, localPodInformer.Get(),
podUpdateChannel,
&o.config.SecondaryNetwork, ovsdbConnection)
if err != nil {
return fmt.Errorf("failed to create secondary network controller: %w", err)
}
}

@@ -864,6 +865,15 @@ func run(o *Options) error {
return fmt.Errorf("failed to connect uplink to OVS bridge: %w", err)
}
}
// secondaryNetworkController Initialize must be run after FlowRestoreComplete for the case that Node
// IPs are moved to the secondary OVS bridge
if features.DefaultFeatureGate.Enabled(features.SecondaryNetwork) {
defer secondaryNetworkController.Restore()
if err = secondaryNetworkController.Initialize(); err != nil {
return fmt.Errorf("failed to initialize secondary network: %v", err)
}
go secondaryNetworkController.Run(stopCh)
}

// statsCollector collects stats and reports to the antrea-controller periodically. For now it's only used for
// NetworkPolicy stats and Multicast stats.
109 changes: 109 additions & 0 deletions pkg/agent/secondarynetwork/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// Copyright 2024 Antrea Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package secondarynetwork

import (
"fmt"

"github.com/TomCodeLV/OVSDB-golang-lib/pkg/ovsdb"
netdefclient "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/client/clientset/versioned/typed/k8s.cni.cncf.io/v1"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/cache"
componentbaseconfig "k8s.io/component-base/config"
"k8s.io/klog/v2"

"antrea.io/antrea/pkg/agent/secondarynetwork/podwatch"
agentconfig "antrea.io/antrea/pkg/config/agent"
"antrea.io/antrea/pkg/ovs/ovsconfig"
"antrea.io/antrea/pkg/util/channel"
"antrea.io/antrea/pkg/util/k8s"
)

var (
newOVSBridgeFn = ovsconfig.NewOVSBridge
)

type Controller struct {
ovsBridgeClient ovsconfig.OVSBridgeClient
secNetConfig *agentconfig.SecondaryNetworkConfig
podController *podwatch.PodController
}

func NewController(
clientConnectionConfig componentbaseconfig.ClientConnectionConfiguration,
kubeAPIServerOverride string,
k8sClient clientset.Interface,
podInformer cache.SharedIndexInformer,
podUpdateSubscriber channel.Subscriber,
secNetConfig *agentconfig.SecondaryNetworkConfig, ovsdb *ovsdb.OVSDB,
) (*Controller, error) {
ovsBridgeClient, err := createOVSBridge(secNetConfig.OVSBridges, ovsdb)
if err != nil {
return nil, err
}

// Create the NetworkAttachmentDefinition client, which handles access to secondary network object
// definition from the API Server.
netAttachDefClient, err := createNetworkAttachDefClient(clientConnectionConfig, kubeAPIServerOverride)
if err != nil {
return nil, fmt.Errorf("NetworkAttachmentDefinition client creation failed: %v", err)
}

// Create podController to handle secondary network configuration for Pods with
// k8s.v1.cni.cncf.io/networks Annotation defined.
podWatchController, err := podwatch.NewPodController(
k8sClient, netAttachDefClient, podInformer,
podUpdateSubscriber, ovsBridgeClient)
if err != nil {
return nil, err
}
return &Controller{
ovsBridgeClient: ovsBridgeClient,
secNetConfig: secNetConfig,
podController: podWatchController}, nil
}

// Run starts the Pod controller for secondary networks.
func (c *Controller) Run(stopCh <-chan struct{}) {
c.podController.Run(stopCh)
}

// CreateNetworkAttachDefClient creates net-attach-def client handle from the given config.
func createNetworkAttachDefClient(config componentbaseconfig.ClientConnectionConfiguration, kubeAPIServerOverride string) (netdefclient.K8sCniCncfIoV1Interface, error) {
kubeConfig, err := k8s.CreateRestConfig(config, kubeAPIServerOverride)
if err != nil {
return nil, err
}

netAttachDefClient, err := netdefclient.NewForConfig(kubeConfig)
if err != nil {
return nil, err
}
return netAttachDefClient, nil
}

func createOVSBridge(bridges []agentconfig.OVSBridgeConfig, ovsdb *ovsdb.OVSDB) (ovsconfig.OVSBridgeClient, error) {
if len(bridges) == 0 {
return nil, nil
}
// Only one OVS bridge is supported.
bridgeConfig := bridges[0]
ovsBridgeClient := newOVSBridgeFn(bridgeConfig.BridgeName, ovsconfig.OVSDatapathSystem, ovsdb)
if err := ovsBridgeClient.Create(); err != nil {
return nil, fmt.Errorf("failed to create OVS bridge %s: %v", bridgeConfig.BridgeName, err)
}
klog.InfoS("OVS bridge created", "bridge", bridgeConfig.BridgeName)
return ovsBridgeClient, nil
}
91 changes: 11 additions & 80 deletions pkg/agent/secondarynetwork/init_linux.go
Original file line number Diff line number Diff line change
@@ -21,52 +21,28 @@ import (
"fmt"
"net"

"github.com/TomCodeLV/OVSDB-golang-lib/pkg/ovsdb"
netdefclient "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/client/clientset/versioned/typed/k8s.cni.cncf.io/v1"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/cache"
componentbaseconfig "k8s.io/component-base/config"
"k8s.io/klog/v2"

"antrea.io/antrea/pkg/agent/interfacestore"
"antrea.io/antrea/pkg/agent/secondarynetwork/podwatch"
"antrea.io/antrea/pkg/agent/util"
agentconfig "antrea.io/antrea/pkg/config/agent"
"antrea.io/antrea/pkg/ovs/ovsconfig"
"antrea.io/antrea/pkg/util/channel"
"antrea.io/antrea/pkg/util/k8s"
)

var (
// Funcs which will be overridden with mock funcs in tests.
interfaceByNameFn = net.InterfaceByName
newOVSBridgeFn = ovsconfig.NewOVSBridge
)

// Initialize sets up OVS bridges and starts the Pod controller for secondary networks.
func Initialize(
clientConnectionConfig componentbaseconfig.ClientConnectionConfiguration,
kubeAPIServerOverride string,
k8sClient clientset.Interface,
podInformer cache.SharedIndexInformer,
nodeName string,
podUpdateSubscriber channel.Subscriber,
stopCh <-chan struct{},
secNetConfig *agentconfig.SecondaryNetworkConfig, ovsdb *ovsdb.OVSDB) error {

ovsBridgeClient, err := createOVSBridge(secNetConfig.OVSBridges, ovsdb)
if err != nil {
return err
}

// Initialize sets up OVS bridges.
func (c *Controller) Initialize() error {
// We only support moving and restoring of interface configuration to OVS Bridge for the single physical interface case.
if len(secNetConfig.OVSBridges) != 0 {
phyInterfaces := make([]string, len(secNetConfig.OVSBridges[0].PhysicalInterfaces))
copy(phyInterfaces, secNetConfig.OVSBridges[0].PhysicalInterfaces)
if len(c.secNetConfig.OVSBridges) != 0 {
phyInterfaces := make([]string, len(c.secNetConfig.OVSBridges[0].PhysicalInterfaces))
copy(phyInterfaces, c.secNetConfig.OVSBridges[0].PhysicalInterfaces)
if len(phyInterfaces) == 1 {

bridgedName, _, err := util.PrepareHostInterfaceConnection(
ovsBridgeClient,
c.ovsBridgeClient,
phyInterfaces[0],
0,
map[string]interface{}{
@@ -78,49 +54,18 @@ func Initialize(
}
phyInterfaces[0] = bridgedName
}
if err = connectPhyInterfacesToOVSBridge(ovsBridgeClient, phyInterfaces); err != nil {
if err := connectPhyInterfacesToOVSBridge(c.ovsBridgeClient, phyInterfaces); err != nil {
return err
}
}

// Create the NetworkAttachmentDefinition client, which handles access to secondary network object
// definition from the API Server.
netAttachDefClient, err := createNetworkAttachDefClient(clientConnectionConfig, kubeAPIServerOverride)
if err != nil {
return fmt.Errorf("NetworkAttachmentDefinition client creation failed: %v", err)
}

// Create podController to handle secondary network configuration for Pods with
// k8s.v1.cni.cncf.io/networks Annotation defined.
if podWatchController, err := podwatch.NewPodController(
k8sClient, netAttachDefClient, podInformer,
podUpdateSubscriber, ovsBridgeClient); err != nil {
return err
} else {
go podWatchController.Run(stopCh)
}
return nil
}

// RestoreHostInterfaceConfiguration restores interface configuration from secondary-bridge back to host-interface.
func RestoreHostInterfaceConfiguration(secNetConfig *agentconfig.SecondaryNetworkConfig) {
if len(secNetConfig.OVSBridges) != 0 && len(secNetConfig.OVSBridges[0].PhysicalInterfaces) == 1 {
util.RestoreHostInterfaceConfiguration(secNetConfig.OVSBridges[0].BridgeName, secNetConfig.OVSBridges[0].PhysicalInterfaces[0])
}
}

func createOVSBridge(bridges []agentconfig.OVSBridgeConfig, ovsdb *ovsdb.OVSDB) (ovsconfig.OVSBridgeClient, error) {
if len(bridges) == 0 {
return nil, nil
// Restore restores interface configuration from secondary-bridge back to host-interface.
func (c *Controller) Restore() {
if len(c.secNetConfig.OVSBridges) != 0 && len(c.secNetConfig.OVSBridges[0].PhysicalInterfaces) == 1 {
util.RestoreHostInterfaceConfiguration(c.secNetConfig.OVSBridges[0].BridgeName, c.secNetConfig.OVSBridges[0].PhysicalInterfaces[0])
}
// Only one OVS bridge is supported.
bridgeConfig := bridges[0]
ovsBridgeClient := newOVSBridgeFn(bridgeConfig.BridgeName, ovsconfig.OVSDatapathSystem, ovsdb)
if err := ovsBridgeClient.Create(); err != nil {
return nil, fmt.Errorf("failed to create OVS bridge %s: %v", bridgeConfig.BridgeName, err)
}
klog.InfoS("OVS bridge created", "bridge", bridgeConfig.BridgeName)
return ovsBridgeClient, nil
}

func connectPhyInterfacesToOVSBridge(ovsBridgeClient ovsconfig.OVSBridgeClient, phyInterfaces []string) error {
@@ -146,17 +91,3 @@ func connectPhyInterfacesToOVSBridge(ovsBridgeClient ovsconfig.OVSBridgeClient,
}
return nil
}

// CreateNetworkAttachDefClient creates net-attach-def client handle from the given config.
func createNetworkAttachDefClient(config componentbaseconfig.ClientConnectionConfiguration, kubeAPIServerOverride string) (netdefclient.K8sCniCncfIoV1Interface, error) {
kubeConfig, err := k8s.CreateRestConfig(config, kubeAPIServerOverride)
if err != nil {
return nil, err
}

netAttachDefClient, err := netdefclient.NewForConfig(kubeConfig)
if err != nil {
return nil, err
}
return netAttachDefClient, nil
}
26 changes: 3 additions & 23 deletions pkg/agent/secondarynetwork/init_windows.go
Original file line number Diff line number Diff line change
@@ -17,30 +17,10 @@

package secondarynetwork

import (
"errors"

"github.com/TomCodeLV/OVSDB-golang-lib/pkg/ovsdb"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/cache"
componentbaseconfig "k8s.io/component-base/config"

agentconfig "antrea.io/antrea/pkg/config/agent"
"antrea.io/antrea/pkg/util/channel"
)

func Initialize(
clientConnectionConfig componentbaseconfig.ClientConnectionConfiguration,
kubeAPIServerOverride string,
k8sClient clientset.Interface,
podInformer cache.SharedIndexInformer,
nodeName string,
podUpdateSubscriber channel.Subscriber,
stopCh <-chan struct{},
secNetConfig *agentconfig.SecondaryNetworkConfig, ovsdb *ovsdb.OVSDB) error {
return errors.New("not supported on Windows")
func (c *Controller) Initialize() error {
return nil
}

func RestoreHostInterfaceConfiguration(secNetConfig *agentconfig.SecondaryNetworkConfig) {
func (c *Controller) Restore() {
// Not supported on Windows.
}
Loading