@@ -54,7 +54,7 @@ import (
5454
5555 cacheclient "github.com/kcp-dev/kcp/pkg/cache/client"
5656 "github.com/kcp-dev/kcp/pkg/cache/client/shard"
57- "github.com/kcp-dev/kcp/pkg/reconciler/cache/cachedresources /replication"
57+ "github.com/kcp-dev/kcp/pkg/reconciler/cache/clustercachedresources /replication"
5858 "github.com/kcp-dev/kcp/test/e2e/framework"
5959)
6060
@@ -414,18 +414,18 @@ func replicateResourceNegative(ctx context.Context, t *testing.T,
414414 scenario .VerifyReplication (t .Context (), t )
415415
416416 t .Logf ("Delete cached %s %s/%s and check if it was brought back by the replication controller" , kind , clusterName , resourceName )
417- scenario .DeleteCachedResource (t .Context (), t )
417+ scenario .DeleteClusterCachedResource (t .Context (), t )
418418 scenario .VerifyReplication (t .Context (), t )
419419
420420 if resWithModifiedSpec != nil {
421421 t .Logf ("Update cached %s %s/%s so that it differs from the source resource" , kind , clusterName , scenario .resourceName )
422- scenario .UpdateSpecCachedResource (t .Context (), t , resWithModifiedSpec )
422+ scenario .UpdateSpecClusterCachedResource (t .Context (), t , resWithModifiedSpec )
423423 t .Logf ("Verify that the cached %s %s/%s was brought back by the replication controller after an update" , kind , clusterName , resourceName )
424424 scenario .VerifyReplication (t .Context (), t )
425425 }
426426
427427 t .Logf ("Update cached %s %s/%s so that it differs from the source resource" , kind , clusterName , scenario .resourceName )
428- scenario .UpdateMetaCachedResource (t .Context (), t )
428+ scenario .UpdateMetaClusterCachedResource (t .Context (), t )
429429 t .Logf ("Verify that the cached %s %s/%s was brought back by the replication controller after an update" , kind , clusterName , resourceName )
430430 scenario .VerifyReplication (t .Context (), t )
431431}
@@ -562,7 +562,7 @@ func (b *replicateResourceScenario) UpdateSpecSourceResource(ctx context.Context
562562 })
563563}
564564
565- func (b * replicateResourceScenario ) UpdateMetaCachedResource (ctx context.Context , t * testing.T ) {
565+ func (b * replicateResourceScenario ) UpdateMetaClusterCachedResource (ctx context.Context , t * testing.T ) {
566566 t .Helper ()
567567 b .resourceUpdateHelper (t .Context (), t , func (ctx context.Context ) (* unstructured.Unstructured , error ) {
568568 return b .cacheKcpClusterDynamicClient .Resource (b .gvr ).Cluster (b .cluster .Path ()).Get (cacheclient .WithShardInContext (t .Context (), shard .New ("root" )), b .resourceName , metav1.GetOptions {})
@@ -579,7 +579,7 @@ func (b *replicateResourceScenario) UpdateMetaCachedResource(ctx context.Context
579579 })
580580}
581581
582- func (b * replicateResourceScenario ) UpdateSpecCachedResource (ctx context.Context , t * testing.T , resWithModifiedSpec runtime.Object ) {
582+ func (b * replicateResourceScenario ) UpdateSpecClusterCachedResource (ctx context.Context , t * testing.T , resWithModifiedSpec runtime.Object ) {
583583 t .Helper ()
584584 b .resourceUpdateHelper (t .Context (), t , func (ctx context.Context ) (* unstructured.Unstructured , error ) {
585585 return b .cacheKcpClusterDynamicClient .Resource (b .gvr ).Cluster (b .cluster .Path ()).Get (cacheclient .WithShardInContext (t .Context (), shard .New ("root" )), b .resourceName , metav1.GetOptions {})
@@ -627,7 +627,7 @@ func (b *replicateResourceScenario) DeleteSourceResourceAndVerify(ctx context.Co
627627 }, wait .ForeverTestTimeout , 100 * time .Millisecond )
628628}
629629
630- func (b * replicateResourceScenario ) DeleteCachedResource (ctx context.Context , t * testing.T ) {
630+ func (b * replicateResourceScenario ) DeleteClusterCachedResource (ctx context.Context , t * testing.T ) {
631631 t .Helper ()
632632 err := b .cacheKcpClusterDynamicClient .Resource (b .gvr ).Cluster (b .cluster .Path ()).Delete (cacheclient .WithShardInContext (t .Context (), shard .New ("root" )), b .resourceName , metav1.DeleteOptions {})
633633 require .NoError (t , err )
@@ -679,7 +679,7 @@ func (b *replicateResourceScenario) verifyResourceReplicationHelper(ctx context.
679679 if err != nil {
680680 return false , err .Error ()
681681 }
682- cachedResource , err := b .cacheKcpClusterDynamicClient .Resource (b .gvr ).Cluster (b .cluster .Path ()).Get (cacheclient .WithShardInContext (t .Context (), shard .New ("root" )), b .resourceName , metav1.GetOptions {})
682+ clusterCachedResource , err := b .cacheKcpClusterDynamicClient .Resource (b .gvr ).Cluster (b .cluster .Path ()).Get (cacheclient .WithShardInContext (t .Context (), shard .New ("root" )), b .resourceName , metav1.GetOptions {})
683683 if err != nil {
684684 if ! errors .IsNotFound (err ) {
685685 return true , err .Error ()
@@ -692,40 +692,40 @@ func (b *replicateResourceScenario) verifyResourceReplicationHelper(ctx context.
692692 replication .AnnotationKeyOriginalResourceVersion ,
693693 replication .AnnotationKeyOriginalResourceUID ,
694694 )
695- cachedResourceMeta , err := meta .Accessor (cachedResource )
695+ clusterCachedResourceMeta , err := meta .Accessor (clusterCachedResource )
696696 if err != nil {
697697 return false , err .Error ()
698698 }
699- if _ , found := cachedResourceMeta .GetAnnotations ()[genericapirequest .ShardAnnotationKey ]; ! found {
700- t .Fatalf ("replicated %s root|%s/%s, doesn't have %s annotation" , b .gvr , cluster , cachedResourceMeta .GetName (), genericapirequest .ShardAnnotationKey )
699+ if _ , found := clusterCachedResourceMeta .GetAnnotations ()[genericapirequest .ShardAnnotationKey ]; ! found {
700+ t .Fatalf ("replicated %s root|%s/%s, doesn't have %s annotation" , b .gvr , cluster , clusterCachedResourceMeta .GetName (), genericapirequest .ShardAnnotationKey )
701701 }
702- if _ , found := cachedResourceMeta .GetAnnotations ()[replication .AnnotationKeyOriginalResourceVersion ]; ! found {
703- t .Fatalf ("replicated %s root|%s/%s, doesn't have %s annotation" , b .gvr , cluster , cachedResourceMeta .GetName (), replication .AnnotationKeyOriginalResourceVersion )
702+ if _ , found := clusterCachedResourceMeta .GetAnnotations ()[replication .AnnotationKeyOriginalResourceVersion ]; ! found {
703+ t .Fatalf ("replicated %s root|%s/%s, doesn't have %s annotation" , b .gvr , cluster , clusterCachedResourceMeta .GetName (), replication .AnnotationKeyOriginalResourceVersion )
704704 }
705- if _ , found := cachedResourceMeta .GetAnnotations ()[replication .AnnotationKeyOriginalResourceUID ]; ! found {
706- t .Fatalf ("replicated %s root|%s/%s, doesn't have %s annotation" , b .gvr , cluster , cachedResourceMeta .GetName (), replication .AnnotationKeyOriginalResourceUID )
705+ if _ , found := clusterCachedResourceMeta .GetAnnotations ()[replication .AnnotationKeyOriginalResourceUID ]; ! found {
706+ t .Fatalf ("replicated %s root|%s/%s, doesn't have %s annotation" , b .gvr , cluster , clusterCachedResourceMeta .GetName (), replication .AnnotationKeyOriginalResourceUID )
707707 }
708708 unstructured .RemoveNestedField (originalResource .Object , "metadata" , "resourceVersion" )
709- unstructured .RemoveNestedField (cachedResource .Object , "metadata" , "resourceVersion" )
709+ unstructured .RemoveNestedField (clusterCachedResource .Object , "metadata" , "resourceVersion" )
710710
711711 // TODO(davidfestal): find out why the generation is not equal, specially for rbacv1.
712712 // Is it a characteristic of all built-in kcp resources (which are not backed by CRDs) ?
713713 // Issue opened: https://github.com/kcp-dev/kcp/issues/2935
714714 if b .gvr .Group == rbacv1 .SchemeGroupVersion .Group {
715715 unstructured .RemoveNestedField (originalResource .Object , "metadata" , "generation" )
716- unstructured .RemoveNestedField (cachedResource .Object , "metadata" , "generation" )
716+ unstructured .RemoveNestedField (clusterCachedResource .Object , "metadata" , "generation" )
717717 }
718718
719- unstructured .RemoveNestedField (cachedResource .Object , "metadata" , "annotations" , genericapirequest .ShardAnnotationKey )
720- unstructured .RemoveNestedField (cachedResource .Object , "metadata" , "annotations" , replication .AnnotationKeyOriginalResourceVersion )
721- unstructured .RemoveNestedField (cachedResource .Object , "metadata" , "annotations" , replication .AnnotationKeyOriginalResourceUID )
722- if cachedStatus , ok := cachedResource .Object ["status" ]; ok && cachedStatus == nil || (cachedStatus != nil && len (cachedStatus .(map [string ]interface {})) == 0 ) {
719+ unstructured .RemoveNestedField (clusterCachedResource .Object , "metadata" , "annotations" , genericapirequest .ShardAnnotationKey )
720+ unstructured .RemoveNestedField (clusterCachedResource .Object , "metadata" , "annotations" , replication .AnnotationKeyOriginalResourceVersion )
721+ unstructured .RemoveNestedField (clusterCachedResource .Object , "metadata" , "annotations" , replication .AnnotationKeyOriginalResourceUID )
722+ if cachedStatus , ok := clusterCachedResource .Object ["status" ]; ok && cachedStatus == nil || (cachedStatus != nil && len (cachedStatus .(map [string ]interface {})) == 0 ) {
723723 // TODO: worth investigating:
724724 // for some reason cached resources have an empty status set whereas the original resources don't
725- unstructured .RemoveNestedField (cachedResource .Object , "status" )
725+ unstructured .RemoveNestedField (clusterCachedResource .Object , "status" )
726726 }
727- if diff := cmp .Diff (cachedResource .Object , originalResource .Object ); len (diff ) > 0 {
728- return false , fmt .Sprintf ("replicated %s root|%s/%s is different from the original: %s" , b .gvr , cluster , cachedResourceMeta .GetName (), diff )
727+ if diff := cmp .Diff (clusterCachedResource .Object , originalResource .Object ); len (diff ) > 0 {
728+ return false , fmt .Sprintf ("replicated %s root|%s/%s is different from the original: %s" , b .gvr , cluster , clusterCachedResourceMeta .GetName (), diff )
729729 }
730730 return true , ""
731731 }, wait .ForeverTestTimeout , 100 * time .Millisecond )
0 commit comments