Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
towca committed Sep 24, 2024
1 parent 48be6fd commit 76c59df
Show file tree
Hide file tree
Showing 34 changed files with 3,782 additions and 2,381 deletions.
2 changes: 1 addition & 1 deletion cluster-autoscaler/core/autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func initializeDefaultOptions(opts *AutoscalerOptions, informerFactory informers
opts.DrainabilityRules = rules.Default(opts.DeleteOptions)
}
if opts.DraProvider == nil {
opts.DraProvider = dynamicresources.NewProvider(informerFactory)
opts.DraProvider = dynamicresources.NewProviderFromInformers(informerFactory)
}

return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ func (p *filterOutSchedulablePodListProcessor) filterOutSchedulableByPacking(uns
return corev1helpers.PodPriority(unschedulableCandidates[i].Pod) > corev1helpers.PodPriority(unschedulableCandidates[j].Pod)
})

// TODO(DRA): Stop casting to naked Pods after ScaleUp works on PodResourceInfos.
statuses, overflowingControllerCount, err := p.schedulingSimulator.TrySchedulePods(clusterSnapshot, clustersnapshot.ToPods(unschedulableCandidates), p.nodeFilter, false)
statuses, overflowingControllerCount, err := p.schedulingSimulator.TrySchedulePods(clusterSnapshot, unschedulableCandidates, p.nodeFilter, false)
if err != nil {
return nil, err
}
klog.Warningf("%s", statuses)

scheduledPods := make(map[types.UID]bool)
for _, status := range statuses {
Expand Down
7 changes: 6 additions & 1 deletion cluster-autoscaler/core/scaledown/planner/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,12 @@ func (p *Planner) injectPods(pods []*apiv1.Pod) error {
pods = pod_util.ClearPodNodeNames(pods)
// Note: We're using ScheduleAnywhere, but the pods won't schedule back
// on the drained nodes due to taints.
statuses, _, err := p.actuationInjector.TrySchedulePods(p.context.ClusterSnapshot, pods, scheduling.ScheduleAnywhere, true)
// TODO(DRA): Figure out.
var podRes []*clustersnapshot.PodResourceInfo
for _, pod := range pods {
podRes = append(podRes, &clustersnapshot.PodResourceInfo{Pod: pod})
}
statuses, _, err := p.actuationInjector.TrySchedulePods(p.context.ClusterSnapshot, podRes, scheduling.ScheduleAnywhere, true)
if err != nil {
return fmt.Errorf("cannot scale down, an unexpected error occurred: %v", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ func (o *ScaleUpOrchestrator) SchedulablePodGroups(
var schedulablePodGroups []estimator.PodEquivalenceGroup
for _, eg := range podEquivalenceGroups {
samplePod := eg.Pods[0]
if err := o.autoscalingContext.PredicateChecker.CheckPredicates(o.autoscalingContext.ClusterSnapshot, samplePod.Pod, nodeInfo.Node().Name); err == nil {
if err, _ := o.autoscalingContext.PredicateChecker.CheckPredicates(o.autoscalingContext.ClusterSnapshot, samplePod, nodeInfo.Node().Name); err == nil {
// Add pods to option.
schedulablePodGroups = append(schedulablePodGroups, estimator.PodEquivalenceGroup{
Pods: eg.Pods,
Expand Down
3 changes: 3 additions & 0 deletions cluster-autoscaler/core/static_autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ func (a *StaticAutoscaler) cleanUpIfRequired() {
func (a *StaticAutoscaler) initializeClusterSnapshot(nodes []*apiv1.Node, scheduledPods []*apiv1.Pod) caerrors.AutoscalerError {
a.ClusterSnapshot.Clear()

a.ClusterSnapshot.SetGlobalResourceSlices(a.ClusterSnapshot.DraObjectsSource.NonNodeLocalResourceSlices)
a.ClusterSnapshot.SetAllResourceClaims(a.ClusterSnapshot.DraObjectsSource.AllResourceClaims())
a.ClusterSnapshot.SetAllDeviceClasses(a.ClusterSnapshot.DraObjectsSource.DeviceClasses)
knownNodes := make(map[string]bool)
for _, node := range nodes {
if err := a.ClusterSnapshot.AddNode(clustersnapshot.NewNodeResourceInfo(node, a.ClusterSnapshot.DraObjectsSource)); err != nil {
Expand Down
Loading

0 comments on commit 76c59df

Please sign in to comment.