From 061876e7e76e0d849dde0871dbd610ae9a6756aa Mon Sep 17 00:00:00 2001 From: Arghya Sadhu Date: Mon, 30 Nov 2020 10:46:51 +0530 Subject: [PATCH] remove deprecated DeleteNodeAnnotation annotation Signed-off-by: Arghya Sadhu --- controllers/machineset_delete_policy.go | 17 +-------- controllers/machineset_delete_policy_test.go | 40 -------------------- 2 files changed, 2 insertions(+), 55 deletions(-) diff --git a/controllers/machineset_delete_policy.go b/controllers/machineset_delete_policy.go index a9d5aa155c04..32b4b6e26b6e 100644 --- a/controllers/machineset_delete_policy.go +++ b/controllers/machineset_delete_policy.go @@ -31,10 +31,6 @@ type ( ) const ( - // DeleteNodeAnnotation marks nodes that will be given priority for deletion - // when a machineset scales down. This annotation is given top priority on all delete policies. - // Deprecated: Please use DeleteMachineAnnotation instead. - DeleteNodeAnnotation = "cluster.k8s.io/delete-machine" // DeleteMachineAnnotation marks nodes that will be given priority for deletion // when a machineset scales down. This annotation is given top priority on all delete policies. DeleteMachineAnnotation = "cluster.x-k8s.io/delete-machine" @@ -52,9 +48,6 @@ func oldestDeletePriority(machine *clusterv1.Machine) deletePriority { if !machine.DeletionTimestamp.IsZero() { return mustDelete } - if machine.ObjectMeta.Annotations != nil && machine.ObjectMeta.Annotations[DeleteNodeAnnotation] != "" { - return mustDelete - } if _, ok := machine.ObjectMeta.Annotations[DeleteMachineAnnotation]; ok { return mustDelete } @@ -78,10 +71,7 @@ func newestDeletePriority(machine *clusterv1.Machine) deletePriority { if !machine.DeletionTimestamp.IsZero() { return mustDelete } - if machine.ObjectMeta.Annotations != nil && machine.ObjectMeta.Annotations[DeleteNodeAnnotation] != "" { - return mustDelete - } - if _, ok := machine.ObjectMeta.Annotations[DeleteMachineAnnotation]; ok { + if machine.ObjectMeta.Annotations != nil && machine.ObjectMeta.Annotations[DeleteMachineAnnotation] != "" { return mustDelete } if machine.Status.NodeRef == nil { @@ -97,10 +87,7 @@ func randomDeletePolicy(machine *clusterv1.Machine) deletePriority { if !machine.DeletionTimestamp.IsZero() { return mustDelete } - if machine.ObjectMeta.Annotations != nil && machine.ObjectMeta.Annotations[DeleteNodeAnnotation] != "" { - return betterDelete - } - if _, ok := machine.ObjectMeta.Annotations[DeleteMachineAnnotation]; ok { + if machine.ObjectMeta.Annotations != nil && machine.ObjectMeta.Annotations[DeleteMachineAnnotation] != "" { return betterDelete } if machine.Status.NodeRef == nil { diff --git a/controllers/machineset_delete_policy_test.go b/controllers/machineset_delete_policy_test.go index b516c55eef1b..b617d637cd5f 100644 --- a/controllers/machineset_delete_policy_test.go +++ b/controllers/machineset_delete_policy_test.go @@ -39,10 +39,6 @@ func TestMachineToDelete(t *testing.T) { betterDeleteMachine := &clusterv1.Machine{ Status: clusterv1.MachineStatus{FailureMessage: &msg, NodeRef: nodeRef}, } - deleteMachineWithNodeAnnotation := &clusterv1.Machine{ - ObjectMeta: metav1.ObjectMeta{Annotations: map[string]string{DeleteNodeAnnotation: "yes"}}, - Status: clusterv1.MachineStatus{NodeRef: nodeRef}, - } deleteMachineWithMachineAnnotation := &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Annotations: map[string]string{DeleteMachineAnnotation: ""}}, Status: clusterv1.MachineStatus{NodeRef: nodeRef}, @@ -154,18 +150,6 @@ func TestMachineToDelete(t *testing.T) { healthyMachine, }, }, - { - desc: "func=randomDeletePolicy, DeleteNodeAnnotation, diff=1", - diff: 1, - machines: []*clusterv1.Machine{ - healthyMachine, - deleteMachineWithNodeAnnotation, - healthyMachine, - }, - expect: []*clusterv1.Machine{ - deleteMachineWithNodeAnnotation, - }, - }, { desc: "func=randomDeletePolicy, DeleteMachineAnnotation, diff=1", diff: 1, @@ -226,10 +210,6 @@ func TestMachineNewestDelete(t *testing.T) { ObjectMeta: metav1.ObjectMeta{CreationTimestamp: metav1.NewTime(currentTime.Time.AddDate(0, 0, -10))}, Status: clusterv1.MachineStatus{NodeRef: nodeRef}, } - deleteMachineWithNodeAnnotation := &clusterv1.Machine{ - ObjectMeta: metav1.ObjectMeta{Annotations: map[string]string{DeleteNodeAnnotation: "yes"}, CreationTimestamp: metav1.NewTime(currentTime.Time.AddDate(0, 0, -10))}, - Status: clusterv1.MachineStatus{NodeRef: nodeRef}, - } deleteMachineWithMachineAnnotation := &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Annotations: map[string]string{DeleteMachineAnnotation: ""}, CreationTimestamp: metav1.NewTime(currentTime.Time.AddDate(0, 0, -10))}, Status: clusterv1.MachineStatus{NodeRef: nodeRef}, @@ -272,14 +252,6 @@ func TestMachineNewestDelete(t *testing.T) { }, expect: []*clusterv1.Machine{mustDeleteMachine, newest, new}, }, - { - desc: "func=newestDeletePriority, diff=1 (DeleteNodeAnnotation)", - diff: 1, - machines: []*clusterv1.Machine{ - new, oldest, old, newest, deleteMachineWithNodeAnnotation, - }, - expect: []*clusterv1.Machine{deleteMachineWithNodeAnnotation}, - }, { desc: "func=newestDeletePriority, diff=1 (DeleteMachineAnnotation)", diff: 1, @@ -339,10 +311,6 @@ func TestMachineOldestDelete(t *testing.T) { ObjectMeta: metav1.ObjectMeta{CreationTimestamp: metav1.NewTime(currentTime.Time.AddDate(0, 0, -10))}, Status: clusterv1.MachineStatus{NodeRef: nodeRef}, } - deleteMachineWithNodeAnnotation := &clusterv1.Machine{ - ObjectMeta: metav1.ObjectMeta{Annotations: map[string]string{DeleteNodeAnnotation: "yes"}, CreationTimestamp: metav1.NewTime(currentTime.Time.AddDate(0, 0, -10))}, - Status: clusterv1.MachineStatus{NodeRef: nodeRef}, - } deleteMachineWithMachineAnnotation := &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Annotations: map[string]string{DeleteMachineAnnotation: ""}, CreationTimestamp: metav1.NewTime(currentTime.Time.AddDate(0, 0, -10))}, Status: clusterv1.MachineStatus{NodeRef: nodeRef}, @@ -393,14 +361,6 @@ func TestMachineOldestDelete(t *testing.T) { }, expect: []*clusterv1.Machine{oldest, old, new, newest}, }, - { - desc: "func=oldestDeletePriority, diff=1 (DeleteNodeAnnotation)", - diff: 1, - machines: []*clusterv1.Machine{ - empty, new, oldest, old, newest, deleteMachineWithNodeAnnotation, - }, - expect: []*clusterv1.Machine{deleteMachineWithNodeAnnotation}, - }, { desc: "func=oldestDeletePriority, diff=1 (DeleteMachineAnnotation)", diff: 1,