@@ -58,6 +58,14 @@ func TestAddIPToEdgeDNS(t *testing.T) {
58
58
ObjectMeta : metav1.ObjectMeta {
59
59
Name : "test-machine" ,
60
60
UID : "test-uid" ,
61
+ OwnerReferences : []metav1.OwnerReference {
62
+ {
63
+ APIVersion : "cluster.x-k8s.io/v1beta1" ,
64
+ Kind : "Machine" ,
65
+ Name : "test-machine" ,
66
+ UID : "test-uid" ,
67
+ },
68
+ },
61
69
},
62
70
Spec : infrav1alpha2.LinodeMachineSpec {
63
71
ProviderID : ptr .To ("linode://123" ),
@@ -117,6 +125,14 @@ func TestAddIPToEdgeDNS(t *testing.T) {
117
125
ObjectMeta : metav1.ObjectMeta {
118
126
Name : "test-machine" ,
119
127
UID : "test-uid" ,
128
+ OwnerReferences : []metav1.OwnerReference {
129
+ {
130
+ APIVersion : "cluster.x-k8s.io/v1beta1" ,
131
+ Kind : "Machine" ,
132
+ Name : "test-machine" ,
133
+ UID : "test-uid" ,
134
+ },
135
+ },
120
136
},
121
137
Spec : infrav1alpha2.LinodeMachineSpec {
122
138
ProviderID : ptr .To ("linode://123" ),
@@ -214,6 +230,14 @@ func TestRemoveIPFromEdgeDNS(t *testing.T) {
214
230
ObjectMeta : metav1.ObjectMeta {
215
231
Name : "test-machine" ,
216
232
UID : "test-uid" ,
233
+ OwnerReferences : []metav1.OwnerReference {
234
+ {
235
+ APIVersion : "cluster.x-k8s.io/v1beta1" ,
236
+ Kind : "Machine" ,
237
+ Name : "test-machine" ,
238
+ UID : "test-uid" ,
239
+ },
240
+ },
217
241
},
218
242
Spec : infrav1alpha2.LinodeMachineSpec {
219
243
ProviderID : ptr .To ("linode://123" ),
@@ -281,6 +305,14 @@ func TestRemoveIPFromEdgeDNS(t *testing.T) {
281
305
ObjectMeta : metav1.ObjectMeta {
282
306
Name : "test-machine" ,
283
307
UID : "test-uid" ,
308
+ OwnerReferences : []metav1.OwnerReference {
309
+ {
310
+ APIVersion : "cluster.x-k8s.io/v1beta1" ,
311
+ Kind : "Machine" ,
312
+ Name : "test-machine" ,
313
+ UID : "test-uid" ,
314
+ },
315
+ },
284
316
},
285
317
Spec : infrav1alpha2.LinodeMachineSpec {
286
318
ProviderID : ptr .To ("linode://123" ),
@@ -377,6 +409,14 @@ func TestAddIPToDNS(t *testing.T) {
377
409
ObjectMeta : metav1.ObjectMeta {
378
410
Name : "test-deleted-machine" ,
379
411
UID : "test-uid-1" ,
412
+ OwnerReferences : []metav1.OwnerReference {
413
+ {
414
+ APIVersion : "cluster.x-k8s.io/v1beta1" ,
415
+ Kind : "Machine" ,
416
+ Name : "test-deleted-machine" ,
417
+ UID : "test-uid-1" ,
418
+ },
419
+ },
380
420
},
381
421
Spec : infrav1alpha2.LinodeMachineSpec {
382
422
ProviderID : ptr .To ("linode://123" ),
@@ -396,6 +436,14 @@ func TestAddIPToDNS(t *testing.T) {
396
436
ObjectMeta : metav1.ObjectMeta {
397
437
Name : "test-active-machine" ,
398
438
UID : "test-uid-2" ,
439
+ OwnerReferences : []metav1.OwnerReference {
440
+ {
441
+ APIVersion : "cluster.x-k8s.io/v1beta1" ,
442
+ Kind : "Machine" ,
443
+ Name : "test-active-machine" ,
444
+ UID : "test-uid-2" ,
445
+ },
446
+ },
399
447
},
400
448
Spec : infrav1alpha2.LinodeMachineSpec {
401
449
ProviderID : ptr .To ("linode://456" ),
@@ -439,6 +487,18 @@ func TestAddIPToDNS(t *testing.T) {
439
487
Target : "10.20.20.20" ,
440
488
TTLSec : 30 ,
441
489
}, nil ).AnyTimes ()
490
+ mockClient .EXPECT ().CreateDomainRecord (gomock .Any (), gomock .Any (), gomock .Eq (linodego.DomainRecordCreateOptions {
491
+ Type : "TXT" ,
492
+ Name : "test-cluster-test-hash" ,
493
+ Target : "test-cluster" ,
494
+ TTLSec : 30 ,
495
+ })).Return (& linodego.DomainRecord {
496
+ ID : 1234 ,
497
+ Type : "TXT" ,
498
+ Name : "test-cluster" ,
499
+ Target : "test-cluster" ,
500
+ TTLSec : 30 ,
501
+ }, nil ).AnyTimes ()
442
502
443
503
// Make sure there's no expectation for the deleted machine's IP
444
504
// We don't need an explicit negative expectation since the mock
@@ -462,10 +522,12 @@ func TestAddIPToDNS(t *testing.T) {
462
522
// Set DeletionTimestamp to indicate the machine is being deleted
463
523
deletionTime := metav1 .Now ()
464
524
machine .DeletionTimestamp = & deletionTime
525
+ machine .UID = "test-uid-1"
465
526
case "test-active-machine" :
466
527
// Set up as an active machine
467
528
machine .Name = "test-active-machine"
468
529
machine .Namespace = "default"
530
+ machine .UID = "test-uid-2"
469
531
machine .DeletionTimestamp = nil
470
532
}
471
533
}
@@ -501,6 +563,14 @@ func TestAddIPToDNS(t *testing.T) {
501
563
ObjectMeta : metav1.ObjectMeta {
502
564
Name : "test-machine" ,
503
565
UID : "test-uid" ,
566
+ OwnerReferences : []metav1.OwnerReference {
567
+ {
568
+ APIVersion : "cluster.x-k8s.io/v1beta1" ,
569
+ Kind : "Machine" ,
570
+ Name : "test-machine" ,
571
+ UID : "test-uid" ,
572
+ },
573
+ },
504
574
},
505
575
Spec : infrav1alpha2.LinodeMachineSpec {
506
576
ProviderID : ptr .To ("linode://123" ),
@@ -571,6 +641,14 @@ func TestAddIPToDNS(t *testing.T) {
571
641
ObjectMeta : metav1.ObjectMeta {
572
642
Name : "test-machine" ,
573
643
UID : "test-uid" ,
644
+ OwnerReferences : []metav1.OwnerReference {
645
+ {
646
+ APIVersion : "cluster.x-k8s.io/v1beta1" ,
647
+ Kind : "Machine" ,
648
+ Name : "test-machine" ,
649
+ UID : "test-uid" ,
650
+ },
651
+ },
574
652
},
575
653
Spec : infrav1alpha2.LinodeMachineSpec {
576
654
ProviderID : ptr .To ("linode://123" ),
@@ -640,6 +718,14 @@ func TestAddIPToDNS(t *testing.T) {
640
718
ObjectMeta : metav1.ObjectMeta {
641
719
Name : "test-machine" ,
642
720
UID : "test-uid" ,
721
+ OwnerReferences : []metav1.OwnerReference {
722
+ {
723
+ APIVersion : "cluster.x-k8s.io/v1beta1" ,
724
+ Kind : "Machine" ,
725
+ Name : "test-machine" ,
726
+ UID : "test-uid" ,
727
+ },
728
+ },
643
729
},
644
730
Spec : infrav1alpha2.LinodeMachineSpec {
645
731
ProviderID : ptr .To ("linode://123" ),
@@ -704,6 +790,14 @@ func TestAddIPToDNS(t *testing.T) {
704
790
ObjectMeta : metav1.ObjectMeta {
705
791
Name : "test-machine" ,
706
792
UID : "test-uid" ,
793
+ OwnerReferences : []metav1.OwnerReference {
794
+ {
795
+ APIVersion : "cluster.x-k8s.io/v1beta1" ,
796
+ Kind : "Machine" ,
797
+ Name : "test-machine" ,
798
+ UID : "test-uid" ,
799
+ },
800
+ },
707
801
},
708
802
Spec : infrav1alpha2.LinodeMachineSpec {
709
803
ProviderID : ptr .To ("linode://123" ),
@@ -775,6 +869,14 @@ func TestAddIPToDNS(t *testing.T) {
775
869
ObjectMeta : metav1.ObjectMeta {
776
870
Name : "test-machine" ,
777
871
UID : "test-uid" ,
872
+ OwnerReferences : []metav1.OwnerReference {
873
+ {
874
+ APIVersion : "cluster.x-k8s.io/v1beta1" ,
875
+ Kind : "Machine" ,
876
+ Name : "test-machine" ,
877
+ UID : "test-uid" ,
878
+ },
879
+ },
778
880
},
779
881
Spec : infrav1alpha2.LinodeMachineSpec {
780
882
ProviderID : ptr .To ("linode://123" ),
@@ -838,6 +940,14 @@ func TestAddIPToDNS(t *testing.T) {
838
940
ObjectMeta : metav1.ObjectMeta {
839
941
Name : "test-machine" ,
840
942
UID : "test-uid" ,
943
+ OwnerReferences : []metav1.OwnerReference {
944
+ {
945
+ APIVersion : "cluster.x-k8s.io/v1beta1" ,
946
+ Kind : "Machine" ,
947
+ Name : "test-machine" ,
948
+ UID : "test-uid" ,
949
+ },
950
+ },
841
951
},
842
952
Spec : infrav1alpha2.LinodeMachineSpec {
843
953
ProviderID : ptr .To ("linode://123" ),
@@ -900,6 +1010,14 @@ func TestAddIPToDNS(t *testing.T) {
900
1010
ObjectMeta : metav1.ObjectMeta {
901
1011
Name : "test-machine" ,
902
1012
UID : "test-uid" ,
1013
+ OwnerReferences : []metav1.OwnerReference {
1014
+ {
1015
+ APIVersion : "cluster.x-k8s.io/v1beta1" ,
1016
+ Kind : "Machine" ,
1017
+ Name : "test-machine" ,
1018
+ UID : "test-uid" ,
1019
+ },
1020
+ },
903
1021
},
904
1022
Spec : infrav1alpha2.LinodeMachineSpec {
905
1023
ProviderID : ptr .To ("linode://123" ),
@@ -1001,6 +1119,14 @@ func TestDeleteIPFromDNS(t *testing.T) {
1001
1119
ObjectMeta : metav1.ObjectMeta {
1002
1120
Name : "test-machine" ,
1003
1121
UID : "test-uid" ,
1122
+ OwnerReferences : []metav1.OwnerReference {
1123
+ {
1124
+ APIVersion : "cluster.x-k8s.io/v1beta1" ,
1125
+ Kind : "Machine" ,
1126
+ Name : "test-machine" ,
1127
+ UID : "test-uid" ,
1128
+ },
1129
+ },
1004
1130
},
1005
1131
Spec : infrav1alpha2.LinodeMachineSpec {
1006
1132
ProviderID : ptr .To ("linode://123" ),
@@ -1072,6 +1198,14 @@ func TestDeleteIPFromDNS(t *testing.T) {
1072
1198
ObjectMeta : metav1.ObjectMeta {
1073
1199
Name : "test-machine" ,
1074
1200
UID : "test-uid" ,
1201
+ OwnerReferences : []metav1.OwnerReference {
1202
+ {
1203
+ APIVersion : "cluster.x-k8s.io/v1beta1" ,
1204
+ Kind : "Machine" ,
1205
+ Name : "test-machine" ,
1206
+ UID : "test-uid" ,
1207
+ },
1208
+ },
1075
1209
},
1076
1210
Spec : infrav1alpha2.LinodeMachineSpec {
1077
1211
ProviderID : ptr .To ("linode://123" ),
@@ -1188,6 +1322,14 @@ func TestDeleteIPFromDNS(t *testing.T) {
1188
1322
ObjectMeta : metav1.ObjectMeta {
1189
1323
Name : "test-machine" ,
1190
1324
UID : "test-uid" ,
1325
+ OwnerReferences : []metav1.OwnerReference {
1326
+ {
1327
+ APIVersion : "cluster.x-k8s.io/v1beta1" ,
1328
+ Kind : "Machine" ,
1329
+ Name : "test-machine" ,
1330
+ UID : "test-uid" ,
1331
+ },
1332
+ },
1191
1333
},
1192
1334
Spec : infrav1alpha2.LinodeMachineSpec {
1193
1335
ProviderID : ptr .To ("linode://123" ),
@@ -1245,6 +1387,14 @@ func TestDeleteIPFromDNS(t *testing.T) {
1245
1387
ObjectMeta : metav1.ObjectMeta {
1246
1388
Name : "test-machine" ,
1247
1389
UID : "test-uid" ,
1390
+ OwnerReferences : []metav1.OwnerReference {
1391
+ {
1392
+ APIVersion : "cluster.x-k8s.io/v1beta1" ,
1393
+ Kind : "Machine" ,
1394
+ Name : "test-machine" ,
1395
+ UID : "test-uid" ,
1396
+ },
1397
+ },
1248
1398
},
1249
1399
Spec : infrav1alpha2.LinodeMachineSpec {
1250
1400
ProviderID : ptr .To ("linode://123" ),
@@ -1307,6 +1457,14 @@ func TestDeleteIPFromDNS(t *testing.T) {
1307
1457
ObjectMeta : metav1.ObjectMeta {
1308
1458
Name : "test-machine" ,
1309
1459
UID : "test-uid" ,
1460
+ OwnerReferences : []metav1.OwnerReference {
1461
+ {
1462
+ APIVersion : "cluster.x-k8s.io/v1beta1" ,
1463
+ Kind : "Machine" ,
1464
+ Name : "test-machine" ,
1465
+ UID : "test-uid" ,
1466
+ },
1467
+ },
1310
1468
},
1311
1469
Spec : infrav1alpha2.LinodeMachineSpec {
1312
1470
ProviderID : ptr .To ("linode://123" ),
@@ -1384,6 +1542,7 @@ func mockCAPIMachine(mockK8sClient *mock.MockK8sClient) {
1384
1542
machine .Name = "test-machine"
1385
1543
machine .Namespace = "default"
1386
1544
machine .DeletionTimestamp = nil
1545
+ machine .UID = "test-uid"
1387
1546
}
1388
1547
return nil
1389
1548
}).AnyTimes ()
0 commit comments