Skip to content

Commit

Permalink
fix: should use domain-qualified finalizer name
Browse files Browse the repository at this point in the history
Signed-off-by: bobz965 <[email protected]>
  • Loading branch information
zbb88888 committed Feb 20, 2024
1 parent 71fa9c4 commit 7bf1343
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ func (c *Controller) syncIPCR() error {

for _, ipCR := range ips {
ip := ipCR.DeepCopy()
if ip.DeletionTimestamp != nil && slices.Contains(ip.Finalizers, util.ControllerName) {
if ip.DeletionTimestamp != nil && slices.Contains(ip.Finalizers, util.FinalizerName) {
klog.Infof("enqueue update for deleting ip %s", ip.Name)
c.updateIPQueue.Add(ip.Name)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ func (c *Controller) handleUpdateIP(key string) error {
klog.Infof("ip cr %s release ipam pod key %s from subnet %s", cachedIP.Name, podKey, cachedIP.Spec.Subnet)
c.ipam.ReleaseAddressByPod(podKey, cachedIP.Spec.Subnet)
}
if err = c.handleDelIPFinalizer(cachedIP, util.ControllerName); err != nil {
if err = c.handleDelIPFinalizer(cachedIP, util.FinalizerName); err != nil {
klog.Errorf("failed to handle del ip finalizer %v", err)
return err
}
Expand Down Expand Up @@ -535,7 +535,7 @@ func (c *Controller) createOrUpdateIPCR(ipCRName, podName, ip, mac, subnetName,
}
}

if err := c.handleAddIPFinalizer(ipCR, util.ControllerName); err != nil {
if err := c.handleAddIPFinalizer(ipCR, util.FinalizerName); err != nil {
klog.Errorf("failed to handle add ip finalizer %v", err)
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/ovn_dnat.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func (c *Controller) handleAddOvnDnatRule(key string) error {
return err
}

if err := c.handleAddOvnDnatFinalizer(cachedDnat, util.ControllerName); err != nil {
if err := c.handleAddOvnDnatFinalizer(cachedDnat, util.FinalizerName); err != nil {
klog.Errorf("failed to add finalizer for ovn dnat %s, %v", cachedDnat.Name, err)
return err
}
Expand Down Expand Up @@ -348,7 +348,7 @@ func (c *Controller) handleDelOvnDnatRule(key string) error {
return err
}
}
if err = c.handleDelOvnDnatFinalizer(cachedDnat, util.ControllerName); err != nil {
if err = c.handleDelOvnDnatFinalizer(cachedDnat, util.FinalizerName); err != nil {
klog.Errorf("failed to remove finalizer for ovn dnat %s, %v", cachedDnat.Name, err)
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/ovn_eip.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func (c *Controller) handleAddOvnEip(key string) error {
return err
}
}
if err = c.handleAddOvnEipFinalizer(cachedEip, util.ControllerName); err != nil {
if err = c.handleAddOvnEipFinalizer(cachedEip, util.FinalizerName); err != nil {
klog.Errorf("failed to add finalizer for ovn eip, %v", err)
return err
}
Expand Down Expand Up @@ -343,7 +343,7 @@ func (c *Controller) handleDelOvnEip(key string) error {
}
}

if err = c.handleDelOvnEipFinalizer(eip, util.ControllerName); err != nil {
if err = c.handleDelOvnEipFinalizer(eip, util.FinalizerName); err != nil {
klog.Errorf("failed to handle remove ovn eip finalizer , %v", err)
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/ovn_fip.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func (c *Controller) handleAddOvnFip(key string) error {
return err
}

if err = c.handleAddOvnFipFinalizer(cachedFip, util.ControllerName); err != nil {
if err = c.handleAddOvnFipFinalizer(cachedFip, util.FinalizerName); err != nil {
klog.Errorf("failed to add finalizer for ovn fip, %v", err)
return err
}
Expand Down Expand Up @@ -463,7 +463,7 @@ func (c *Controller) handleDelOvnFip(key string) error {
return err
}
}
if err = c.handleDelOvnFipFinalizer(cachedFip, util.ControllerName); err != nil {
if err = c.handleDelOvnFipFinalizer(cachedFip, util.FinalizerName); err != nil {
klog.Errorf("failed to remove finalizer for ovn fip %s, %v", cachedFip.Name, err)
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/ovn_snat.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func (c *Controller) handleAddOvnSnatRule(key string) error {
klog.Errorf("failed to create snat, %v", err)
return err
}
if err := c.handleAddOvnSnatFinalizer(cachedSnat, util.ControllerName); err != nil {
if err := c.handleAddOvnSnatFinalizer(cachedSnat, util.FinalizerName); err != nil {
klog.Errorf("failed to add finalizer for ovn snat %s, %v", cachedSnat.Name, err)
return err
}
Expand Down Expand Up @@ -419,7 +419,7 @@ func (c *Controller) handleDelOvnSnatRule(key string) error {
return err
}
}
if err = c.handleDelOvnSnatFinalizer(cachedSnat, util.ControllerName); err != nil {
if err = c.handleDelOvnSnatFinalizer(cachedSnat, util.FinalizerName); err != nil {
klog.Errorf("failed to remove finalizer for ovn snat %s, %v", cachedSnat.Name, err)
return err
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/qos_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func (c *Controller) handleDelQoSPoliciesFinalizer(key string) error {
return nil
}
newQoSPolicies := cachedQoSPolicies.DeepCopy()
controllerutil.RemoveFinalizer(newQoSPolicies, util.ControllerName)
controllerutil.RemoveFinalizer(newQoSPolicies, util.FinalizerName)
patch, err := util.GenerateMergePatchPayload(cachedQoSPolicies, newQoSPolicies)
if err != nil {
klog.Errorf("failed to generate patch payload for qos '%s', %v", cachedQoSPolicies.Name, err)
Expand Down Expand Up @@ -521,12 +521,12 @@ func (c *Controller) handleAddQoSPolicyFinalizer(key string) error {
return err
}
if cachedQoSPolicy.DeletionTimestamp.IsZero() {
if slices.Contains(cachedQoSPolicy.Finalizers, util.ControllerName) {
if slices.Contains(cachedQoSPolicy.Finalizers, util.FinalizerName) {
return nil
}
}
newQoSPolicy := cachedQoSPolicy.DeepCopy()
controllerutil.AddFinalizer(newQoSPolicy, util.ControllerName)
controllerutil.AddFinalizer(newQoSPolicy, util.FinalizerName)
patch, err := util.GenerateMergePatchPayload(cachedQoSPolicy, newQoSPolicy)
if err != nil {
klog.Errorf("failed to generate patch payload for qos '%s', %v", cachedQoSPolicy.Name, err)
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,9 @@ func checkAndUpdateExcludeIPs(subnet *kubeovnv1.Subnet) bool {
}

func (c *Controller) handleSubnetFinalizer(subnet *kubeovnv1.Subnet) (bool, error) {
if subnet.DeletionTimestamp.IsZero() && !slices.Contains(subnet.Finalizers, util.ControllerName) {
if subnet.DeletionTimestamp.IsZero() && !slices.Contains(subnet.Finalizers, util.FinalizerName) {
newSubnet := subnet.DeepCopy()
newSubnet.Finalizers = append(newSubnet.Finalizers, util.ControllerName)
newSubnet.Finalizers = append(newSubnet.Finalizers, util.FinalizerName)
patch, err := util.GenerateMergePatchPayload(subnet, newSubnet)
if err != nil {
klog.Errorf("failed to generate patch payload for subnet '%s', %v", subnet.Name, err)
Expand All @@ -506,7 +506,7 @@ func (c *Controller) handleSubnetFinalizer(subnet *kubeovnv1.Subnet) (bool, erro
u2oInterconnIP := subnet.Status.U2OInterconnectionIP
if !subnet.DeletionTimestamp.IsZero() && (usingIPs == 0 || (usingIPs == 1 && u2oInterconnIP != "")) {
newSubnet := subnet.DeepCopy()
newSubnet.Finalizers = util.RemoveString(newSubnet.Finalizers, util.ControllerName)
newSubnet.Finalizers = util.RemoveString(newSubnet.Finalizers, util.FinalizerName)
patch, err := util.GenerateMergePatchPayload(subnet, newSubnet)
if err != nil {
klog.Errorf("failed to generate patch payload for subnet '%s', %v", subnet.Name, err)
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/vip.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,12 +637,12 @@ func (c *Controller) handleAddVipFinalizer(key string) error {
return err
}
if cachedVip.DeletionTimestamp.IsZero() {
if slices.Contains(cachedVip.Finalizers, util.ControllerName) {
if slices.Contains(cachedVip.Finalizers, util.FinalizerName) {
return nil
}
}
newVip := cachedVip.DeepCopy()
controllerutil.AddFinalizer(newVip, util.ControllerName)
controllerutil.AddFinalizer(newVip, util.FinalizerName)
patch, err := util.GenerateMergePatchPayload(cachedVip, newVip)
if err != nil {
klog.Errorf("failed to generate patch payload for ovn eip '%s', %v", cachedVip.Name, err)
Expand Down Expand Up @@ -672,7 +672,7 @@ func (c *Controller) handleDelVipFinalizer(key string) error {
return nil
}
newVip := cachedVip.DeepCopy()
controllerutil.RemoveFinalizer(newVip, util.ControllerName)
controllerutil.RemoveFinalizer(newVip, util.FinalizerName)
patch, err := util.GenerateMergePatchPayload(cachedVip, newVip)
if err != nil {
klog.Errorf("failed to generate patch payload for ovn eip '%s', %v", cachedVip.Name, err)
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/vpc_nat_gw_eip.go
Original file line number Diff line number Diff line change
Expand Up @@ -760,12 +760,12 @@ func (c *Controller) handleAddIptablesEipFinalizer(key string) error {
return err
}
if cachedIptablesEip.DeletionTimestamp.IsZero() {
if slices.Contains(cachedIptablesEip.Finalizers, util.ControllerName) {
if slices.Contains(cachedIptablesEip.Finalizers, util.FinalizerName) {
return nil
}
}
newIptablesEip := cachedIptablesEip.DeepCopy()
controllerutil.AddFinalizer(newIptablesEip, util.ControllerName)
controllerutil.AddFinalizer(newIptablesEip, util.FinalizerName)
patch, err := util.GenerateMergePatchPayload(cachedIptablesEip, newIptablesEip)
if err != nil {
klog.Errorf("failed to generate patch payload for iptables eip '%s', %v", cachedIptablesEip.Name, err)
Expand Down Expand Up @@ -795,7 +795,7 @@ func (c *Controller) handleDelIptablesEipFinalizer(key string) error {
return nil
}
newIptablesEip := cachedIptablesEip.DeepCopy()
controllerutil.RemoveFinalizer(newIptablesEip, util.ControllerName)
controllerutil.RemoveFinalizer(newIptablesEip, util.FinalizerName)
patch, err := util.GenerateMergePatchPayload(cachedIptablesEip, newIptablesEip)
if err != nil {
klog.Errorf("failed to generate patch payload for iptables eip '%s', %v", cachedIptablesEip.Name, err)
Expand Down
18 changes: 9 additions & 9 deletions pkg/controller/vpc_nat_gw_nat.go
Original file line number Diff line number Diff line change
Expand Up @@ -1054,12 +1054,12 @@ func (c *Controller) handleAddIptablesFipFinalizer(key string) error {
return err
}
if cachedIptablesFip.DeletionTimestamp.IsZero() {
if slices.Contains(cachedIptablesFip.Finalizers, util.ControllerName) {
if slices.Contains(cachedIptablesFip.Finalizers, util.FinalizerName) {
return nil
}
}
newIptablesFip := cachedIptablesFip.DeepCopy()
controllerutil.AddFinalizer(newIptablesFip, util.ControllerName)
controllerutil.AddFinalizer(newIptablesFip, util.FinalizerName)
patch, err := util.GenerateMergePatchPayload(cachedIptablesFip, newIptablesFip)
if err != nil {
klog.Errorf("failed to generate patch payload for iptables fip '%s', %v", cachedIptablesFip.Name, err)
Expand Down Expand Up @@ -1089,7 +1089,7 @@ func (c *Controller) handleDelIptablesFipFinalizer(key string) error {
return nil
}
newIptablesFip := cachedIptablesFip.DeepCopy()
controllerutil.RemoveFinalizer(newIptablesFip, util.ControllerName)
controllerutil.RemoveFinalizer(newIptablesFip, util.FinalizerName)
patch, err := util.GenerateMergePatchPayload(cachedIptablesFip, newIptablesFip)
if err != nil {
klog.Errorf("failed to generate patch payload for iptables fip '%s', %v", cachedIptablesFip.Name, err)
Expand All @@ -1116,12 +1116,12 @@ func (c *Controller) handleAddIptablesDnatFinalizer(key string) error {
return err
}
if cachedIptablesDnat.DeletionTimestamp.IsZero() {
if slices.Contains(cachedIptablesDnat.Finalizers, util.ControllerName) {
if slices.Contains(cachedIptablesDnat.Finalizers, util.FinalizerName) {
return nil
}
}
newIptablesDnat := cachedIptablesDnat.DeepCopy()
controllerutil.AddFinalizer(newIptablesDnat, util.ControllerName)
controllerutil.AddFinalizer(newIptablesDnat, util.FinalizerName)
patch, err := util.GenerateMergePatchPayload(cachedIptablesDnat, newIptablesDnat)
if err != nil {
klog.Errorf("failed to generate patch payload for iptables dnat '%s', %v", cachedIptablesDnat.Name, err)
Expand Down Expand Up @@ -1151,7 +1151,7 @@ func (c *Controller) handleDelIptablesDnatFinalizer(key string) error {
return nil
}
newIptablesDnat := cachedIptablesDnat.DeepCopy()
controllerutil.RemoveFinalizer(newIptablesDnat, util.ControllerName)
controllerutil.RemoveFinalizer(newIptablesDnat, util.FinalizerName)
patch, err := util.GenerateMergePatchPayload(cachedIptablesDnat, newIptablesDnat)
if err != nil {
klog.Errorf("failed to generate patch payload for iptables dnat '%s', %v", cachedIptablesDnat.Name, err)
Expand Down Expand Up @@ -1229,12 +1229,12 @@ func (c *Controller) handleAddIptablesSnatFinalizer(key string) error {
return err
}
if cachedIptablesSnat.DeletionTimestamp.IsZero() {
if slices.Contains(cachedIptablesSnat.Finalizers, util.ControllerName) {
if slices.Contains(cachedIptablesSnat.Finalizers, util.FinalizerName) {
return nil
}
}
newIptablesSnat := cachedIptablesSnat.DeepCopy()
controllerutil.AddFinalizer(newIptablesSnat, util.ControllerName)
controllerutil.AddFinalizer(newIptablesSnat, util.FinalizerName)
patch, err := util.GenerateMergePatchPayload(cachedIptablesSnat, newIptablesSnat)
if err != nil {
klog.Errorf("failed to generate patch payload for iptables snat '%s', %v", cachedIptablesSnat.Name, err)
Expand Down Expand Up @@ -1264,7 +1264,7 @@ func (c *Controller) handleDelIptablesSnatFinalizer(key string) error {
return nil
}
newIptablesSnat := cachedIptablesSnat.DeepCopy()
controllerutil.RemoveFinalizer(newIptablesSnat, util.ControllerName)
controllerutil.RemoveFinalizer(newIptablesSnat, util.FinalizerName)
patch, err := util.GenerateMergePatchPayload(cachedIptablesSnat, newIptablesSnat)
if err != nil {
klog.Errorf("failed to generate patch payload for iptables snat '%s', %v", cachedIptablesSnat.Name, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package util
const (
CniTypeName = "kube-ovn"

ControllerName = "kube-ovn-controller"
FinalizerName = "kubeovn.io/finalizer"

AllocatedAnnotation = "ovn.kubernetes.io/allocated"
RoutedAnnotation = "ovn.kubernetes.io/routed"
Expand Down
16 changes: 8 additions & 8 deletions test/e2e/kube-ovn/subnet/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ var _ = framework.Describe("[group:subnet]", func() {
subnet = subnetClient.CreateSync(subnet)

ginkgo.By("Validating subnet finalizers")
framework.ExpectContainElement(subnet.Finalizers, util.ControllerName)
framework.ExpectContainElement(subnet.Finalizers, util.FinalizerName)

ginkgo.By("Validating subnet spec fields")
framework.ExpectFalse(subnet.Spec.Default)
Expand Down Expand Up @@ -206,7 +206,7 @@ var _ = framework.Describe("[group:subnet]", func() {
subnet = subnetClient.CreateSync(subnet)

ginkgo.By("Validating subnet finalizers")
framework.ExpectContainElement(subnet.ObjectMeta.Finalizers, util.ControllerName)
framework.ExpectContainElement(subnet.ObjectMeta.Finalizers, util.FinalizerName)

ginkgo.By("Validating subnet spec fields")
framework.ExpectFalse(subnet.Spec.Default)
Expand Down Expand Up @@ -251,7 +251,7 @@ var _ = framework.Describe("[group:subnet]", func() {
subnet = subnetClient.CreateSync(subnet)

ginkgo.By("Validating subnet finalizers")
framework.ExpectContainElement(subnet.ObjectMeta.Finalizers, util.ControllerName)
framework.ExpectContainElement(subnet.ObjectMeta.Finalizers, util.FinalizerName)

ginkgo.By("Validating subnet spec fields")
framework.ExpectFalse(subnet.Spec.Default)
Expand Down Expand Up @@ -301,7 +301,7 @@ var _ = framework.Describe("[group:subnet]", func() {
subnet = subnetClient.CreateSync(subnet)

ginkgo.By("Validating subnet finalizers")
framework.ExpectContainElement(subnet.Finalizers, util.ControllerName)
framework.ExpectContainElement(subnet.Finalizers, util.FinalizerName)

ginkgo.By("Validating subnet spec fields")
framework.ExpectFalse(subnet.Spec.Default)
Expand Down Expand Up @@ -345,7 +345,7 @@ var _ = framework.Describe("[group:subnet]", func() {
subnet = subnetClient.CreateSync(subnet)

ginkgo.By("Validating subnet finalizers")
framework.ExpectContainElement(subnet.Finalizers, util.ControllerName)
framework.ExpectContainElement(subnet.Finalizers, util.FinalizerName)

ginkgo.By("Validating subnet spec fields")
framework.ExpectFalse(subnet.Spec.Default)
Expand Down Expand Up @@ -388,7 +388,7 @@ var _ = framework.Describe("[group:subnet]", func() {
subnet = subnetClient.PatchSync(subnet, modifiedSubnet)

ginkgo.By("Validating subnet finalizers")
framework.ExpectContainElement(subnet.ObjectMeta.Finalizers, util.ControllerName)
framework.ExpectContainElement(subnet.ObjectMeta.Finalizers, util.FinalizerName)

ginkgo.By("Validating subnet spec fields")
framework.ExpectFalse(subnet.Spec.Default)
Expand Down Expand Up @@ -444,7 +444,7 @@ var _ = framework.Describe("[group:subnet]", func() {
subnet = subnetClient.CreateSync(subnet)

ginkgo.By("Validating subnet finalizers")
framework.ExpectContainElement(subnet.Finalizers, util.ControllerName)
framework.ExpectContainElement(subnet.Finalizers, util.FinalizerName)

ginkgo.By("Validating centralized subnet with active-standby mode")
framework.ExpectFalse(subnet.Spec.EnableEcmp)
Expand Down Expand Up @@ -947,7 +947,7 @@ var _ = framework.Describe("[group:subnet]", func() {
subnet = subnetClient.CreateSync(subnet)

ginkgo.By("Validating subnet load-balancer records exist")
framework.ExpectContainElement(subnet.Finalizers, util.ControllerName)
framework.ExpectContainElement(subnet.Finalizers, util.FinalizerName)
execCmd := "kubectl ko nbctl --format=csv --data=bare --no-heading --columns=load_balancer find logical-switch " + fmt.Sprintf("name=%s", subnetName)
output, err := exec.Command("bash", "-c", execCmd).CombinedOutput()
framework.ExpectNoError(err)
Expand Down

0 comments on commit 7bf1343

Please sign in to comment.