@@ -49,6 +49,8 @@ import (
49
49
)
50
50
51
51
// ClusterClassRolloutSpecInput is the input for ClusterClassRolloutSpec.
52
+ // FIXME(sbueringer):doc: review the entire PR and add more godoc
53
+ // FIXME(sbueringer): review the entire PR and check if we can move more to util funcs, split up more funcs
52
54
type ClusterClassRolloutSpecInput struct {
53
55
E2EConfig * clusterctl.E2EConfig
54
56
ClusterctlConfigPath string
@@ -59,7 +61,7 @@ type ClusterClassRolloutSpecInput struct {
59
61
60
62
// Flavor is the cluster-template flavor used to create the Cluster for testing.
61
63
// NOTE: The template must be using a ClusterClass.
62
- // FIXME(sbueringer): add more requirements
64
+ // FIXME(sbueringer):doc: add more requirements
63
65
Flavor string
64
66
65
67
// ModifyControlPlaneFields are the ControlPlane fields which will be set on the
@@ -69,7 +71,7 @@ type ClusterClassRolloutSpecInput struct {
69
71
// map[string]interface{}{
70
72
// "spec.path.to.field": <value>,
71
73
// }
72
- // FIXME(sbueringer): should be a field which triggers a Machine rollout
74
+ // FIXME(sbueringer):doc: should be a field which triggers a Machine rollout
73
75
ModifyControlPlaneFields map [string ]interface {}
74
76
75
77
// ModifyMachineDeploymentBootstrapConfigTemplateFields are the fields which will be set on the
@@ -92,7 +94,7 @@ type ClusterClassRolloutSpecInput struct {
92
94
}
93
95
94
96
// ClusterClassRolloutSpec implements a test that verifies that ClusterClass changes are rolled out successfully.
95
- // FIXME(sbueringer)
97
+ // FIXME(sbueringer):doc document this test is specifically for KCP + CABPK + MD/MS rollouts
96
98
// Thus, the test consists of the following steps:
97
99
// - Deploy Cluster using a ClusterClass and wait until it is fully provisioned.
98
100
// - Modify the ControlPlaneTemplate of the ClusterClass by setting ModifyControlPlaneFields
@@ -162,8 +164,6 @@ func ClusterClassRolloutSpec(ctx context.Context, inputGetter func() ClusterClas
162
164
163
165
assertMetadataOnClusterObjects (ctx , input .BootstrapClusterProxy , clusterResources .Cluster , clusterResources .ClusterClass )
164
166
165
- // FIXME: Verify all labels/annotations exactly on all objects (including nodes, inframachine, bootstrapconfig?) (fail on CAPI internal labels/annotations)
166
-
167
167
By ("Rolling out changes to control plane and MachineDeployment (in-place)" )
168
168
169
169
By ("Modifying the control plane configuration in Cluster and wait for changes to be applied to the control plane object (in-place)" )
@@ -184,10 +184,6 @@ func ClusterClassRolloutSpec(ctx context.Context, inputGetter func() ClusterClas
184
184
},
185
185
WaitForControlPlane : input .E2EConfig .GetIntervals (specName , "wait-control-plane" ),
186
186
})
187
-
188
- // FIXME: Verify all labels/annotations exactly on all objects (including nodes, inframachine, bootstrapconfig?) (fail on CAPI internal labels/annotations)
189
- // FIXME: Verify Machines are still the same
190
-
191
187
By ("Modifying the MachineDeployment configuration in ClusterClass and wait for changes to be applied to the MachineDeployment objects (in-place" )
192
188
modifyMachineDeploymentViaClusterAndWait (ctx , modifyMachineDeploymentViaClusterAndWaitInput {
193
189
ClusterProxy : input .BootstrapClusterProxy ,
@@ -219,8 +215,9 @@ func ClusterClassRolloutSpec(ctx context.Context, inputGetter func() ClusterClas
219
215
WaitForMachineDeployments : input .E2EConfig .GetIntervals (specName , "wait-worker-nodes" ),
220
216
})
221
217
222
- // FIXME: Verify all labels/annotations exactly on all objects (including nodes, inframachine, bootstrapconfig?) (fail on CAPI internal labels/annotations)
223
- // * Wait for machines & they are still the same
218
+ assertMetadataOnClusterObjects (ctx , input .BootstrapClusterProxy , clusterResources .Cluster , clusterResources .ClusterClass )
219
+
220
+ // FIXME: Verify machines are still the same (assert already waited for the in-place rollout)
224
221
225
222
By ("Rolling out changes to control plane and MachineDeployment (rollout)" )
226
223
@@ -232,10 +229,6 @@ func ClusterClassRolloutSpec(ctx context.Context, inputGetter func() ClusterClas
232
229
ModifyControlPlaneFields : input .ModifyControlPlaneFields ,
233
230
WaitForControlPlane : input .E2EConfig .GetIntervals (specName , "wait-control-plane" ),
234
231
})
235
-
236
- // FIXME: Verify all labels/annotations exactly on all objects (including nodes, inframachine, bootstrapconfig?) (fail on CAPI internal labels/annotations)
237
- // * Wait for machines & they are new
238
-
239
232
By ("Modifying the MachineDeployment configuration in ClusterClass and wait for changes to be applied to the MachineDeployment objects (rollout" )
240
233
modifyMachineDeploymentViaClusterClassAndWait (ctx , modifyMachineDeploymentViaClusterClassAndWaitInput {
241
234
ClusterProxy : input .BootstrapClusterProxy ,
@@ -246,9 +239,9 @@ func ClusterClassRolloutSpec(ctx context.Context, inputGetter func() ClusterClas
246
239
WaitForMachineDeployments : input .E2EConfig .GetIntervals (specName , "wait-worker-nodes" ),
247
240
})
248
241
249
- // FIXME: Verify all labels/annotations exactly on all objects (including nodes, inframachine, bootstrapconfig?) (fail on CAPI internal labels/annotations )
250
- // * Wait for machines & they are new
251
- // * Verify old MachineSet is not changed
242
+ assertMetadataOnClusterObjects ( ctx , input . BootstrapClusterProxy , clusterResources . Cluster , clusterResources . ClusterClass )
243
+
244
+ // FIXME: Verify machines are all rotated (assert already waited for the full rollout)
252
245
253
246
By ("PASSED!" )
254
247
})
@@ -259,10 +252,11 @@ func ClusterClassRolloutSpec(ctx context.Context, inputGetter func() ClusterClas
259
252
})
260
253
}
261
254
262
- // FIXME: ensure we wait until everything is reconciled enough before we call this func
263
- // FIXME: extract util stuff into util funcs, also the whole get all objects thing
264
- // FIXME: check assertions have the right semantics (i.e. they use the right labels/annotations => based on picture)
265
- // FIXME: double check ordering vs code
255
+ // FIXME: Ensure this func gracefully retries if the rollout is not complete (e.g. node might not exist)
256
+ // FIXME: Check assertions have the right semantics (i.e. they use the right labels/annotations => based on picture)
257
+ // FIXME: Double check ordering of labels/annotations vs our code paths
258
+ // FIXME: Split up func in smaller assertion funcs
259
+ // FIXME: Maybe extract util stuff into util funcs
266
260
func assertMetadataOnClusterObjects (ctx context.Context , clusterProxy framework.ClusterProxy , cluster * clusterv1.Cluster , clusterClass * clusterv1.ClusterClass ) {
267
261
By ("Checking cluster objects have the right labels, annotations and selectors" )
268
262
@@ -323,15 +317,15 @@ func assertMetadataOnClusterObjects(ctx context.Context, clusterProxy framework.
323
317
},
324
318
cluster .Spec .Topology .ControlPlane .Metadata .Labels ,
325
319
clusterClass .Spec .ControlPlane .Metadata .Labels ,
326
- //machineTemplateMetadata(clusterClassObjects.ControlPlaneTemplate).Labels, // FIXME: shouldn 't work atm (fix CC reconciler)
320
+ //machineTemplateMetadata(clusterClassObjects.ControlPlaneTemplate).Labels, // FIXME: doesn 't work atm (fix CC reconciler)
327
321
),
328
322
))
329
323
330
324
g .Expect (controlPlaneMachineTemplateMetadata .Annotations ).To (BeEquivalentTo (
331
325
union (
332
326
cluster .Spec .Topology .ControlPlane .Metadata .Annotations ,
333
327
clusterClass .Spec .ControlPlane .Metadata .Annotations ,
334
- //machineTemplateMetadata(clusterClassObjects.ControlPlaneTemplate).Annotations, // FIXME: shouldn 't work atm (fix CC reconciler)
328
+ //machineTemplateMetadata(clusterClassObjects.ControlPlaneTemplate).Annotations, // FIXME: doesn 't work atm (fix CC reconciler)
335
329
),
336
330
))
337
331
@@ -560,6 +554,7 @@ func assertMetadataOnClusterObjects(ctx context.Context, clusterProxy framework.
560
554
561
555
// MachineDeployment MachineSet
562
556
for _ , machineSet := range clusterObjects .MachineSetsByMachineDeployment [machineDeployment .Name ] {
557
+ // FIXME: skip old MachineSet
563
558
machineTemplateHash := machineSet .Labels [clusterv1 .MachineDeploymentUniqueLabel ]
564
559
565
560
g .Expect (machineSet .Labels ).To (BeEquivalentTo (
@@ -676,7 +671,7 @@ func assertMetadataOnClusterObjects(ctx context.Context, clusterProxy framework.
676
671
}
677
672
}
678
673
679
- fmt . Println ( "FIXME: breakpoint " )
674
+ By ( "All cluster objects have the right labels, annotations and selectors " )
680
675
}, 10 * time .Minute , 1 * time .Second ).Should (Succeed ()) // FIXME: timeouts, look at actual rollout times
681
676
}
682
677
@@ -713,7 +708,8 @@ func groupKind(ref *corev1.ObjectReference) string {
713
708
return gk .String ()
714
709
}
715
710
716
- // FIXME(sbueringer) move to contract (+ use must func)
711
+ // FIXME(sbueringer) move to contract (+ use must func), also for other usages of contract + check if we can optimize contract call length
712
+ // e.g. contract.ControlPlane().MachineTemplate() => controlPlaneMachineTemplate := contract.ControlPlane().MachineTemplate()
717
713
func templateMetadata (obj * unstructured.Unstructured ) * clusterv1.ObjectMeta {
718
714
labelsValue , ok , err := unstructured .NestedStringMap (obj .UnstructuredContent (), "spec" , "template" , "metadata" , "labels" )
719
715
Expect (err ).ToNot (HaveOccurred ())
@@ -733,26 +729,6 @@ func templateMetadata(obj *unstructured.Unstructured) *clusterv1.ObjectMeta {
733
729
}
734
730
}
735
731
736
- // FIXME(sbueringer) move to contract (+ use must func)
737
- func machineTemplateMetadata (obj * unstructured.Unstructured ) * clusterv1.ObjectMeta {
738
- labelsValue , ok , err := unstructured .NestedStringMap (obj .UnstructuredContent (), "spec" , "template" , "spec" , "machineTemplate" , "metadata" , "labels" )
739
- Expect (err ).ToNot (HaveOccurred ())
740
- if ! ok {
741
- labelsValue = map [string ]string {}
742
- }
743
-
744
- annotationsValue , ok , err := unstructured .NestedStringMap (obj .UnstructuredContent (), "spec" , "template" , "spec" , "machineTemplate" , "metadata" , "annotations" )
745
- Expect (err ).ToNot (HaveOccurred ())
746
- if ! ok {
747
- annotationsValue = map [string ]string {}
748
- }
749
-
750
- return & clusterv1.ObjectMeta {
751
- Labels : labelsValue ,
752
- Annotations : annotationsValue ,
753
- }
754
- }
755
-
756
732
type unionMap map [string ]string
757
733
758
734
// union merges maps. keys from earlier maps are preserved over keys from later maps.
@@ -811,7 +787,6 @@ type clusterClassObjects struct {
811
787
BootstrapConfigTemplateByMachineDeploymentClass map [string ]* unstructured.Unstructured
812
788
}
813
789
814
- // FIXME: ensure bootstrap is optional everywhere
815
790
func getClusterClassObjects (ctx context.Context , g Gomega , clusterProxy framework.ClusterProxy , clusterClass * clusterv1.ClusterClass ) clusterClassObjects {
816
791
mgmtClient := clusterProxy .GetClient ()
817
792
@@ -835,11 +810,9 @@ func getClusterClassObjects(ctx context.Context, g Gomega, clusterProxy framewor
835
810
g .Expect (err ).ToNot (HaveOccurred ())
836
811
res .InfrastructureMachineTemplateByMachineDeploymentClass [mdClass .Class ] = infrastructureMachineTemplate
837
812
838
- if mdClass .Template .Bootstrap .Ref != nil {
839
- bootstrapConfigTemplate , err := external .Get (ctx , mgmtClient , mdClass .Template .Bootstrap .Ref , clusterClass .Namespace )
840
- g .Expect (err ).ToNot (HaveOccurred ())
841
- res .BootstrapConfigTemplateByMachineDeploymentClass [mdClass .Class ] = bootstrapConfigTemplate
842
- }
813
+ bootstrapConfigTemplate , err := external .Get (ctx , mgmtClient , mdClass .Template .Bootstrap .Ref , clusterClass .Namespace )
814
+ g .Expect (err ).ToNot (HaveOccurred ())
815
+ res .BootstrapConfigTemplateByMachineDeploymentClass [mdClass .Class ] = bootstrapConfigTemplate
843
816
}
844
817
845
818
return res
@@ -864,7 +837,7 @@ type clusterObjects struct {
864
837
BootstrapConfigByMachine map [string ]* unstructured.Unstructured
865
838
}
866
839
867
- // FIXME(sbueringer) add godoc (which should help with structure
840
+ // FIXME(sbueringer):doc add godoc (which should help with structure)
868
841
func getClusterObjects (ctx context.Context , g Gomega , clusterProxy framework.ClusterProxy , cluster * clusterv1.Cluster ) clusterObjects {
869
842
mgmtClient := clusterProxy .GetClient ()
870
843
workloadClient := clusterProxy .GetWorkloadCluster (ctx , cluster .Namespace , cluster .Name ).GetClient ()
@@ -912,11 +885,9 @@ func getClusterObjects(ctx context.Context, g Gomega, clusterProxy framework.Clu
912
885
md := mdList .Items [0 ]
913
886
res .MachineDeployments = append (res .MachineDeployments , & md )
914
887
915
- if md .Spec .Template .Spec .Bootstrap .ConfigRef != nil {
916
- bootstrapConfigTemplate , err := external .Get (ctx , mgmtClient , md .Spec .Template .Spec .Bootstrap .ConfigRef , cluster .Namespace )
917
- g .Expect (err ).ToNot (HaveOccurred ())
918
- res .BootstrapConfigTemplateByMachineDeployment [md .Name ] = bootstrapConfigTemplate
919
- }
888
+ bootstrapConfigTemplate , err := external .Get (ctx , mgmtClient , md .Spec .Template .Spec .Bootstrap .ConfigRef , cluster .Namespace )
889
+ g .Expect (err ).ToNot (HaveOccurred ())
890
+ res .BootstrapConfigTemplateByMachineDeployment [md .Name ] = bootstrapConfigTemplate
920
891
921
892
infrastructureMachineTemplate , err := external .Get (ctx , mgmtClient , & md .Spec .Template .Spec .InfrastructureRef , cluster .Namespace )
922
893
g .Expect (err ).ToNot (HaveOccurred ())
@@ -944,11 +915,9 @@ func getClusterObjects(ctx context.Context, g Gomega, clusterProxy framework.Clu
944
915
}
945
916
946
917
func addMachineObjects (ctx context.Context , g Gomega , res clusterObjects , mgmtClient , workloadClient client.Client , cluster * clusterv1.Cluster , machine * clusterv1.Machine ) {
947
- if machine .Spec .Bootstrap .ConfigRef != nil {
948
- bootstrapConfig , err := external .Get (ctx , mgmtClient , machine .Spec .Bootstrap .ConfigRef , cluster .Namespace )
949
- g .Expect (err ).ToNot (HaveOccurred ())
950
- res .BootstrapConfigByMachine [machine .Name ] = bootstrapConfig
951
- }
918
+ bootstrapConfig , err := external .Get (ctx , mgmtClient , machine .Spec .Bootstrap .ConfigRef , cluster .Namespace )
919
+ g .Expect (err ).ToNot (HaveOccurred ())
920
+ res .BootstrapConfigByMachine [machine .Name ] = bootstrapConfig
952
921
953
922
infrastructureMachine , err := external .Get (ctx , mgmtClient , & machine .Spec .InfrastructureRef , cluster .Namespace )
954
923
g .Expect (err ).ToNot (HaveOccurred ())
@@ -971,7 +940,6 @@ type modifyControlPlaneViaClusterAndWaitInput struct {
971
940
// modifyControlPlaneViaClusterAndWait modifies the ControlPlaneTemplate of a ClusterClass by setting ModifyControlPlaneFields
972
941
// and waits until the changes are rolled out to the ControlPlane of the Cluster.
973
942
// NOTE: This helper is really specific to this test, so we are keeping this private vs. adding it to the framework.
974
- // FIXME(sbueringer)
975
943
func modifyControlPlaneViaClusterAndWait (ctx context.Context , input modifyControlPlaneViaClusterAndWaitInput ) {
976
944
Expect (ctx ).NotTo (BeNil (), "ctx is required for modifyControlPlaneViaClusterAndWait" )
977
945
Expect (input .ClusterProxy ).ToNot (BeNil (), "Invalid argument. input.ClusterProxy can't be nil when calling modifyControlPlaneViaClusterAndWait" )
@@ -1013,7 +981,6 @@ type modifyMachineDeploymentViaClusterAndWaitInput struct {
1013
981
// modifyMachineDeploymentViaClusterAndWait modifies the BootstrapConfigTemplate of MachineDeploymentClasses of a ClusterClass
1014
982
// by setting ModifyBootstrapConfigTemplateFields and waits until the changes are rolled out to the MachineDeployments of the Cluster.
1015
983
// NOTE: This helper is really specific to this test, so we are keeping this private vs. adding it to the framework.
1016
- // FIXME(sbueringer)
1017
984
func modifyMachineDeploymentViaClusterAndWait (ctx context.Context , input modifyMachineDeploymentViaClusterAndWaitInput ) {
1018
985
Expect (ctx ).NotTo (BeNil (), "ctx is required for modifyMachineDeploymentViaClusterAndWait" )
1019
986
Expect (input .ClusterProxy ).ToNot (BeNil (), "Invalid argument. input.ClusterProxy can't be nil when calling modifyMachineDeploymentViaClusterAndWait" )
0 commit comments