Skip to content

Commit

Permalink
feat: add event for prefiltered instance types
Browse files Browse the repository at this point in the history
  • Loading branch information
njtran committed Dec 19, 2024
1 parent 79fe772 commit cde376b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
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: fmt.Sprintf("NodePool requirements filtered out all compatible instance types"),

Check failure on line 57 in pkg/controllers/provisioning/scheduling/events.go

View workflow job for this annotation

GitHub Actions / presubmit (1.25.x)

S1039: unnecessary use of fmt.Sprintf (gosimple)

Check failure on line 57 in pkg/controllers/provisioning/scheduling/events.go

View workflow job for this annotation

GitHub Actions / presubmit (1.26.x)

S1039: unnecessary use of fmt.Sprintf (gosimple)

Check failure on line 57 in pkg/controllers/provisioning/scheduling/events.go

View workflow job for this annotation

GitHub Actions / presubmit (1.27.x)

S1039: unnecessary use of fmt.Sprintf (gosimple)

Check failure on line 57 in pkg/controllers/provisioning/scheduling/events.go

View workflow job for this annotation

GitHub Actions / presubmit (1.28.x)

S1039: unnecessary use of fmt.Sprintf (gosimple)

Check failure on line 57 in pkg/controllers/provisioning/scheduling/events.go

View workflow job for this annotation

GitHub Actions / presubmit (1.29.x)

S1039: unnecessary use of fmt.Sprintf (gosimple)

Check failure on line 57 in pkg/controllers/provisioning/scheduling/events.go

View workflow job for this annotation

GitHub Actions / presubmit (1.30.x)

S1039: unnecessary use of fmt.Sprintf (gosimple)

Check failure on line 57 in pkg/controllers/provisioning/scheduling/events.go

View workflow job for this annotation

GitHub Actions / presubmit (1.31.x)

S1039: unnecessary use of fmt.Sprintf (gosimple)
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

0 comments on commit cde376b

Please sign in to comment.