@@ -56,7 +56,7 @@ func ValidateResourceVersionStable(ctx context.Context, proxy ClusterProxy, name
56
56
Consistently (func (g Gomega ) {
57
57
objectsWithResourceVersion , objects , err := getObjectsWithResourceVersion (ctx , proxy , namespace , ownerGraphFilterFunction )
58
58
g .Expect (err ).ToNot (HaveOccurred ())
59
- g .Expect (objectsWithResourceVersion ).To (BeComparableTo (previousResourceVersions ), printObjectDiff (previousObjects , objects ))
59
+ g .Expect (previousResourceVersions ).To (BeComparableTo (objectsWithResourceVersion ), printObjectDiff (previousObjects , objects ))
60
60
}, 2 * time .Minute , 15 * time .Second ).Should (Succeed (), "resourceVersions didn't stay stable" )
61
61
}
62
62
@@ -132,5 +132,37 @@ func getObjectsWithResourceVersion(ctx context.Context, proxy ClusterProxy, name
132
132
objectsWithResourceVersion [fmt .Sprintf ("%s/%s/%s" , node .Object .Kind , node .Object .Namespace , node .Object .Name )] = obj .GetResourceVersion ()
133
133
objects [fmt .Sprintf ("%s/%s/%s" , node .Object .Kind , node .Object .Namespace , node .Object .Name )] = obj
134
134
}
135
+
136
+ // Drop KubeConfig owned by MachinePools (and corresponding dataSecret), because they can change when the token.
137
+ keysToDelete := sets.Set [string ]{}
138
+ for key , obj := range objects {
139
+ if obj .GetObjectKind ().GroupVersionKind ().Kind != "KubeadmConfig" {
140
+ continue
141
+ }
142
+
143
+ isControlledByMachinePool := false
144
+ for _ , ref := range obj .GetOwnerReferences () {
145
+ if ref .Controller != nil && * ref .Controller && ref .Kind == "MachinePool" {
146
+ isControlledByMachinePool = true
147
+ break
148
+ }
149
+ }
150
+ if ! isControlledByMachinePool {
151
+ continue
152
+ }
153
+
154
+ keysToDelete .Insert (key )
155
+ if objUnstructured , ok := obj .(* unstructured.Unstructured ); ok {
156
+ if dataSecretName , ok , err := unstructured .NestedString (objUnstructured .Object , "status" , "dataSecretName" ); ok && err == nil {
157
+ keysToDelete .Insert (fmt .Sprintf ("Secret/%s/%s" , obj .GetNamespace (), dataSecretName ))
158
+ }
159
+ }
160
+ }
161
+
162
+ for _ , key := range keysToDelete .UnsortedList () {
163
+ delete (objectsWithResourceVersion , key )
164
+ delete (objects , key )
165
+ }
166
+
135
167
return objectsWithResourceVersion , objects , nil
136
168
}
0 commit comments