From 4ca02abead33dd84cd9794d974ef762b8800b5f3 Mon Sep 17 00:00:00 2001 From: Stefan Bueringer Date: Sat, 19 Oct 2024 15:31:37 +0200 Subject: [PATCH] Deprecate ClusterCacheTracker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stefan Büringer buringerst@vmware.com --- controllers/remote/cluster_cache_reconciler.go | 2 ++ controllers/remote/cluster_cache_tracker.go | 6 ++++++ controllers/remote/cluster_cache_tracker_fake.go | 2 ++ controllers/remote/index.go | 4 ++++ controlplane/kubeadm/internal/controllers/controller.go | 3 --- .../book/src/developer/providers/migrations/v1.8-to-v1.9.md | 6 ++++++ 6 files changed, 20 insertions(+), 3 deletions(-) diff --git a/controllers/remote/cluster_cache_reconciler.go b/controllers/remote/cluster_cache_reconciler.go index caace4257af5..bf7edbe7ab36 100644 --- a/controllers/remote/cluster_cache_reconciler.go +++ b/controllers/remote/cluster_cache_reconciler.go @@ -32,6 +32,8 @@ import ( // ClusterCacheReconciler is responsible for stopping remote cluster caches when // the cluster for the remote cache is being deleted. +// +// Deprecated: This will be removed in Cluster API v1.10, use clustercache.ClusterCache instead. type ClusterCacheReconciler struct { Client client.Client Tracker *ClusterCacheTracker diff --git a/controllers/remote/cluster_cache_tracker.go b/controllers/remote/cluster_cache_tracker.go index 2ca2d9d67b3b..a260e9ed0650 100644 --- a/controllers/remote/cluster_cache_tracker.go +++ b/controllers/remote/cluster_cache_tracker.go @@ -66,6 +66,8 @@ const ( var ErrClusterLocked = errors.New("cluster is locked already") // ClusterCacheTracker manages client caches for workload clusters. +// +// Deprecated: This will be removed in Cluster API v1.10, use clustercache.ClusterCache instead. type ClusterCacheTracker struct { log logr.Logger @@ -108,6 +110,8 @@ type ClusterCacheTracker struct { // ClusterCacheTrackerOptions defines options to configure // a ClusterCacheTracker. +// +// Deprecated: This will be removed in Cluster API v1.10, use clustercache.ClusterCache instead. type ClusterCacheTrackerOptions struct { // SecretCachingClient is a client which caches secrets. // If set it will be used to read the kubeconfig secret. @@ -172,6 +176,8 @@ func setDefaultOptions(opts *ClusterCacheTrackerOptions) { } // NewClusterCacheTracker creates a new ClusterCacheTracker. +// +// Deprecated: This will be removed in Cluster API v1.10, use clustercache.SetupWithManager instead. func NewClusterCacheTracker(manager ctrl.Manager, options ClusterCacheTrackerOptions) (*ClusterCacheTracker, error) { setDefaultOptions(&options) diff --git a/controllers/remote/cluster_cache_tracker_fake.go b/controllers/remote/cluster_cache_tracker_fake.go index 6062b967a637..9aa7a749161f 100644 --- a/controllers/remote/cluster_cache_tracker_fake.go +++ b/controllers/remote/cluster_cache_tracker_fake.go @@ -24,6 +24,8 @@ import ( ) // NewTestClusterCacheTracker creates a new fake ClusterCacheTracker that can be used by unit tests with fake client. +// +// Deprecated: This will be removed in Cluster API v1.10, use clustercache.NewTestClusterCacheTracker instead. func NewTestClusterCacheTracker(log logr.Logger, cl client.Client, remoteClient client.Client, scheme *runtime.Scheme, objKey client.ObjectKey, watchObjects ...string) *ClusterCacheTracker { testCacheTracker := &ClusterCacheTracker{ log: log, diff --git a/controllers/remote/index.go b/controllers/remote/index.go index 16a7f5810240..28733bb478a2 100644 --- a/controllers/remote/index.go +++ b/controllers/remote/index.go @@ -24,6 +24,8 @@ import ( ) // Index is a helper to model the info passed to cache.IndexField. +// +// Deprecated: This will be removed in Cluster API v1.10, use clustercache.CacheOptionsIndex instead. type Index struct { Object client.Object Field string @@ -31,6 +33,8 @@ type Index struct { } // NodeProviderIDIndex is used to index Nodes by ProviderID. +// +// Deprecated: This will be removed in Cluster API v1.10, use clustercache.NodeProviderIDIndex instead. var NodeProviderIDIndex = Index{ Object: &corev1.Node{}, Field: index.NodeProviderIDField, diff --git a/controlplane/kubeadm/internal/controllers/controller.go b/controlplane/kubeadm/internal/controllers/controller.go index b8bb9af3b9e4..c1712bb99378 100644 --- a/controlplane/kubeadm/internal/controllers/controller.go +++ b/controlplane/kubeadm/internal/controllers/controller.go @@ -121,9 +121,6 @@ func (r *KubeadmControlPlaneReconciler) SetupWithManager(ctx context.Context, mg r.ssaCache = ssa.NewCache() if r.managementCluster == nil { - if r.ClusterCache == nil { - return errors.New("cluster cache tracker is nil, cannot create the internal management cluster resource") - } r.managementCluster = &internal.Management{ Client: r.Client, SecretCachingClient: r.SecretCachingClient, diff --git a/docs/book/src/developer/providers/migrations/v1.8-to-v1.9.md b/docs/book/src/developer/providers/migrations/v1.8-to-v1.9.md index db67749aa0b3..81e13b91167f 100644 --- a/docs/book/src/developer/providers/migrations/v1.8-to-v1.9.md +++ b/docs/book/src/developer/providers/migrations/v1.8-to-v1.9.md @@ -29,3 +29,9 @@ maintainers of providers and consumers of our Go API. ### Suggested changes for providers - The Errors package was created when capi provider implementation was running as machineActuators that needed to vendor core capi to function. There is no usage recommendations today and its value is questionable since we moved to CRDs that inter-operate mostly via conditions. Instead we plan to drop the dedicated semantic for terminal failure and keep improving Machine lifecycle signal through conditions. Therefore the Errors package [has been deprecated in v1.8](https://github.com/kubernetes-sigs/cluster-api/issues/10784). It's recommended to remove any usage of the currently exported variables. +- The `ClusterCacheTracker` component has been deprecated, please use the new `ClusterCache` instead. For more context and examples for + how to use it, see [PR: Introduce new ClusterCache](https://github.com/kubernetes-sigs/cluster-api/pull/11247) and the corresponding + [issue](https://github.com/kubernetes-sigs/cluster-api/issues/11272). Some notes: + - The `DisabledFor` option (previously `ClientUncachedObjects`) is not defaulted to `&corev1.ConfigMap` & `&corev1.Secret` anymore, + thus it's now necessary to explicitly set `DisabledFor` to avoid caching ConfigMaps and Secrets. + - `SecretClient` and `UserAgent` are now mandatory options, please take a look at the corresponding godoc.