Skip to content

Commit

Permalink
eip status状态切换缓慢 (#2256)
Browse files Browse the repository at this point in the history
Co-authored-by: yl4811 <yl4811@yealink.com>
  • Loading branch information
2 people authored and zhangbingbing committed Feb 22, 2023
1 parent 5603a98 commit 0f8c04e
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions pkg/controller/vpc_nat_gw_eip.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@ import (
"context"
"encoding/json"
"fmt"
"net"
"strings"
"time"

k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/types"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/tools/cache"
"k8s.io/klog/v2"
"net"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"strings"

kubeovnv1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1"
"github.com/kubeovn/kube-ovn/pkg/ovs"
Expand Down Expand Up @@ -270,10 +268,9 @@ func (c *Controller) handleResetIptablesEip(key string) error {
klog.V(3).Infof("handle reset eip %s", key)
var notUse bool
switch eip.Status.Nat {
case "fip":
case util.FipUsingEip:
notUse = true
case "dnat":
time.Sleep(10 * time.Second)
case util.DnatUsingEip:
// nat change eip not that fast
dnats, err := c.config.KubeOvnClient.KubeovnV1().IptablesDnatRules().List(context.Background(), metav1.ListOptions{
LabelSelector: fields.OneTermEqualSelector(util.VpcEipLabel, key).String(),
Expand All @@ -285,8 +282,7 @@ func (c *Controller) handleResetIptablesEip(key string) error {
if len(dnats.Items) == 0 {
notUse = true
}
case "snat":
time.Sleep(10 * time.Second)
case util.SnatUsingEip:
// nat change eip not that fast
snats, err := c.config.KubeOvnClient.KubeovnV1().IptablesSnatRules().List(context.Background(), metav1.ListOptions{
LabelSelector: fields.OneTermEqualSelector(util.VpcEipLabel, key).String(),
Expand Down

0 comments on commit 0f8c04e

Please sign in to comment.