Skip to content

Commit

Permalink
chore: remove v1alpha5 hash and disruption controllers (kubernetes-si…
Browse files Browse the repository at this point in the history
  • Loading branch information
njtran authored Nov 1, 2023
1 parent a08781f commit c3941b2
Show file tree
Hide file tree
Showing 15 changed files with 144 additions and 1,174 deletions.
2 changes: 0 additions & 2 deletions pkg/controllers/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func NewControllers(
p, evictionQueue,
disruption.NewController(clock, kubeClient, p, cloudProvider, recorder, cluster),
provisioning.NewController(kubeClient, p, recorder),
nodepoolhash.NewProvisionerController(kubeClient),
nodepoolhash.NewNodePoolController(kubeClient),
informer.NewDaemonSetController(kubeClient, cluster),
informer.NewNodeController(kubeClient, cluster),
Expand All @@ -78,7 +77,6 @@ func NewControllers(
nodeclaimgarbagecollection.NewController(clock, kubeClient, cloudProvider),
nodeclaimtermination.NewMachineController(kubeClient, cloudProvider),
nodeclaimtermination.NewNodeClaimController(kubeClient, cloudProvider),
nodeclaimdisruption.NewMachineController(clock, kubeClient, cluster, cloudProvider),
nodeclaimdisruption.NewNodeClaimController(clock, kubeClient, cluster, cloudProvider),
leasegarbagecollection.NewController(kubeClient),
}
Expand Down
64 changes: 0 additions & 64 deletions pkg/controllers/nodeclaim/disruption/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ import (
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

"github.com/aws/karpenter-core/pkg/apis/v1alpha5"
"github.com/aws/karpenter-core/pkg/apis/v1beta1"
"github.com/aws/karpenter-core/pkg/cloudprovider"
"github.com/aws/karpenter-core/pkg/controllers/state"
corecontroller "github.com/aws/karpenter-core/pkg/operator/controller"
machineutil "github.com/aws/karpenter-core/pkg/utils/machine"
nodeclaimutil "github.com/aws/karpenter-core/pkg/utils/nodeclaim"
"github.com/aws/karpenter-core/pkg/utils/result"
)
Expand Down Expand Up @@ -163,65 +161,3 @@ func (c *NodeClaimController) Builder(_ context.Context, m manager.Manager) core
),
)
}

var _ corecontroller.TypedController[*v1alpha5.Machine] = (*MachineController)(nil)

type MachineController struct {
*Controller
}

func NewMachineController(clk clock.Clock, kubeClient client.Client, cluster *state.Cluster, cloudProvider cloudprovider.CloudProvider) corecontroller.Controller {
return corecontroller.Typed[*v1alpha5.Machine](kubeClient, &MachineController{
Controller: NewController(clk, kubeClient, cluster, cloudProvider),
})
}

func (c *MachineController) Name() string {
return "machine.disruption"
}

func (c *MachineController) Reconcile(ctx context.Context, machine *v1alpha5.Machine) (reconcile.Result, error) {
return c.Controller.Reconcile(ctx, nodeclaimutil.New(machine))
}

func (c *Controller) Builder(_ context.Context, m manager.Manager) corecontroller.Builder {
return corecontroller.Adapt(controllerruntime.
NewControllerManagedBy(m).
For(&v1alpha5.Machine{}, builder.WithPredicates(
predicate.Or(
predicate.GenerationChangedPredicate{},
predicate.Funcs{
UpdateFunc: func(e event.UpdateEvent) bool {
oldMachine := e.ObjectOld.(*v1alpha5.Machine)
newMachine := e.ObjectNew.(*v1alpha5.Machine)

// One of the status conditions that affects disruption has changed
// which means that we should re-consider this for disruption
for _, cond := range v1alpha5.LivingConditions {
if !equality.Semantic.DeepEqual(
oldMachine.StatusConditions().GetCondition(cond),
newMachine.StatusConditions().GetCondition(cond),
) {
return true
}
}
return false
},
},
),
)).
WithOptions(controller.Options{MaxConcurrentReconciles: 10}).
Watches(
&v1alpha5.Provisioner{},
machineutil.ProvisionerEventHandler(c.kubeClient),
).
Watches(
&v1.Node{},
machineutil.NodeEventHandler(c.kubeClient),
).
Watches(
&v1.Pod{},
machineutil.PodEventHandler(c.kubeClient),
),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
. "github.com/onsi/gomega"
)

var _ = Describe("NodeClaim/Drift", func() {
var _ = Describe("Drift", func() {
var nodePool *v1beta1.NodePool
var nodeClaim *v1beta1.NodeClaim
var node *v1.Node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
. "github.com/aws/karpenter-core/pkg/test/expectations"
)

var _ = Describe("NodeClaim/Emptiness", func() {
var _ = Describe("Emptiness", func() {
var nodePool *v1beta1.NodePool
var nodeClaim *v1beta1.NodeClaim
var node *v1.Node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
. "github.com/aws/karpenter-core/pkg/test/expectations"
)

var _ = Describe("NodeClaim/Expiration", func() {
var _ = Describe("Expiration", func() {
var nodePool *v1beta1.NodePool
var nodeClaim *v1beta1.NodeClaim
var node *v1.Node
Expand Down
Loading

0 comments on commit c3941b2

Please sign in to comment.