@@ -1363,14 +1363,7 @@ func TestIsNodeDrainedAllowed(t *testing.T) {
1363
1363
Name : "test-machine" ,
1364
1364
Namespace : metav1 .NamespaceDefault ,
1365
1365
Labels : map [string ]string {clusterv1 .MachineControlPlaneLabel : "" },
1366
- Annotations : map [string ]string {KubeadmControlPlanePreTerminateHookCleanupAnnotation : "" },
1367
- OwnerReferences : []metav1.OwnerReference {
1368
- {
1369
- APIVersion : KubeadmControlPlaneAPIVersion ,
1370
- Kind : "KubeadmControlPlane" ,
1371
- Name : "Foo" ,
1372
- },
1373
- },
1366
+ Annotations : map [string ]string {clusterv1 .PreTerminateDeleteHookAnnotationPrefix + "/kcp-cleanup" : "" },
1374
1367
},
1375
1368
Spec : clusterv1.MachineSpec {
1376
1369
ClusterName : "test-cluster" ,
@@ -1388,13 +1381,6 @@ func TestIsNodeDrainedAllowed(t *testing.T) {
1388
1381
Name : "test-machine" ,
1389
1382
Namespace : metav1 .NamespaceDefault ,
1390
1383
Labels : map [string ]string {clusterv1 .MachineControlPlaneLabel : "" },
1391
- OwnerReferences : []metav1.OwnerReference {
1392
- {
1393
- APIVersion : KubeadmControlPlaneAPIVersion ,
1394
- Kind : "KubeadmControlPlane" ,
1395
- Name : "Foo" ,
1396
- },
1397
- },
1398
1384
},
1399
1385
Spec : clusterv1.MachineSpec {
1400
1386
ClusterName : "test-cluster" ,
@@ -1428,6 +1414,28 @@ func TestIsNodeDrainedAllowed(t *testing.T) {
1428
1414
},
1429
1415
expected : false ,
1430
1416
},
1417
+ {
1418
+ name : "Node draining succeeded" ,
1419
+ machine : & clusterv1.Machine {
1420
+ ObjectMeta : metav1.ObjectMeta {
1421
+ Name : "test-machine" ,
1422
+ Namespace : metav1 .NamespaceDefault ,
1423
+ Finalizers : []string {clusterv1 .MachineFinalizer },
1424
+ },
1425
+ Spec : clusterv1.MachineSpec {
1426
+ ClusterName : "test-cluster" ,
1427
+ InfrastructureRef : corev1.ObjectReference {},
1428
+ Bootstrap : clusterv1.Bootstrap {DataSecretName : ptr .To ("data" )},
1429
+ },
1430
+ Status : clusterv1.MachineStatus {
1431
+ Conditions : clusterv1.Conditions {{
1432
+ Type : clusterv1 .DrainingSucceededCondition ,
1433
+ Status : corev1 .ConditionTrue ,
1434
+ }},
1435
+ },
1436
+ },
1437
+ expected : false ,
1438
+ },
1431
1439
{
1432
1440
name : "Node draining timeout is not yet over" ,
1433
1441
machine : & clusterv1.Machine {
@@ -1924,14 +1932,7 @@ func TestIsNodeVolumeDetachingAllowed(t *testing.T) {
1924
1932
Name : "test-machine" ,
1925
1933
Namespace : metav1 .NamespaceDefault ,
1926
1934
Labels : map [string ]string {clusterv1 .MachineControlPlaneLabel : "" },
1927
- Annotations : map [string ]string {KubeadmControlPlanePreTerminateHookCleanupAnnotation : "" },
1928
- OwnerReferences : []metav1.OwnerReference {
1929
- {
1930
- APIVersion : KubeadmControlPlaneAPIVersion ,
1931
- Kind : "KubeadmControlPlane" ,
1932
- Name : "Foo" ,
1933
- },
1934
- },
1935
+ Annotations : map [string ]string {clusterv1 .PreTerminateDeleteHookAnnotationPrefix + "/kcp-cleanup" : "" },
1935
1936
},
1936
1937
Spec : clusterv1.MachineSpec {
1937
1938
ClusterName : "test-cluster" ,
@@ -1949,13 +1950,6 @@ func TestIsNodeVolumeDetachingAllowed(t *testing.T) {
1949
1950
Name : "test-machine" ,
1950
1951
Namespace : metav1 .NamespaceDefault ,
1951
1952
Labels : map [string ]string {clusterv1 .MachineControlPlaneLabel : "" },
1952
- OwnerReferences : []metav1.OwnerReference {
1953
- {
1954
- APIVersion : KubeadmControlPlaneAPIVersion ,
1955
- Kind : "KubeadmControlPlane" ,
1956
- Name : "Foo" ,
1957
- },
1958
- },
1959
1953
},
1960
1954
Spec : clusterv1.MachineSpec {
1961
1955
ClusterName : "test-cluster" ,
@@ -1989,6 +1983,28 @@ func TestIsNodeVolumeDetachingAllowed(t *testing.T) {
1989
1983
},
1990
1984
expected : false ,
1991
1985
},
1986
+ {
1987
+ name : "Volume detach completed" ,
1988
+ machine : & clusterv1.Machine {
1989
+ ObjectMeta : metav1.ObjectMeta {
1990
+ Name : "test-machine" ,
1991
+ Namespace : metav1 .NamespaceDefault ,
1992
+ Finalizers : []string {clusterv1 .MachineFinalizer },
1993
+ },
1994
+ Spec : clusterv1.MachineSpec {
1995
+ ClusterName : "test-cluster" ,
1996
+ InfrastructureRef : corev1.ObjectReference {},
1997
+ Bootstrap : clusterv1.Bootstrap {DataSecretName : ptr .To ("data" )},
1998
+ },
1999
+ Status : clusterv1.MachineStatus {
2000
+ Conditions : clusterv1.Conditions {{
2001
+ Type : clusterv1 .VolumeDetachSucceededCondition ,
2002
+ Status : corev1 .ConditionTrue ,
2003
+ }},
2004
+ },
2005
+ },
2006
+ expected : false ,
2007
+ },
1992
2008
{
1993
2009
name : "Volume detach timeout is not yet over" ,
1994
2010
machine : & clusterv1.Machine {
0 commit comments