Skip to content

Commit

Permalink
removes deprecated CAPI annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
clintonyeboah authored and piotrnosek committed Nov 30, 2021
1 parent 1d48a5a commit 4523efd
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,7 @@ func (c *machineController) findMachineByProviderID(providerID normalizedProvide
return nil, nil
}

machineID, ok := node.Annotations[machineAnnotationKey]
if !ok {
machineID = node.Annotations[deprecatedMachineAnnotationKey]
}
machineID, _ := node.Annotations[machineAnnotationKey]
return c.findMachine(machineID)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,12 +596,11 @@ func TestControllerFindMachine(t *testing.T) {
for i := range testConfig.machines {
n := testConfig.nodes[i]
annotations := n.GetAnnotations()
val, ok := annotations[machineAnnotationKey]
_, ok := annotations[machineAnnotationKey]
if !ok {
t.Fatal("node did not contain machineAnnotationKey")
}
delete(annotations, machineAnnotationKey)
annotations[deprecatedMachineAnnotationKey] = val
n.SetAnnotations(annotations)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ import (
)

const (
// deprecatedMachineDeleteAnnotationKey should not be removed until minimum cluster-api support is v1alpha3
deprecatedMachineDeleteAnnotationKey = "cluster.k8s.io/delete-machine"
// TODO: determine what currently relies on deprecatedMachineAnnotationKey to determine when it can be removed
deprecatedMachineAnnotationKey = "cluster.k8s.io/machine"
debugFormat = "%s (min: %d, max: %d, replicas: %d)"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -649,9 +649,6 @@ func TestNodeGroupDeleteNodes(t *testing.T) {
if _, found := machine.GetAnnotations()[machineDeleteAnnotationKey]; !found {
t.Errorf("expected annotation %q on machine %s", machineDeleteAnnotationKey, machine.GetName())
}
if _, found := machine.GetAnnotations()[deprecatedMachineDeleteAnnotationKey]; !found {
t.Errorf("expected annotation %q on machine %s", deprecatedMachineDeleteAnnotationKey, machine.GetName())
}
}

gvr, err := ng.scalableResource.GroupVersionResource()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ func (r unstructuredScalableResource) UnmarkMachineForDeletion(machine *unstruct

annotations := u.GetAnnotations()
delete(annotations, machineDeleteAnnotationKey)
delete(annotations, deprecatedMachineDeleteAnnotationKey)
u.SetAnnotations(annotations)
_, updateErr := r.controller.managementClient.Resource(r.controller.machineResource).Namespace(u.GetNamespace()).Update(context.TODO(), u, metav1.UpdateOptions{})

Expand All @@ -151,7 +150,6 @@ func (r unstructuredScalableResource) MarkMachineForDeletion(machine *unstructur
}

annotations[machineDeleteAnnotationKey] = time.Now().String()
annotations[deprecatedMachineDeleteAnnotationKey] = time.Now().String()
u.SetAnnotations(annotations)

_, updateErr := r.controller.managementClient.Resource(r.controller.machineResource).Namespace(u.GetNamespace()).Update(context.TODO(), u, metav1.UpdateOptions{})
Expand Down

0 comments on commit 4523efd

Please sign in to comment.