removes deprecated CAPI annotations

This commit is contained in:
Clinton Yeboah 2021-11-11 18:56:53 -05:00
parent 86068ba9a9
commit ecfaa6d700
5 changed files with 2 additions and 15 deletions

View File

@ -259,10 +259,7 @@ func (c *machineController) findMachineByProviderID(providerID normalizedProvide
return nil, nil return nil, nil
} }
machineID, ok := node.Annotations[machineAnnotationKey] machineID, _ := node.Annotations[machineAnnotationKey]
if !ok {
machineID = node.Annotations[deprecatedMachineAnnotationKey]
}
return c.findMachine(machineID) return c.findMachine(machineID)
} }

View File

@ -596,12 +596,11 @@ func TestControllerFindMachine(t *testing.T) {
for i := range testConfig.machines { for i := range testConfig.machines {
n := testConfig.nodes[i] n := testConfig.nodes[i]
annotations := n.GetAnnotations() annotations := n.GetAnnotations()
val, ok := annotations[machineAnnotationKey] _, ok := annotations[machineAnnotationKey]
if !ok { if !ok {
t.Fatal("node did not contain machineAnnotationKey") t.Fatal("node did not contain machineAnnotationKey")
} }
delete(annotations, machineAnnotationKey) delete(annotations, machineAnnotationKey)
annotations[deprecatedMachineAnnotationKey] = val
n.SetAnnotations(annotations) n.SetAnnotations(annotations)
} }
} }

View File

@ -28,10 +28,6 @@ import (
) )
const ( 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)" debugFormat = "%s (min: %d, max: %d, replicas: %d)"
) )

View File

@ -649,9 +649,6 @@ func TestNodeGroupDeleteNodes(t *testing.T) {
if _, found := machine.GetAnnotations()[machineDeleteAnnotationKey]; !found { if _, found := machine.GetAnnotations()[machineDeleteAnnotationKey]; !found {
t.Errorf("expected annotation %q on machine %s", machineDeleteAnnotationKey, machine.GetName()) 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() gvr, err := ng.scalableResource.GroupVersionResource()

View File

@ -130,7 +130,6 @@ func (r unstructuredScalableResource) UnmarkMachineForDeletion(machine *unstruct
annotations := u.GetAnnotations() annotations := u.GetAnnotations()
delete(annotations, machineDeleteAnnotationKey) delete(annotations, machineDeleteAnnotationKey)
delete(annotations, deprecatedMachineDeleteAnnotationKey)
u.SetAnnotations(annotations) u.SetAnnotations(annotations)
_, updateErr := r.controller.managementClient.Resource(r.controller.machineResource).Namespace(u.GetNamespace()).Update(context.TODO(), u, metav1.UpdateOptions{}) _, updateErr := r.controller.managementClient.Resource(r.controller.machineResource).Namespace(u.GetNamespace()).Update(context.TODO(), u, metav1.UpdateOptions{})
@ -151,7 +150,6 @@ func (r unstructuredScalableResource) MarkMachineForDeletion(machine *unstructur
} }
annotations[machineDeleteAnnotationKey] = time.Now().String() annotations[machineDeleteAnnotationKey] = time.Now().String()
annotations[deprecatedMachineDeleteAnnotationKey] = time.Now().String()
u.SetAnnotations(annotations) u.SetAnnotations(annotations)
_, updateErr := r.controller.managementClient.Resource(r.controller.machineResource).Namespace(u.GetNamespace()).Update(context.TODO(), u, metav1.UpdateOptions{}) _, updateErr := r.controller.managementClient.Resource(r.controller.machineResource).Namespace(u.GetNamespace()).Update(context.TODO(), u, metav1.UpdateOptions{})