Skip to content

Commit

Permalink
fix comment
Browse files Browse the repository at this point in the history
  • Loading branch information
zbb88888 committed Oct 23, 2023
1 parent b755a05 commit 54e69ba
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
22 changes: 15 additions & 7 deletions pkg/controller/ovn_dnat.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,16 +524,18 @@ func (c *Controller) patchOvnDnatAnnotations(key, eipName string) error {
}

func (c *Controller) patchOvnDnatStatus(key, vpcName, v4Eip, podIP string, ready bool) error {
oriDnat, err := c.ovnDnatRulesLister.Get(key)
if err != nil {
var (
oriDnat, dnat *kubeovnv1.OvnDnatRule
err error
)
if oriDnat, err = c.ovnDnatRulesLister.Get(key); err != nil {
if k8serrors.IsNotFound(err) {
return nil
}
klog.Error(err)
return err
}
dnat := oriDnat.DeepCopy()

dnat = oriDnat.DeepCopy()
var (
needUpdateLabel = false
changed bool
Expand Down Expand Up @@ -567,11 +569,17 @@ func (c *Controller) patchOvnDnatStatus(key, vpcName, v4Eip, podIP string, ready
changed = true
}

if (v4Eip != "" && dnat.Status.V4Eip != v4Eip) ||
(vpcName != "" && dnat.Status.Vpc != vpcName) ||
(podIP != "" && dnat.Status.V4Ip != podIP) {
if vpcName != "" && dnat.Status.Vpc != vpcName {
dnat.Status.Vpc = vpcName
changed = true
}

if v4Eip != "" && dnat.Status.V4Eip != v4Eip {
dnat.Status.V4Eip = v4Eip
changed = true
}

if podIP != "" && dnat.Status.V4Ip != podIP {
dnat.Status.V4Ip = podIP
changed = true
}
Expand Down
18 changes: 12 additions & 6 deletions test/e2e/ovn-vpc-nat-gw/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ var _ = framework.Describe("[group:ovn-vpc-nat-gw]", func() {
podClient = f.PodClient()

namespaceName = f.Namespace.Name

gwNodeNum := 2
// gw node is 2 means e2e HA cluster will have 2 gw nodes and a worker node
// in this env, tcpdump gw nat flows will be more clear

noBfdVpcName = "no-bfd-vpc-" + framework.RandomSuffix()
bfdVpcName = "bfd-vpc-" + framework.RandomSuffix()

Expand Down Expand Up @@ -160,15 +164,17 @@ var _ = framework.Describe("[group:ovn-vpc-nat-gw]", func() {
podEipName = fipPodName
podFipName = fipPodName

// nats use ip or cidr
// fip use ip addr
ipFipVipName = "ip-fip-vip-" + framework.RandomSuffix()
ipFipEipName = "ip-fip-eip-" + framework.RandomSuffix()
ipFipName = "ip-fip-" + framework.RandomSuffix()

// dnat use ip addr
ipDnatVipName = "ip-dnat-vip-" + framework.RandomSuffix()
ipDnatEipName = "ip-dnat-eip-" + framework.RandomSuffix()
ipDnatName = "ip-dnat-" + framework.RandomSuffix()

// snat use ip cidr
cidrSnatEipName = "cidr-snat-eip-" + framework.RandomSuffix()
cidrSnatName = "cidr-snat-" + framework.RandomSuffix()
ipSnatVipName = "ip-snat-vip-" + framework.RandomSuffix()
Expand Down Expand Up @@ -235,7 +241,7 @@ var _ = framework.Describe("[group:ovn-vpc-nat-gw]", func() {
framework.ExpectHaveKey(linkMap, node.ID)
linkMap[node.Name()] = linkMap[node.ID]
nodeNames = append(nodeNames, node.Name())
if index < 2 {
if index < gwNodeNum {
gwNodeNames = append(gwNodeNames, node.Name())
}
}
Expand Down Expand Up @@ -338,9 +344,9 @@ var _ = framework.Describe("[group:ovn-vpc-nat-gw]", func() {
ginkgo.By("Deleting ovn eip " + snatEipName)
ovnEipClient.DeleteSync(snatEipName)

ginkgo.By("Deleting ovn allowd address pair vip " + aapVip1Name)
ginkgo.By("Deleting ovn allowed address pair vip " + aapVip1Name)
vipClient.DeleteSync(aapVip1Name)
ginkgo.By("Deleting ovn allowd address pair vip " + aapVip2Name)
ginkgo.By("Deleting ovn allowed address pair vip " + aapVip2Name)

// clean up share eip case resource
ginkgo.By("Deleting share ovn dnat " + sharedEipDnatName)
Expand Down Expand Up @@ -522,8 +528,8 @@ var _ = framework.Describe("[group:ovn-vpc-nat-gw]", func() {
fipPod = podClient.CreateSync(fipPod)
podEip := framework.MakeOvnEip(podEipName, underlaySubnetName, "", "", "", "")
_ = ovnEipClient.CreateSync(podEip)
fipPodIp := ovs.PodNameToPortName(fipPod.Name, fipPod.Namespace, noBfdSubnet.Spec.Provider)
podFip := framework.MakeOvnFip(podFipName, podEipName, "", fipPodIp, "", "")
fipPodIP := ovs.PodNameToPortName(fipPod.Name, fipPod.Namespace, noBfdSubnet.Spec.Provider)
podFip := framework.MakeOvnFip(podFipName, podEipName, "", fipPodIP, "", "")
podFip = ovnFipClient.CreateSync(podFip)

ginkgo.By("1.1 Test fip dnat snat share eip by by setting eip name and ip name")
Expand Down

0 comments on commit 54e69ba

Please sign in to comment.