@@ -260,12 +260,12 @@ func assertClusterObjects(ctx context.Context, clusterProxy framework.ClusterPro
260
260
261
261
// ControlPlane
262
262
assertControlPlane (g , clusterClassObjects , clusterObjects , cluster , clusterClass )
263
- assertControlPlaneMachines (g , clusterObjects )
263
+ assertControlPlaneMachines (g , clusterObjects , cluster )
264
264
265
265
// MachineDeployments
266
266
assertMachineDeployments (g , clusterClassObjects , clusterObjects , cluster , clusterClass )
267
267
assertMachineSets (g , clusterObjects , cluster )
268
- assertMachineSetsMachines (g , clusterObjects )
268
+ assertMachineSetsMachines (g , clusterObjects , cluster )
269
269
270
270
By ("All cluster objects have the right labels, annotations and selectors" )
271
271
}, 10 * time .Second , 1 * time .Second ).Should (Succeed ())
@@ -375,7 +375,7 @@ func assertControlPlane(g Gomega, clusterClassObjects clusterClassObjects, clust
375
375
))
376
376
}
377
377
378
- func assertControlPlaneMachines (g Gomega , clusterObjects clusterObjects ) {
378
+ func assertControlPlaneMachines (g Gomega , clusterObjects clusterObjects , cluster * clusterv1. Cluster ) {
379
379
controlPlaneMachineTemplateMetadata := mustMetadata (contract .ControlPlane ().MachineTemplate ().Metadata ().Get (clusterObjects .ControlPlane ))
380
380
controlPlaneInfrastructureMachineTemplateTemplateMetadata := mustMetadata (contract .InfrastructureMachineTemplate ().Template ().Metadata ().Get (clusterObjects .ControlPlaneInfrastructureMachineTemplate ))
381
381
@@ -384,6 +384,7 @@ func assertControlPlaneMachines(g Gomega, clusterObjects clusterObjects) {
384
384
g .Expect (machine .Labels ).To (BeEquivalentTo (
385
385
union (
386
386
map [string ]string {
387
+ clusterv1 .ClusterNameLabel : cluster .Name ,
387
388
clusterv1 .MachineControlPlaneLabel : "" ,
388
389
clusterv1 .MachineControlPlaneNameLabel : clusterObjects .ControlPlane .GetName (),
389
390
},
@@ -405,6 +406,7 @@ func assertControlPlaneMachines(g Gomega, clusterObjects clusterObjects) {
405
406
g .Expect (infrastructureMachine .GetLabels ()).To (BeEquivalentTo (
406
407
union (
407
408
map [string ]string {
409
+ clusterv1 .ClusterNameLabel : cluster .Name ,
408
410
clusterv1 .MachineControlPlaneLabel : "" ,
409
411
clusterv1 .MachineControlPlaneNameLabel : clusterObjects .ControlPlane .GetName (),
410
412
},
@@ -428,6 +430,7 @@ func assertControlPlaneMachines(g Gomega, clusterObjects clusterObjects) {
428
430
g .Expect (bootstrapConfig .GetLabels ()).To (BeEquivalentTo (
429
431
union (
430
432
map [string ]string {
433
+ clusterv1 .ClusterNameLabel : cluster .Name ,
431
434
clusterv1 .MachineControlPlaneLabel : "" ,
432
435
clusterv1 .MachineControlPlaneNameLabel : clusterObjects .ControlPlane .GetName (),
433
436
},
@@ -589,8 +592,11 @@ func assertMachineSets(g Gomega, clusterObjects clusterObjects, cluster *cluster
589
592
g .Expect (machineSet .Labels ).To (BeEquivalentTo (
590
593
union (
591
594
map [string ]string {
592
- clusterv1 .MachineDeploymentNameLabel : machineDeployment .Name ,
593
- clusterv1 .MachineDeploymentUniqueLabel : machineTemplateHash ,
595
+ clusterv1 .ClusterNameLabel : cluster .Name ,
596
+ clusterv1 .ClusterTopologyOwnedLabel : "" ,
597
+ clusterv1 .ClusterTopologyMachineDeploymentNameLabel : mdTopology .Name ,
598
+ clusterv1 .MachineDeploymentNameLabel : machineDeployment .Name ,
599
+ clusterv1 .MachineDeploymentUniqueLabel : machineTemplateHash ,
594
600
},
595
601
machineDeployment .Spec .Template .Labels ,
596
602
),
@@ -619,7 +625,10 @@ func assertMachineSets(g Gomega, clusterObjects clusterObjects, cluster *cluster
619
625
g .Expect (machineSet .Spec .Template .Labels ).To (BeEquivalentTo (
620
626
union (
621
627
map [string ]string {
622
- clusterv1 .MachineDeploymentUniqueLabel : machineTemplateHash ,
628
+ clusterv1 .ClusterNameLabel : cluster .Name ,
629
+ clusterv1 .ClusterTopologyOwnedLabel : "" ,
630
+ clusterv1 .ClusterTopologyMachineDeploymentNameLabel : mdTopology .Name ,
631
+ clusterv1 .MachineDeploymentUniqueLabel : machineTemplateHash ,
623
632
},
624
633
machineDeployment .Spec .Template .Labels ,
625
634
),
@@ -631,21 +640,28 @@ func assertMachineSets(g Gomega, clusterObjects clusterObjects, cluster *cluster
631
640
}
632
641
}
633
642
634
- func assertMachineSetsMachines (g Gomega , clusterObjects clusterObjects ) {
643
+ func assertMachineSetsMachines (g Gomega , clusterObjects clusterObjects , cluster * clusterv1. Cluster ) {
635
644
for _ , machineDeployment := range clusterObjects .MachineDeployments {
645
+ mdTopology := getMDTopology (cluster , machineDeployment )
636
646
infrastructureMachineTemplate := clusterObjects .InfrastructureMachineTemplateByMachineDeployment [machineDeployment .Name ]
637
647
infrastructureMachineTemplateTemplateMetadata := mustMetadata (contract .InfrastructureMachineTemplate ().Template ().Metadata ().Get (infrastructureMachineTemplate ))
638
648
bootstrapConfigTemplate := clusterObjects .BootstrapConfigTemplateByMachineDeployment [machineDeployment .Name ]
639
649
bootstrapConfigTemplateTemplateMetadata := mustMetadata (contract .BootstrapConfigTemplate ().Template ().Metadata ().Get (bootstrapConfigTemplate ))
640
650
641
651
for _ , machineSet := range clusterObjects .MachineSetsByMachineDeployment [machineDeployment .Name ] {
652
+ machineTemplateHash := machineSet .Labels [clusterv1 .MachineDeploymentUniqueLabel ]
653
+
642
654
for _ , machine := range clusterObjects .MachinesByMachineSet [machineSet .Name ] {
643
655
// MachineDeployment MachineSet Machine.metadata
644
656
g .Expect (machine .Labels ).To (BeEquivalentTo (
645
657
union (
646
658
map [string ]string {
647
- clusterv1 .MachineDeploymentNameLabel : machineDeployment .Name ,
648
- clusterv1 .MachineSetNameLabel : machineSet .Name ,
659
+ clusterv1 .ClusterNameLabel : cluster .Name ,
660
+ clusterv1 .ClusterTopologyOwnedLabel : "" ,
661
+ clusterv1 .ClusterTopologyMachineDeploymentNameLabel : mdTopology .Name ,
662
+ clusterv1 .MachineDeploymentNameLabel : machineDeployment .Name ,
663
+ clusterv1 .MachineSetNameLabel : machineSet .Name ,
664
+ clusterv1 .MachineDeploymentUniqueLabel : machineTemplateHash ,
649
665
},
650
666
machineSet .Spec .Template .Labels ,
651
667
),
@@ -659,8 +675,12 @@ func assertMachineSetsMachines(g Gomega, clusterObjects clusterObjects) {
659
675
g .Expect (infrastructureMachine .GetLabels ()).To (BeEquivalentTo (
660
676
union (
661
677
map [string ]string {
662
- clusterv1 .MachineDeploymentNameLabel : machineDeployment .Name ,
663
- clusterv1 .MachineSetNameLabel : machineSet .Name ,
678
+ clusterv1 .ClusterNameLabel : cluster .Name ,
679
+ clusterv1 .ClusterTopologyOwnedLabel : "" ,
680
+ clusterv1 .ClusterTopologyMachineDeploymentNameLabel : mdTopology .Name ,
681
+ clusterv1 .MachineDeploymentNameLabel : machineDeployment .Name ,
682
+ clusterv1 .MachineSetNameLabel : machineSet .Name ,
683
+ clusterv1 .MachineDeploymentUniqueLabel : machineTemplateHash ,
664
684
},
665
685
machineSet .Spec .Template .Labels ,
666
686
infrastructureMachineTemplateTemplateMetadata .Labels ,
@@ -682,8 +702,12 @@ func assertMachineSetsMachines(g Gomega, clusterObjects clusterObjects) {
682
702
g .Expect (bootstrapConfig .GetLabels ()).To (BeEquivalentTo (
683
703
union (
684
704
map [string ]string {
685
- clusterv1 .MachineDeploymentNameLabel : machineDeployment .Name ,
686
- clusterv1 .MachineSetNameLabel : machineSet .Name ,
705
+ clusterv1 .ClusterNameLabel : cluster .Name ,
706
+ clusterv1 .ClusterTopologyOwnedLabel : "" ,
707
+ clusterv1 .ClusterTopologyMachineDeploymentNameLabel : mdTopology .Name ,
708
+ clusterv1 .MachineDeploymentNameLabel : machineDeployment .Name ,
709
+ clusterv1 .MachineSetNameLabel : machineSet .Name ,
710
+ clusterv1 .MachineDeploymentUniqueLabel : machineTemplateHash ,
687
711
},
688
712
machineSet .Spec .Template .Labels ,
689
713
bootstrapConfigTemplateTemplateMetadata .Labels ,
0 commit comments