Skip to content

Commit

Permalink
Merge pull request #8855 from killianmuldoon/pr-remove-default-index
Browse files Browse the repository at this point in the history
🌱 Deprecate DefaultIndex usage and remove where not needed
  • Loading branch information
k8s-ci-robot committed Jun 14, 2023
2 parents 677a182 + 2f8bc8d commit 7b64459
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 16 deletions.
1 change: 0 additions & 1 deletion bootstrap/kubeadm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) {
remote.ClusterCacheTrackerOptions{
ControllerName: controllerName,
Log: &log,
Indexes: remote.DefaultIndexes,
},
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion controllers/remote/cluster_cache_healthcheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestClusterCacheHealthCheck(t *testing.T) {
log := klogr.New()
cct, err = NewClusterCacheTracker(mgr, ClusterCacheTrackerOptions{
Log: &log,
Indexes: DefaultIndexes,
Indexes: []Index{NodeProviderIDIndex},
})
g.Expect(err).NotTo(HaveOccurred())

Expand Down
2 changes: 1 addition & 1 deletion controllers/remote/cluster_cache_tracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func TestClusterCacheTracker(t *testing.T) {

t.Log("Setting up a ClusterCacheTracker")
cct, err = NewClusterCacheTracker(mgr, ClusterCacheTrackerOptions{
Indexes: DefaultIndexes,
Indexes: []Index{NodeProviderIDIndex},
})
g.Expect(err).NotTo(HaveOccurred())

Expand Down
8 changes: 6 additions & 2 deletions controllers/remote/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ type Index struct {
ExtractValue client.IndexerFunc
}

var nodeProviderIDIndex = Index{
// NodeProviderIDIndex is used to index Nodes by ProviderID.
var NodeProviderIDIndex = Index{
Object: &corev1.Node{},
Field: index.NodeProviderIDField,
ExtractValue: index.NodeByProviderID,
}

// DefaultIndexes is the default list of indexes on a ClusterCacheTracker.
var DefaultIndexes = []Index{nodeProviderIDIndex}
//
// Deprecated: This variable is deprecated and will be removed in a future release of Cluster API.
// Instead please use `[]Index{NodeProviderIDIndex}`.
var DefaultIndexes = []Index{NodeProviderIDIndex}
3 changes: 1 addition & 2 deletions controlplane/kubeadm/internal/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ func TestGetWorkloadCluster(t *testing.T) {
tracker, err := remote.NewClusterCacheTracker(
env.Manager,
remote.ClusterCacheTrackerOptions{
Log: &log.Log,
Indexes: remote.DefaultIndexes,
Log: &log.Log,
},
)
g.Expect(err).ToNot(HaveOccurred())
Expand Down
1 change: 0 additions & 1 deletion controlplane/kubeadm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) {
tracker, err := remote.NewClusterCacheTracker(mgr, remote.ClusterCacheTrackerOptions{
ControllerName: controllerName,
Log: &log,
Indexes: remote.DefaultIndexes,
ClientUncachedObjects: []client.Object{
&corev1.ConfigMap{},
&corev1.Secret{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ maintainers of providers and consumers of our Go API.
### Deprecation

- API version`v1alpha4` is deprecated and CAPI will stop serving this version in v1.6.
- `sigs.k8s.io/cluster-api/controllers/remote.DefaultIndexex` has been deprecated and will be removed in a future release. Please use `sigs.k8s.io/cluster-api/controllers/external.NodeProviderIDIndex` instead. This index should not be used as a default index and should only be used if a controller is using `index.NodeProviderIDField`.

### Removals

Expand Down
2 changes: 1 addition & 1 deletion internal/controllers/cluster/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestMain(m *testing.M) {
mgr,
remote.ClusterCacheTrackerOptions{
Log: &log,
Indexes: remote.DefaultIndexes,
Indexes: []remote.Index{remote.NodeProviderIDIndex},
},
)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func TestGetNode(t *testing.T) {

tracker, err := remote.NewClusterCacheTracker(
env.Manager, remote.ClusterCacheTrackerOptions{
Indexes: remote.DefaultIndexes,
Indexes: []remote.Index{remote.NodeProviderIDIndex},
},
)
g.Expect(err).ToNot(HaveOccurred())
Expand Down
2 changes: 1 addition & 1 deletion internal/controllers/machine/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestMain(m *testing.M) {
mgr,
remote.ClusterCacheTrackerOptions{
Log: &log,
Indexes: remote.DefaultIndexes,
Indexes: []remote.Index{remote.NodeProviderIDIndex},
},
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/controllers/machinedeployment/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestMain(m *testing.M) {
mgr,
remote.ClusterCacheTrackerOptions{
Log: &log,
Indexes: remote.DefaultIndexes,
Indexes: []remote.Index{remote.NodeProviderIDIndex},
},
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/controllers/machinehealthcheck/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestMain(m *testing.M) {
mgr,
remote.ClusterCacheTrackerOptions{
Log: &log,
Indexes: remote.DefaultIndexes,
Indexes: []remote.Index{remote.NodeProviderIDIndex},
},
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/controllers/machineset/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestMain(m *testing.M) {
mgr,
remote.ClusterCacheTrackerOptions{
Log: &log,
Indexes: remote.DefaultIndexes,
Indexes: []remote.Index{remote.NodeProviderIDIndex},
},
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) {
remote.ClusterCacheTrackerOptions{
ControllerName: controllerName,
Log: &log,
Indexes: remote.DefaultIndexes,
Indexes: []remote.Index{remote.NodeProviderIDIndex},
},
)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion test/infrastructure/docker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) {
remote.ClusterCacheTrackerOptions{
ControllerName: controllerName,
Log: &log,
Indexes: remote.DefaultIndexes,
},
)
if err != nil {
Expand Down

0 comments on commit 7b64459

Please sign in to comment.