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

ci: fix ovn-vpc-nat-gw e2e failed #3503

Merged
merged 2 commits into from
Dec 12, 2023
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
22 changes: 18 additions & 4 deletions pkg/controller/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,15 @@ func checkAndUpdateExcludeIPs(subnet *kubeovnv1.Subnet) bool {

func (c *Controller) handleSubnetFinalizer(subnet *kubeovnv1.Subnet) (bool, error) {
if subnet.DeletionTimestamp.IsZero() && !util.ContainsString(subnet.Finalizers, util.ControllerName) {
subnet.Finalizers = append(subnet.Finalizers, util.ControllerName)
if _, err := c.config.KubeOvnClient.KubeovnV1().Subnets().Update(context.Background(), subnet, metav1.UpdateOptions{}); err != nil {
newSubnet := subnet.DeepCopy()
zcq98 marked this conversation as resolved.
Show resolved Hide resolved
newSubnet.Finalizers = append(newSubnet.Finalizers, util.ControllerName)
patch, err := util.GenerateMergePatchPayload(subnet, newSubnet)
if err != nil {
klog.Errorf("failed to generate patch payload for subnet '%s', %v", subnet.Name, err)
return false, err
}
if _, err := c.config.KubeOvnClient.KubeovnV1().Subnets().Patch(context.Background(), subnet.Name,
types.MergePatchType, patch, metav1.PatchOptions{}, ""); err != nil {
klog.Errorf("failed to add finalizer to subnet %s, %v", subnet.Name, err)
return false, err
}
Expand All @@ -496,8 +503,15 @@ func (c *Controller) handleSubnetFinalizer(subnet *kubeovnv1.Subnet) (bool, erro

u2oInterconnIP := subnet.Status.U2OInterconnectionIP
if !subnet.DeletionTimestamp.IsZero() && (usingIPs == 0 || (usingIPs == 1 && u2oInterconnIP != "")) {
subnet.Finalizers = util.RemoveString(subnet.Finalizers, util.ControllerName)
if _, err := c.config.KubeOvnClient.KubeovnV1().Subnets().Update(context.Background(), subnet, metav1.UpdateOptions{}); err != nil {
newSubnet := subnet.DeepCopy()
newSubnet.Finalizers = util.RemoveString(newSubnet.Finalizers, util.ControllerName)
patch, err := util.GenerateMergePatchPayload(subnet, newSubnet)
if err != nil {
klog.Errorf("failed to generate patch payload for subnet '%s', %v", subnet.Name, err)
return false, err
}
if _, err := c.config.KubeOvnClient.KubeovnV1().Subnets().Patch(context.Background(), subnet.Name,
types.MergePatchType, patch, metav1.PatchOptions{}, ""); err != nil {
klog.Errorf("failed to remove finalizer from subnet %s, %v", subnet.Name, err)
return false, err
}
Expand Down
19 changes: 14 additions & 5 deletions test/e2e/ovn-vpc-nat-gw/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ var _ = framework.Describe("[group:ovn-vpc-nat-gw]", func() {
var dockerNetwork, dockerExtraNetwork *dockertypes.NetworkResource
var nodeNames, gwNodeNames, providerBridgeIps, extraProviderBridgeIps []string
var clusterName, providerNetworkName, vlanName, underlaySubnetName, noBfdVpcName, bfdVpcName, noBfdSubnetName, bfdSubnetName string
var providerExtraNetworkName, underlayExtraSubnetName, noBfdExtraSubnetName string
var providerExtraNetworkName, vlanExtraName, underlayExtraSubnetName, noBfdExtraSubnetName string
var linkMap, extraLinkMap map[string]*iproute.Link
var providerNetworkClient *framework.ProviderNetworkClient
var vlanClient *framework.VlanClient
Expand Down Expand Up @@ -158,6 +158,7 @@ var _ = framework.Describe("[group:ovn-vpc-nat-gw]", func() {
providerNetworkName = "external"
providerExtraNetworkName = "extra"
vlanName = "vlan-" + framework.RandomSuffix()
vlanExtraName = "vlan-extra-" + framework.RandomSuffix()
underlaySubnetName = "external"
underlayExtraSubnetName = "extra"

Expand Down Expand Up @@ -469,6 +470,8 @@ var _ = framework.Describe("[group:ovn-vpc-nat-gw]", func() {

ginkgo.By("Deleting vlan " + vlanName)
vlanClient.Delete(vlanName, metav1.DeleteOptions{})
ginkgo.By("Deleting extra vlan " + vlanExtraName)
vlanClient.Delete(vlanExtraName, metav1.DeleteOptions{})

ginkgo.By("Deleting provider network " + providerNetworkName)
providerNetworkClient.DeleteSync(providerNetworkName)
Expand Down Expand Up @@ -692,6 +695,10 @@ var _ = framework.Describe("[group:ovn-vpc-nat-gw]", func() {
framework.ExpectNoError(err, "getting extra docker network "+dockerExtraNetworkName)
itFn(exchangeLinkName, providerExtraNetworkName, extraLinkMap, &extraProviderBridgeIps)

ginkgo.By("Creating underlay extra vlan " + vlanExtraName)
vlan = framework.MakeVlan(vlanExtraName, providerExtraNetworkName, 0)
_ = vlanClient.Create(vlan)

ginkgo.By("Creating extra underlay subnet " + underlayExtraSubnetName)
extracidr := make([]string, 0, 2)
extragateway := make([]string, 0, 2)
Expand Down Expand Up @@ -722,25 +729,26 @@ var _ = framework.Describe("[group:ovn-vpc-nat-gw]", func() {
}
extraVlanSubnetCidr := strings.Join(extracidr, ",")
extraVlanSubnetGw := strings.Join(extragateway, ",")
underlayExtraSubnet := framework.MakeSubnet(underlayExtraSubnetName, vlanName, extraVlanSubnetCidr, extraVlanSubnetGw, "", "", extraExcludeIPs, nil, nil)
underlayExtraSubnet := framework.MakeSubnet(underlayExtraSubnetName, vlanExtraName, extraVlanSubnetCidr, extraVlanSubnetGw, "", "", extraExcludeIPs, nil, nil)
_ = subnetClient.CreateSync(underlayExtraSubnet)
vlanExtraSubnet := subnetClient.Get(underlayExtraSubnetName)
ginkgo.By("Checking extra underlay vlan " + vlanExtraSubnet.Name)
framework.ExpectEqual(vlanExtraSubnet.Spec.Vlan, vlanName)
framework.ExpectEqual(vlanExtraSubnet.Spec.Vlan, vlanExtraName)
framework.ExpectNotEqual(vlanExtraSubnet.Spec.CIDRBlock, "")

ginkgo.By("1.3 Test custom vpc nats using extra centralized external gw")
noBfdExtraSubnetV4Cidr := "192.168.3.0/24"
noBfdExtraSubnetV4Gw := "192.168.3.1"

noBfdVpc = vpcClient.Get(noBfdVpcName)
cachedVpc := vpcClient.Get(noBfdVpcName)
noBfdVpc = cachedVpc.DeepCopy()
noBfdVpc.Spec.ExtraExternalSubnets = append(noBfdVpc.Spec.ExtraExternalSubnets, underlayExtraSubnetName)
noBfdVpc.Spec.StaticRoutes = append(noBfdVpc.Spec.StaticRoutes, &kubeovnv1.StaticRoute{
Policy: kubeovnv1.PolicySrc,
CIDR: noBfdExtraSubnetV4Cidr,
NextHopIP: gatewayV4,
})
_, err = vpcClient.Update(context.Background(), noBfdVpc, metav1.UpdateOptions{})
_ = vpcClient.PatchSync(cachedVpc, noBfdVpc, nil, 180*time.Second)
framework.ExpectNoError(err)

ginkgo.By("Creating overlay subnet " + noBfdExtraSubnetName)
Expand Down Expand Up @@ -1005,6 +1013,7 @@ var _ = framework.Describe("[group:ovn-vpc-nat-gw]", func() {

k8sNodes, err = e2enode.GetReadySchedulableNodes(context.Background(), cs)
framework.ExpectNoError(err)
time.Sleep(5 * time.Second)
for _, node := range k8sNodes.Items {
// label should be false after remove node external gw
framework.ExpectHaveKeyWithValue(node.Labels, util.NodeExtGwLabel, "false")
Expand Down
Loading