Skip to content

Commit

Permalink
chore: Remove dangling dependency on state.Cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
ellistarn committed Jun 28, 2024
1 parent 0011ad2 commit f11074c
Show file tree
Hide file tree
Showing 13 changed files with 1,538 additions and 1,615 deletions.
1,450 changes: 709 additions & 741 deletions pkg/apis/crds/karpenter.sh_nodeclaims.yaml

Large diffs are not rendered by default.

1,680 changes: 818 additions & 862 deletions pkg/apis/crds/karpenter.sh_nodepools.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/controllers/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func NewControllers(
cloudProvider cloudprovider.CloudProvider,
) []controller.Controller {

cluster := state.NewCluster(clock, kubeClient, cloudProvider)
cluster := state.NewCluster(clock, kubeClient)
p := provisioning.NewProvisioner(kubeClient, recorder, cloudProvider, cluster)
evictionQueue := terminator.NewQueue(kubeClient, recorder)
disruptionQueue := orchestration.NewQueue(kubeClient, recorder, cluster, clock, p)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/disruption/orchestration/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ var _ = BeforeSuite(func() {
ctx = options.ToContext(ctx, test.Options())
fakeClock = clock.NewFakeClock(time.Now())
cloudProvider = fake.NewCloudProvider()
cluster = state.NewCluster(fakeClock, env.Client, cloudProvider)
cluster = state.NewCluster(fakeClock, env.Client)
nodeStateController = informer.NewNodeController(env.Client, cluster)
nodeClaimStateController = informer.NewNodeClaimController(env.Client, cluster)
recorder = test.NewEventRecorder()
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/disruption/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ var _ = BeforeSuite(func() {
ctx = options.ToContext(ctx, test.Options())
cloudProvider = fake.NewCloudProvider()
fakeClock = clock.NewFakeClock(time.Now())
cluster = state.NewCluster(fakeClock, env.Client, cloudProvider)
cluster = state.NewCluster(fakeClock, env.Client)
nodeStateController = informer.NewNodeController(env.Client, cluster)
nodeClaimStateController = informer.NewNodeClaimController(env.Client, cluster)
recorder = test.NewEventRecorder()
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/metrics/node/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var _ = BeforeSuite(func() {
cloudProvider = fake.NewCloudProvider()
cloudProvider.InstanceTypes = fake.InstanceTypesAssorted()
fakeClock = clock.NewFakeClock(time.Now())
cluster = state.NewCluster(fakeClock, env.Client, cloudProvider)
cluster = state.NewCluster(fakeClock, env.Client)
nodeController = informer.NewNodeController(env.Client, cluster)
metricsStateController = node.NewController(cluster)
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/nodeclaim/disruption/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var _ = BeforeSuite(func() {
}))
ctx = options.ToContext(ctx, test.Options())
cp = fake.NewCloudProvider()
cluster = state.NewCluster(fakeClock, env.Client, cp)
cluster = state.NewCluster(fakeClock, env.Client)
nodeClaimDisruptionController = nodeclaimdisruption.NewController(fakeClock, env.Client, cluster, cp)
})

Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/nodepool/counter/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ var _ = BeforeSuite(func() {
cloudProvider = fake.NewCloudProvider()
env = test.NewEnvironment(test.WithCRDs(apis.CRDs...))
fakeClock = clock.NewFakeClock(time.Now())
cluster = state.NewCluster(fakeClock, env.Client, cloudProvider)
cluster = state.NewCluster(fakeClock, env.Client)
nodeClaimController = informer.NewNodeClaimController(env.Client, cluster)
nodeController = informer.NewNodeController(env.Client, cluster)
nodePoolInformerController = informer.NewNodePoolController(env.Client, cluster)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func benchmarkScheduler(b *testing.B, instanceCount, podCount int) {

client := fakecr.NewFakeClient()
pods := makeDiversePods(podCount)
cluster = state.NewCluster(&clock.RealClock{}, client, cloudProvider)
cluster = state.NewCluster(&clock.RealClock{}, client)
domains := map[string]sets.Set[string]{}
topology, err := scheduling.NewTopology(ctx, client, cluster, domains, pods)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/provisioning/scheduling/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ var _ = BeforeSuite(func() {
// set these on the cloud provider, so we can manipulate them if needed
cloudProvider.InstanceTypes = instanceTypes
fakeClock = clock.NewFakeClock(time.Now())
cluster = state.NewCluster(fakeClock, env.Client, cloudProvider)
cluster = state.NewCluster(fakeClock, env.Client)
nodeStateController = informer.NewNodeController(env.Client, cluster)
nodeClaimStateController = informer.NewNodeClaimController(env.Client, cluster)
podStateController = informer.NewPodController(env.Client, cluster)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/provisioning/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var _ = BeforeSuite(func() {
ctx = options.ToContext(ctx, test.Options())
cloudProvider = fake.NewCloudProvider()
fakeClock = clock.NewFakeClock(time.Now())
cluster = state.NewCluster(fakeClock, env.Client, cloudProvider)
cluster = state.NewCluster(fakeClock, env.Client)
nodeController = informer.NewNodeController(env.Client, cluster)
prov = provisioning.NewProvisioner(env.Client, events.NewRecorder(&record.FakeRecorder{}), cloudProvider, cluster)
daemonsetController = informer.NewDaemonSetController(env.Client, cluster)
Expand Down
3 changes: 1 addition & 2 deletions pkg/controllers/state/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ type Cluster struct {
antiAffinityPods sync.Map // pod namespaced name -> *v1.Pod of pods that have required anti affinities
}

func NewCluster(clk clock.Clock, client client.Client, cp cloudprovider.CloudProvider) *Cluster {
func NewCluster(clk clock.Clock, client client.Client) *Cluster {
return &Cluster{
clock: clk,
kubeClient: client,
cloudProvider: cp,
nodes: map[string]*StateNode{},
bindings: map[types.NamespacedName]string{},
daemonSetPods: sync.Map{},
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/state/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var _ = BeforeSuite(func() {
ctx = options.ToContext(ctx, test.Options())
cloudProvider = fake.NewCloudProvider()
fakeClock = clock.NewFakeClock(time.Now())
cluster = state.NewCluster(fakeClock, env.Client, cloudProvider)
cluster = state.NewCluster(fakeClock, env.Client)
nodeClaimController = informer.NewNodeClaimController(env.Client, cluster)
nodeController = informer.NewNodeController(env.Client, cluster)
podController = informer.NewPodController(env.Client, cluster)
Expand Down

0 comments on commit f11074c

Please sign in to comment.