@@ -24,40 +24,40 @@ import (
24
24
25
25
"github.com/google/go-cmp/cmp"
26
26
. "github.com/onsi/gomega"
27
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27
+ "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured "
28
28
"k8s.io/apimachinery/pkg/util/sets"
29
29
"sigs.k8s.io/controller-runtime/pkg/client"
30
30
"sigs.k8s.io/yaml"
31
31
32
32
clusterctlcluster "sigs.k8s.io/cluster-api/cmd/clusterctl/client/cluster"
33
33
)
34
34
35
- // ValidateResourceVersionStable checks that resource versions are stable.
35
+ // ValidateResourceVersionStable checks that resourceVersions are stable.
36
36
func ValidateResourceVersionStable (ctx context.Context , proxy ClusterProxy , namespace string , ownerGraphFilterFunction clusterctlcluster.GetOwnerGraphFilterFunction ) {
37
- // Wait until resource versions are stable for a bit.
38
- byf ("Check Resource versions are stable" )
37
+ // Wait until resourceVersions are stable for a bit.
38
+ byf ("Check resourceVersions are stable" )
39
39
var previousResourceVersions map [string ]string
40
40
var previousObjects map [string ]client.Object
41
41
Eventually (func (g Gomega ) {
42
42
objectsWithResourceVersion , objects , err := getObjectsWithResourceVersion (ctx , proxy , namespace , ownerGraphFilterFunction )
43
43
g .Expect (err ).ToNot (HaveOccurred ())
44
44
45
45
defer func () {
46
- // Set current resource versions as previous resource versions for the next try.
46
+ // Set current resourceVersions as previous resourceVersions for the next try.
47
47
previousResourceVersions = objectsWithResourceVersion
48
48
previousObjects = objects
49
49
}()
50
50
// This is intentionally failing on the first run.
51
51
g .Expect (objectsWithResourceVersion ).To (BeComparableTo (previousResourceVersions ))
52
- }, 1 * time .Minute , 15 * time .Second ).Should (Succeed (), "Resource versions never became stable" )
52
+ }, 1 * time .Minute , 15 * time .Second ).Should (Succeed (), "resourceVersions never became stable" )
53
53
54
- // Verify resource versions are stable for a while.
55
- byf ("Check Resource versions remain stable" )
54
+ // Verify resourceVersions are stable for a while.
55
+ byf ("Check resourceVersions remain stable" )
56
56
Consistently (func (g Gomega ) {
57
57
objectsWithResourceVersion , objects , err := getObjectsWithResourceVersion (ctx , proxy , namespace , ownerGraphFilterFunction )
58
58
g .Expect (err ).ToNot (HaveOccurred ())
59
59
g .Expect (objectsWithResourceVersion ).To (BeComparableTo (previousResourceVersions ), printObjectDiff (previousObjects , objects ))
60
- }, 2 * time .Minute , 15 * time .Second ).Should (Succeed (), "Resource versions didn't stay stable" )
60
+ }, 2 * time .Minute , 15 * time .Second ).Should (Succeed (), "resourceVersions didn't stay stable" )
61
61
}
62
62
63
63
func printObjectDiff (previousObjects , newObjects map [string ]client.Object ) func () string {
@@ -123,16 +123,13 @@ func getObjectsWithResourceVersion(ctx context.Context, proxy ClusterProxy, name
123
123
objects := map [string ]client.Object {}
124
124
for _ , node := range graph {
125
125
nodeNamespacedName := client.ObjectKey {Namespace : node .Object .Namespace , Name : node .Object .Name }
126
- obj := & metav1.PartialObjectMetadata {
127
- TypeMeta : metav1.TypeMeta {
128
- APIVersion : node .Object .APIVersion ,
129
- Kind : node .Object .Kind ,
130
- },
131
- }
126
+ obj := & unstructured.Unstructured {}
127
+ obj .SetAPIVersion (node .Object .APIVersion )
128
+ obj .SetKind (node .Object .Kind )
132
129
if err := proxy .GetClient ().Get (ctx , nodeNamespacedName , obj ); err != nil {
133
130
return nil , nil , err
134
131
}
135
- objectsWithResourceVersion [fmt .Sprintf ("%s/%s/%s" , node .Object .Kind , node .Object .Namespace , node .Object .Name )] = obj .ResourceVersion
132
+ objectsWithResourceVersion [fmt .Sprintf ("%s/%s/%s" , node .Object .Kind , node .Object .Namespace , node .Object .Name )] = obj .GetResourceVersion ()
136
133
objects [fmt .Sprintf ("%s/%s/%s" , node .Object .Kind , node .Object .Namespace , node .Object .Name )] = obj
137
134
}
138
135
return objectsWithResourceVersion , objects , nil
0 commit comments