From 02e888a80f2930ad2146f3419c8aa8ba47ccab99 Mon Sep 17 00:00:00 2001 From: ShawnLu Date: Thu, 30 Nov 2023 10:40:33 +0800 Subject: [PATCH] Bugfix: migrate vmi eip not exist in dst hyper ipset Vmi migrate, if vmi hyper change, vmi ip must change, check it if hyper change vmi ip not change, it means vmi info not sync finished. ISSUE: https://github.com/lucheng0127/kube-eip/issues/7 --- buildfile/operator/Dockerfile_operator | 1 + buildfile/operator/arp.go | 13 +++++++++++++ config/manager/kustomization.yaml | 2 +- internal/controller/eipbinding_controller.go | 7 +++++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 buildfile/operator/arp.go diff --git a/buildfile/operator/Dockerfile_operator b/buildfile/operator/Dockerfile_operator index 3fcf824..319acd3 100644 --- a/buildfile/operator/Dockerfile_operator +++ b/buildfile/operator/Dockerfile_operator @@ -17,6 +17,7 @@ COPY cmd/operator/main.go cmd/main.go COPY api/ api/ COPY internal/controller/ internal/controller/ COPY pkg/ pkg/ +COPY buildfile/operator/arp.go pkg/manager/arp.go # Build # the GOARCH has not a default value to allow the binary be built according to the host where the command diff --git a/buildfile/operator/arp.go b/buildfile/operator/arp.go new file mode 100644 index 0000000..90163d9 --- /dev/null +++ b/buildfile/operator/arp.go @@ -0,0 +1,13 @@ +package manager + +type ArpManager interface { + AddTarget(string) + DeleteTarget(string) + Poisoning() +} + +var ArpMgr ArpManager + +func RegisterAndRunArpManager(dev string) error { + return nil +} diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 3c279ca..dacd61d 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -5,4 +5,4 @@ kind: Kustomization images: - name: controller newName: quay.io/shawnlu0127/eipbinding_operator - newTag: "20231128" + newTag: "20231130" diff --git a/internal/controller/eipbinding_controller.go b/internal/controller/eipbinding_controller.go index 1ffc2b3..abf4e44 100644 --- a/internal/controller/eipbinding_controller.go +++ b/internal/controller/eipbinding_controller.go @@ -154,6 +154,13 @@ func (r *EipBindingReconciler) Reconcile(ctx context.Context, req ctrl.Request) return ctrl.Result{}, nil } + // For vmi, if hyper change, vmi ip must change, so if vmi ip not change + // it means vmi is migrate and the vmi info not sync finished + if eb.Spec.CurrentHyper != newHyper && eb.Spec.CurrentIPAddr == newIPAddr { + log.Info("VMI info not update finished, skip") + return ctrl.Result{}, nil + } + // Handle vmi info change staleHyper := eb.Spec.CurrentHyper staleIPAddr := eb.Spec.CurrentIPAddr