Skip to content

Commit

Permalink
feat: add event for prefiltered instance types (#1891)
Browse files Browse the repository at this point in the history
  • Loading branch information
njtran authored Dec 20, 2024
1 parent b3fa6eb commit 1db5097
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions pkg/controllers/provisioning/scheduling/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ func NominatePodEvent(pod *corev1.Pod, node *corev1.Node, nodeClaim *v1.NodeClai
}
}

func NoCompatibleInstanceTypes(np *v1.NodePool) events.Event {
return events.Event{
InvolvedObject: np,
Type: corev1.EventTypeWarning,
Reason: "NoCompatibleInstanceTypes",
Message: "NodePool requirements filtered out all compatible available instance types",
DedupeValues: []string{string(np.UID)},
DedupeTimeout: 1 * time.Minute,
}
}

func PodFailedToScheduleEvent(pod *corev1.Pod, err error) events.Event {
return events.Event{
InvolvedObject: pod,
Expand Down
1 change: 1 addition & 0 deletions pkg/controllers/provisioning/scheduling/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func NewScheduler(ctx context.Context, kubeClient client.Client, nodePools []*v1
nct := NewNodeClaimTemplate(np)
nct.InstanceTypeOptions = filterInstanceTypesByRequirements(instanceTypes[np.Name], nct.Requirements, corev1.ResourceList{}).remaining
if len(nct.InstanceTypeOptions) == 0 {
recorder.Publish(NoCompatibleInstanceTypes(np))
log.FromContext(ctx).WithValues("NodePool", klog.KRef("", np.Name)).Info("skipping, nodepool requirements filtered out all instance types")
return nil, false
}
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 @@ -1480,7 +1480,7 @@ var _ = Describe("Consolidated State", func() {
fakeClock.Step(time.Minute)
Expect(cluster.ConsolidationState()).To(Equal(state))

fakeClock.Step(time.Minute * 3)
fakeClock.Step(time.Minute * 2)
Expect(cluster.ConsolidationState()).To(Equal(state))

fakeClock.Step(time.Minute * 2)
Expand Down

0 comments on commit 1db5097

Please sign in to comment.