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

improve eip status switchover speed #2256

Merged
merged 1 commit into from
Jan 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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