@@ -45,18 +45,23 @@ import (
45
45
func ValidateOwnerReferencesOnUpdate (ctx context.Context , proxy ClusterProxy , namespace , clusterName string , assertFuncs ... map [string ]func (reference []metav1.OwnerReference ) error ) {
46
46
clusterKey := client.ObjectKey {Namespace : namespace , Name : clusterName }
47
47
48
- // Changes the version of all the owner references to v1alpha1. Expect the apiVersion to be updated after reconciliation .
48
+ // Pause the cluster .
49
49
setClusterPause (ctx , proxy .GetClient (), clusterKey , true )
50
50
51
51
// Change the version of the OwnerReferences on each object in the Graph to "v1alpha1"
52
52
changeOwnerReferencesAPIVersion (ctx , proxy , namespace )
53
53
54
+ // Unpause the cluster.
54
55
setClusterPause (ctx , proxy .GetClient (), clusterKey , false )
55
56
56
- // Annotate the clusterClass, if one is in use, to speed up reconciliation. This ensures ClusterClass ownerReferences
57
- // are re-reconciled before asserting the owner reference graph.
57
+ // Force ClusterClass reconciliation. This ensures ClusterClass ownerReferences are re-reconciled before asserting
58
+ // the owner reference graph.
58
59
forceClusterClassReconcile (ctx , proxy .GetClient (), clusterKey )
59
60
61
+ // Force ClusterResourceSet reconciliation. This ensures ClusterResourceBinding ownerReferences are re-reconciled before
62
+ // asserting the owner reference graph.
63
+ forceClusterResourceSetReconcile (ctx , proxy .GetClient (), namespace )
64
+
60
65
// Check that the ownerReferences have updated their apiVersions to current versions after reconciliation.
61
66
AssertOwnerReferences (namespace , proxy .GetKubeconfigPath (), assertFuncs ... )
62
67
}
@@ -79,6 +84,7 @@ func ValidateOwnerReferencesResilience(ctx context.Context, proxy ClusterProxy,
79
84
// Once all Clusters are paused remove the OwnerReference from all objects in the graph.
80
85
removeOwnerReferences (ctx , proxy , namespace )
81
86
87
+ // Unpause the cluster.
82
88
setClusterPause (ctx , proxy .GetClient (), clusterKey , false )
83
89
84
90
// Annotate the clusterClass, if one is in use, to speed up reconciliation. This ensures ClusterClass ownerReferences
@@ -367,6 +373,16 @@ func forceClusterClassReconcile(ctx context.Context, cli client.Client, clusterK
367
373
}
368
374
}
369
375
376
+ // forceClusterResourceSetReconcile forces reconciliation of all ClusterResourceSets.
377
+ func forceClusterResourceSetReconcile (ctx context.Context , cli client.Client , namespace string ) {
378
+ crsList := & addonsv1.ClusterResourceSetList {}
379
+ Expect (cli .List (ctx , crsList , client .InNamespace (namespace ))).To (Succeed ())
380
+ for _ , crs := range crsList .Items {
381
+ annotationPatch := client .RawPatch (types .MergePatchType , []byte (fmt .Sprintf ("{\" metadata\" :{\" annotations\" :{\" cluster.x-k8s.io/modifiedAt\" :\" %v\" }}}" , time .Now ().Format (time .RFC3339 ))))
382
+ Expect (cli .Patch (ctx , crs .DeepCopy (), annotationPatch )).To (Succeed ())
383
+ }
384
+ }
385
+
370
386
func changeOwnerReferencesAPIVersion (ctx context.Context , proxy ClusterProxy , namespace string ) {
371
387
graph , err := clusterctlcluster .GetOwnerGraph (ctx , namespace , proxy .GetKubeconfigPath ())
372
388
Expect (err ).ToNot (HaveOccurred ())
0 commit comments