Skip to content

Commit

Permalink
remove deprecated DeleteNodeAnnotation annotation
Browse files Browse the repository at this point in the history
Signed-off-by: Arghya Sadhu <[email protected]>
  • Loading branch information
arghya88 committed Nov 30, 2020
1 parent 97c495b commit 061876e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 55 deletions.
17 changes: 2 additions & 15 deletions controllers/machineset_delete_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
}
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
40 changes: 0 additions & 40 deletions controllers/machineset_delete_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 061876e

Please sign in to comment.