Skip to content

Commit 508d9ea

Browse files
committed
fixups
1 parent 8d12c67 commit 508d9ea

19 files changed

+152
-170
lines changed

controllers/clustercache/cluster_accessor.go

+3
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ type clusterAccessorCacheConfig struct {
9090
// InitialSyncTimeout is the timeout used when waiting for the first cache sync after cache start.
9191
InitialSyncTimeout time.Duration
9292

93+
// SyncPeriod is the sync period of the cache.
94+
SyncPeriod *time.Duration
95+
9396
// ByObject restricts the cache's ListWatch to the desired fields per GVK at the specified object.
9497
ByObject map[client.Object]cache.ByObject
9598

controllers/clustercache/cluster_accessor_client.go

+1
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ func createCachedClient(ctx context.Context, clusterAccessorConfig *clusterAcces
219219
HTTPClient: httpClient,
220220
Scheme: clusterAccessorConfig.Scheme,
221221
Mapper: mapper,
222+
SyncPeriod: clusterAccessorConfig.Cache.SyncPeriod,
222223
ByObject: clusterAccessorConfig.Cache.ByObject,
223224
}
224225
remoteCache, err := cache.New(config, cacheOptions)

controllers/clustercache/cluster_cache.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ type Options struct {
6666

6767
// CacheOptions are the cache options for the caches that are created per cluster.
6868
type CacheOptions struct {
69+
// SyncPeriod is the sync period of the cache.
70+
SyncPeriod *time.Duration
71+
6972
// ByObject restricts the cache's ListWatch to the desired fields per GVK at the specified object.
7073
ByObject map[client.Object]cache.ByObject
7174

@@ -119,6 +122,7 @@ type ClientCacheOptions struct {
119122
DisableFor []client.Object
120123
}
121124

125+
// ClusterCache is a component that caches clients, caches etc. for workload clusters.
122126
type ClusterCache interface {
123127
// GetClient returns a cached client for the given cluster.
124128
// If there is no connection to the workload cluster ErrClusterNotConnected will be returned.
@@ -434,7 +438,7 @@ func (cc *clusterCache) Reconcile(ctx context.Context, req reconcile.Request) (r
434438

435439
// Store that disconnect was done.
436440
didDisconnect = true
437-
connected = false
441+
connected = false //nolint:ineffassign // connected is *currently* not used below, let's make update it anyway
438442
}
439443

440444
// Requeue for next health probe.
@@ -482,8 +486,7 @@ func (cc *clusterCache) getClusterAccessor(_ context.Context, cluster client.Obj
482486
cc.clusterAccessorsLock.RLock()
483487
defer cc.clusterAccessorsLock.RUnlock()
484488

485-
accessor, _ := cc.clusterAccessors[cluster]
486-
return accessor
489+
return cc.clusterAccessors[cluster]
487490
}
488491

489492
// deleteClusterAccessor deletes the clusterAccessor for the given cluster in the clusterAccessors map.
@@ -614,6 +617,7 @@ func buildClusterAccessorConfig(mgr manager.Manager, options Options, controller
614617
ControllerPodMetadata: controllerPodMetadata,
615618
Cache: &clusterAccessorCacheConfig{
616619
InitialSyncTimeout: 5 * time.Minute,
620+
SyncPeriod: options.Cache.SyncPeriod,
617621
ByObject: options.Cache.ByObject,
618622
Indexes: options.Cache.Indexes,
619623
},

exp/addons/internal/controllers/clusterresourceset_controller_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ metadata:
110110
g.Expect(env.CreateAndWait(ctx, testCluster)).To(Succeed())
111111
t.Log("Creating the remote Cluster kubeconfig")
112112
g.Expect(env.CreateKubeconfigSecret(ctx, testCluster)).To(Succeed())
113-
_, err = tracker.GetClient(ctx, client.ObjectKeyFromObject(testCluster))
113+
_, err = clusterCache.GetClient(ctx, client.ObjectKeyFromObject(testCluster))
114114
g.Expect(err).ToNot(HaveOccurred())
115115

116116
createConfigMapAndSecret(g, ns.Name, configmapName, secretName)

exp/addons/internal/controllers/suite_test.go

+14-5
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ import (
3232
"sigs.k8s.io/controller-runtime/pkg/controller"
3333

3434
"sigs.k8s.io/cluster-api/api/v1beta1/index"
35+
"sigs.k8s.io/cluster-api/controllers/clustercache"
3536
"sigs.k8s.io/cluster-api/controllers/remote"
3637
addonsv1 "sigs.k8s.io/cluster-api/exp/addons/api/v1beta1"
3738
"sigs.k8s.io/cluster-api/internal/test/envtest"
3839
)
3940

4041
var (
41-
env *envtest.Environment
42-
tracker *remote.ClusterCacheTracker
43-
ctx = ctrl.SetupSignalHandler()
42+
env *envtest.Environment
43+
clusterCache clustercache.ClusterCache
44+
ctx = ctrl.SetupSignalHandler()
4445
)
4546

4647
func TestMain(m *testing.M) {
@@ -77,14 +78,22 @@ func TestMain(m *testing.M) {
7778
panic(fmt.Sprintf("Failed to start cache for metadata only Secret watches: %v", err))
7879
}
7980

80-
tracker, err = remote.NewClusterCacheTracker(mgr, remote.ClusterCacheTrackerOptions{})
81+
clusterCache, err = clustercache.SetupWithManager(ctx, mgr, clustercache.Options{
82+
SecretClient: mgr.GetClient(),
83+
Cache: clustercache.CacheOptions{
84+
Indexes: []clustercache.CacheOptionsIndex{clustercache.NodeProviderIDIndex},
85+
},
86+
Client: clustercache.ClientOptions{
87+
UserAgent: remote.DefaultClusterAPIUserAgent("test-controller-manager"),
88+
},
89+
}, controller.Options{MaxConcurrentReconciles: 10})
8190
if err != nil {
8291
panic(fmt.Sprintf("Failed to create new cluster cache tracker: %v", err))
8392
}
8493

8594
reconciler := ClusterResourceSetReconciler{
8695
Client: mgr.GetClient(),
87-
ClusterCache: tracker,
96+
ClusterCache: clusterCache,
8897
}
8998
if err = reconciler.SetupWithManager(ctx, mgr, controller.Options{MaxConcurrentReconciles: 10}, partialSecretCache); err != nil {
9099
panic(fmt.Sprintf("Failed to set up cluster resource set reconciler: %v", err))

exp/internal/controllers/machinepool_controller_phases_test.go

+18-20
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"testing"
2222
"time"
2323

24-
"github.com/go-logr/logr"
2524
. "github.com/onsi/gomega"
2625
corev1 "k8s.io/api/core/v1"
2726
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -33,11 +32,10 @@ import (
3332
ctrl "sigs.k8s.io/controller-runtime"
3433
"sigs.k8s.io/controller-runtime/pkg/client"
3534
"sigs.k8s.io/controller-runtime/pkg/client/fake"
36-
"sigs.k8s.io/controller-runtime/pkg/log"
3735

3836
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
37+
"sigs.k8s.io/cluster-api/controllers/clustercache"
3938
"sigs.k8s.io/cluster-api/controllers/external"
40-
"sigs.k8s.io/cluster-api/controllers/remote"
4139
expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1"
4240
"sigs.k8s.io/cluster-api/internal/test/builder"
4341
"sigs.k8s.io/cluster-api/internal/util/ssa"
@@ -129,7 +127,7 @@ func TestReconcileMachinePoolPhases(t *testing.T) {
129127
fakeClient := fake.NewClientBuilder().WithObjects(defaultCluster, defaultKubeconfigSecret, machinepool, bootstrapConfig, infraConfig, builder.TestBootstrapConfigCRD, builder.TestInfrastructureMachineTemplateCRD).Build()
130128
r := &MachinePoolReconciler{
131129
Client: fakeClient,
132-
ClusterCache: remote.NewTestClusterCacheTracker(logr.New(log.NullLogSink{}), fakeClient, fakeClient, fakeClient.Scheme(), client.ObjectKey{Name: defaultCluster.Name, Namespace: defaultCluster.Namespace}),
130+
ClusterCache: clustercache.NewFakeClusterCache(fakeClient, client.ObjectKey{Name: defaultCluster.Name, Namespace: defaultCluster.Namespace}),
133131
}
134132

135133
scope := &scope{
@@ -166,7 +164,7 @@ func TestReconcileMachinePoolPhases(t *testing.T) {
166164

167165
r := &MachinePoolReconciler{
168166
Client: fakeClient,
169-
ClusterCache: remote.NewTestClusterCacheTracker(logr.New(log.NullLogSink{}), fakeClient, fakeClient, fakeClient.Scheme(), client.ObjectKey{Name: defaultCluster.Name, Namespace: defaultCluster.Namespace}),
167+
ClusterCache: clustercache.NewFakeClusterCache(fakeClient, client.ObjectKey{Name: defaultCluster.Name, Namespace: defaultCluster.Namespace}),
170168
}
171169

172170
scope := &scope{
@@ -200,7 +198,7 @@ func TestReconcileMachinePoolPhases(t *testing.T) {
200198
fakeClient := fake.NewClientBuilder().WithObjects(defaultCluster, defaultKubeconfigSecret, machinepool, bootstrapConfig, infraConfig, builder.TestBootstrapConfigCRD, builder.TestInfrastructureMachineTemplateCRD).Build()
201199
r := &MachinePoolReconciler{
202200
Client: fakeClient,
203-
ClusterCache: remote.NewTestClusterCacheTracker(logr.New(log.NullLogSink{}), fakeClient, fakeClient, fakeClient.Scheme(), client.ObjectKey{Name: defaultCluster.Name, Namespace: defaultCluster.Namespace}),
201+
ClusterCache: clustercache.NewFakeClusterCache(fakeClient, client.ObjectKey{Name: defaultCluster.Name, Namespace: defaultCluster.Namespace}),
204202
}
205203

206204
scope := &scope{
@@ -250,7 +248,7 @@ func TestReconcileMachinePoolPhases(t *testing.T) {
250248
fakeClient := fake.NewClientBuilder().WithObjects(defaultCluster, defaultKubeconfigSecret, machinepool, bootstrapConfig, infraConfig, builder.TestBootstrapConfigCRD, builder.TestInfrastructureMachineTemplateCRD).Build()
251249
r := &MachinePoolReconciler{
252250
Client: fakeClient,
253-
ClusterCache: remote.NewTestClusterCacheTracker(logr.New(log.NullLogSink{}), fakeClient, fakeClient, fakeClient.Scheme(), client.ObjectKey{Name: defaultCluster.Name, Namespace: defaultCluster.Namespace}),
251+
ClusterCache: clustercache.NewFakeClusterCache(fakeClient, client.ObjectKey{Name: defaultCluster.Name, Namespace: defaultCluster.Namespace}),
254252
}
255253

256254
scope := &scope{
@@ -312,7 +310,7 @@ func TestReconcileMachinePoolPhases(t *testing.T) {
312310
fakeClient := fake.NewClientBuilder().WithObjects(defaultCluster, defaultKubeconfigSecret, machinepool, bootstrapConfig, infraConfig, builder.TestBootstrapConfigCRD, builder.TestInfrastructureMachineTemplateCRD).Build()
313311
r := &MachinePoolReconciler{
314312
Client: fakeClient,
315-
ClusterCache: remote.NewTestClusterCacheTracker(logr.New(log.NullLogSink{}), fakeClient, fakeClient, fakeClient.Scheme(), client.ObjectKey{Name: defaultCluster.Name, Namespace: defaultCluster.Namespace}),
313+
ClusterCache: clustercache.NewFakeClusterCache(fakeClient, client.ObjectKey{Name: defaultCluster.Name, Namespace: defaultCluster.Namespace}),
316314
}
317315

318316
scope := &scope{
@@ -352,7 +350,7 @@ func TestReconcileMachinePoolPhases(t *testing.T) {
352350
fakeClient := fake.NewClientBuilder().WithObjects(defaultCluster, defaultKubeconfigSecret, machinepool, bootstrapConfig, infraConfig, builder.TestBootstrapConfigCRD, builder.TestInfrastructureMachineTemplateCRD).Build()
353351
r := &MachinePoolReconciler{
354352
Client: fakeClient,
355-
ClusterCache: remote.NewTestClusterCacheTracker(logr.New(log.NullLogSink{}), fakeClient, fakeClient, fakeClient.Scheme(), client.ObjectKey{Name: defaultCluster.Name, Namespace: defaultCluster.Namespace}),
353+
ClusterCache: clustercache.NewFakeClusterCache(fakeClient, client.ObjectKey{Name: defaultCluster.Name, Namespace: defaultCluster.Namespace}),
356354
}
357355

358356
scope := &scope{
@@ -399,7 +397,7 @@ func TestReconcileMachinePoolPhases(t *testing.T) {
399397
fakeClient := fake.NewClientBuilder().WithObjects(defaultCluster, defaultKubeconfigSecret, machinepool, bootstrapConfig, infraConfig, builder.TestBootstrapConfigCRD, builder.TestInfrastructureMachineTemplateCRD).Build()
400398
r := &MachinePoolReconciler{
401399
Client: fakeClient,
402-
ClusterCache: remote.NewTestClusterCacheTracker(logr.New(log.NullLogSink{}), fakeClient, fakeClient, fakeClient.Scheme(), client.ObjectKey{Name: defaultCluster.Name, Namespace: defaultCluster.Namespace}),
400+
ClusterCache: clustercache.NewFakeClusterCache(fakeClient, client.ObjectKey{Name: defaultCluster.Name, Namespace: defaultCluster.Namespace}),
403401
}
404402

405403
scope := &scope{
@@ -459,7 +457,7 @@ func TestReconcileMachinePoolPhases(t *testing.T) {
459457
fakeClient := fake.NewClientBuilder().WithObjects(defaultCluster, defaultKubeconfigSecret, machinepool, bootstrapConfig, infraConfig, builder.TestBootstrapConfigCRD, builder.TestInfrastructureMachineTemplateCRD).Build()
460458
r := &MachinePoolReconciler{
461459
Client: fakeClient,
462-
ClusterCache: remote.NewTestClusterCacheTracker(logr.New(log.NullLogSink{}), fakeClient, fakeClient, fakeClient.Scheme(), client.ObjectKey{Name: defaultCluster.Name, Namespace: defaultCluster.Namespace}),
460+
ClusterCache: clustercache.NewFakeClusterCache(fakeClient, client.ObjectKey{Name: defaultCluster.Name, Namespace: defaultCluster.Namespace}),
463461
}
464462

465463
scope := &scope{
@@ -525,7 +523,7 @@ func TestReconcileMachinePoolPhases(t *testing.T) {
525523
fakeClient := fake.NewClientBuilder().WithObjects(defaultCluster, defaultKubeconfigSecret, machinepool, bootstrapConfig, infraConfig, builder.TestBootstrapConfigCRD, builder.TestInfrastructureMachineTemplateCRD).Build()
526524
r := &MachinePoolReconciler{
527525
Client: fakeClient,
528-
ClusterCache: remote.NewTestClusterCacheTracker(logr.New(log.NullLogSink{}), fakeClient, fakeClient, fakeClient.Scheme(), client.ObjectKey{Name: defaultCluster.Name, Namespace: defaultCluster.Namespace}),
526+
ClusterCache: clustercache.NewFakeClusterCache(fakeClient, client.ObjectKey{Name: defaultCluster.Name, Namespace: defaultCluster.Namespace}),
529527
}
530528

531529
scope := &scope{
@@ -589,7 +587,7 @@ func TestReconcileMachinePoolPhases(t *testing.T) {
589587
fakeClient := fake.NewClientBuilder().WithObjects(defaultCluster, defaultKubeconfigSecret, machinePool, bootstrapConfig, infraConfig, builder.TestBootstrapConfigCRD, builder.TestInfrastructureMachineTemplateCRD).Build()
590588
r := &MachinePoolReconciler{
591589
Client: fakeClient,
592-
ClusterCache: remote.NewTestClusterCacheTracker(logr.New(log.NullLogSink{}), fakeClient, fakeClient, fakeClient.Scheme(), client.ObjectKey{Name: defaultCluster.Name, Namespace: defaultCluster.Namespace}),
590+
ClusterCache: clustercache.NewFakeClusterCache(fakeClient, client.ObjectKey{Name: defaultCluster.Name, Namespace: defaultCluster.Namespace}),
593591
}
594592

595593
scope := &scope{
@@ -675,7 +673,7 @@ func TestReconcileMachinePoolPhases(t *testing.T) {
675673
fakeClient := fake.NewClientBuilder().WithObjects(defaultCluster, defaultKubeconfigSecret, machinePool, bootstrapConfig, infraConfig, builder.TestBootstrapConfigCRD, builder.TestInfrastructureMachineTemplateCRD).Build()
676674
r := &MachinePoolReconciler{
677675
Client: fakeClient,
678-
ClusterCache: remote.NewTestClusterCacheTracker(logr.New(log.NullLogSink{}), fakeClient, fakeClient, fakeClient.Scheme(), client.ObjectKey{Name: defaultCluster.Name, Namespace: defaultCluster.Namespace}),
676+
ClusterCache: clustercache.NewFakeClusterCache(fakeClient, client.ObjectKey{Name: defaultCluster.Name, Namespace: defaultCluster.Namespace}),
679677
}
680678

681679
scope := &scope{
@@ -1286,7 +1284,7 @@ func TestReconcileMachinePoolInfrastructure(t *testing.T) {
12861284
fakeClient := fake.NewClientBuilder().WithObjects(tc.machinepool, infraConfig, builder.TestBootstrapConfigCRD, builder.TestInfrastructureMachineTemplateCRD).Build()
12871285
r := &MachinePoolReconciler{
12881286
Client: fakeClient,
1289-
ClusterCache: remote.NewTestClusterCacheTracker(logr.New(log.NullLogSink{}), fakeClient, fakeClient, fakeClient.Scheme(), client.ObjectKey{Name: defaultCluster.Name, Namespace: defaultCluster.Namespace}),
1287+
ClusterCache: clustercache.NewFakeClusterCache(fakeClient, client.ObjectKey{Name: defaultCluster.Name, Namespace: defaultCluster.Namespace}),
12901288
}
12911289

12921290
scope := &scope{
@@ -1789,7 +1787,7 @@ func TestReconcileMachinePoolScaleToFromZero(t *testing.T) {
17891787
fakeClient := fake.NewClientBuilder().WithObjects(testCluster, kubeconfigSecret, machinepool, bootstrapConfig, infraConfig, builder.TestBootstrapConfigCRD, builder.TestInfrastructureMachineTemplateCRD).Build()
17901788
r := &MachinePoolReconciler{
17911789
Client: fakeClient,
1792-
ClusterCache: remote.NewTestClusterCacheTracker(logr.New(log.NullLogSink{}), env.GetClient(), env.GetClient(), env.GetClient().Scheme(), client.ObjectKey{Name: testCluster.Name, Namespace: testCluster.Namespace}),
1790+
ClusterCache: clustercache.NewFakeClusterCache(env.GetClient(), client.ObjectKey{Name: testCluster.Name, Namespace: testCluster.Namespace}),
17931791
recorder: record.NewFakeRecorder(32),
17941792
}
17951793

@@ -1851,7 +1849,7 @@ func TestReconcileMachinePoolScaleToFromZero(t *testing.T) {
18511849
fakeClient := fake.NewClientBuilder().WithObjects(testCluster, kubeconfigSecret, machinepool, bootstrapConfig, infraConfig, builder.TestBootstrapConfigCRD, builder.TestInfrastructureMachineTemplateCRD).Build()
18521850
r := &MachinePoolReconciler{
18531851
Client: fakeClient,
1854-
ClusterCache: remote.NewTestClusterCacheTracker(logr.New(log.NullLogSink{}), env.GetClient(), env.GetClient(), env.GetClient().Scheme(), client.ObjectKey{Name: testCluster.Name, Namespace: testCluster.Namespace}),
1852+
ClusterCache: clustercache.NewFakeClusterCache(env.GetClient(), client.ObjectKey{Name: testCluster.Name, Namespace: testCluster.Namespace}),
18551853
recorder: record.NewFakeRecorder(32),
18561854
}
18571855

@@ -1897,7 +1895,7 @@ func TestReconcileMachinePoolScaleToFromZero(t *testing.T) {
18971895
r := &MachinePoolReconciler{
18981896
Client: fakeClient,
18991897
recorder: record.NewFakeRecorder(32),
1900-
ClusterCache: remote.NewTestClusterCacheTracker(logr.New(log.NullLogSink{}), fakeClient, fakeClient, fakeClient.Scheme(), client.ObjectKey{Name: testCluster.Name, Namespace: testCluster.Namespace}),
1898+
ClusterCache: clustercache.NewFakeClusterCache(fakeClient, client.ObjectKey{Name: testCluster.Name, Namespace: testCluster.Namespace}),
19011899
}
19021900

19031901
scope := &scope{
@@ -1938,7 +1936,7 @@ func TestReconcileMachinePoolScaleToFromZero(t *testing.T) {
19381936
r := &MachinePoolReconciler{
19391937
Client: fakeClient,
19401938
recorder: record.NewFakeRecorder(32),
1941-
ClusterCache: remote.NewTestClusterCacheTracker(logr.New(log.NullLogSink{}), fakeClient, fakeClient, fakeClient.Scheme(), client.ObjectKey{Name: testCluster.Name, Namespace: testCluster.Namespace}),
1939+
ClusterCache: clustercache.NewFakeClusterCache(fakeClient, client.ObjectKey{Name: testCluster.Name, Namespace: testCluster.Namespace}),
19421940
}
19431941

19441942
scope := &scope{
@@ -2000,7 +1998,7 @@ func TestReconcileMachinePoolScaleToFromZero(t *testing.T) {
20001998
fakeClient := fake.NewClientBuilder().WithObjects(testCluster, kubeconfigSecret, machinepool, bootstrapConfig, infraConfig, builder.TestBootstrapConfigCRD, builder.TestInfrastructureMachineTemplateCRD).Build()
20011999
r := &MachinePoolReconciler{
20022000
Client: fakeClient,
2003-
ClusterCache: remote.NewTestClusterCacheTracker(logr.New(log.NullLogSink{}), env.GetClient(), env.GetClient(), env.GetClient().Scheme(), client.ObjectKey{Name: testCluster.Name, Namespace: testCluster.Namespace}),
2001+
ClusterCache: clustercache.NewFakeClusterCache(env.GetClient(), client.ObjectKey{Name: testCluster.Name, Namespace: testCluster.Namespace}),
20042002
recorder: record.NewFakeRecorder(32),
20052003
}
20062004

exp/internal/controllers/machinepool_controller_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import (
3838
"sigs.k8s.io/controller-runtime/pkg/reconcile"
3939

4040
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
41-
"sigs.k8s.io/cluster-api/controllers/remote"
41+
"sigs.k8s.io/cluster-api/controllers/clustercache"
4242
expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1"
4343
"sigs.k8s.io/cluster-api/internal/test/builder"
4444
"sigs.k8s.io/cluster-api/util"
@@ -555,7 +555,7 @@ func TestReconcileMachinePoolRequest(t *testing.T) {
555555
r := &MachinePoolReconciler{
556556
Client: clientFake,
557557
APIReader: clientFake,
558-
ClusterCache: remote.NewTestClusterCacheTracker(ctrl.LoggerFrom(ctx), clientFake, trackerClientFake, clientFake.Scheme(), client.ObjectKey{Name: testCluster.Name, Namespace: testCluster.Namespace}),
558+
ClusterCache: clustercache.NewFakeClusterCache(trackerClientFake, client.ObjectKey{Name: testCluster.Name, Namespace: testCluster.Namespace}),
559559
}
560560

561561
result, err := r.Reconcile(ctx, reconcile.Request{NamespacedName: util.ObjectKey(&tc.machinePool)})
@@ -825,7 +825,7 @@ func TestRemoveMachinePoolFinalizerAfterDeleteReconcile(t *testing.T) {
825825
clientFake := fake.NewClientBuilder().WithObjects(testCluster, m).WithStatusSubresource(&expv1.MachinePool{}).Build()
826826
mr := &MachinePoolReconciler{
827827
Client: clientFake,
828-
ClusterCache: remote.NewTestClusterCacheTracker(ctrl.LoggerFrom(ctx), clientFake, clientFake, clientFake.Scheme(), client.ObjectKey{Name: testCluster.Name, Namespace: testCluster.Namespace}),
828+
ClusterCache: clustercache.NewFakeClusterCache(clientFake, client.ObjectKey{Name: testCluster.Name, Namespace: testCluster.Namespace}),
829829
}
830830
_, err := mr.Reconcile(ctx, reconcile.Request{NamespacedName: key})
831831
g.Expect(err).ToNot(HaveOccurred())
@@ -1102,7 +1102,7 @@ func TestMachinePoolConditions(t *testing.T) {
11021102
r := &MachinePoolReconciler{
11031103
Client: clientFake,
11041104
APIReader: clientFake,
1105-
ClusterCache: remote.NewTestClusterCacheTracker(ctrl.LoggerFrom(ctx), clientFake, clientFake, clientFake.Scheme(), client.ObjectKey{Name: testCluster.Name, Namespace: testCluster.Namespace}),
1105+
ClusterCache: clustercache.NewFakeClusterCache(clientFake, client.ObjectKey{Name: testCluster.Name, Namespace: testCluster.Namespace}),
11061106
}
11071107

11081108
_, err := r.Reconcile(ctx, reconcile.Request{NamespacedName: util.ObjectKey(machinePool)})

0 commit comments

Comments
 (0)