Skip to content

Commit

Permalink
Merge pull request #5597 from kisieland/scale-up-changes-v2
Browse files Browse the repository at this point in the history
Put ScaleUp logic behind an interface
  • Loading branch information
k8s-ci-robot authored Mar 21, 2023
2 parents b31b006 + 5b6c50e commit 241643d
Show file tree
Hide file tree
Showing 13 changed files with 1,066 additions and 834 deletions.
5 changes: 4 additions & 1 deletion cluster-autoscaler/core/autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"k8s.io/autoscaler/cluster-autoscaler/config"
"k8s.io/autoscaler/cluster-autoscaler/context"
"k8s.io/autoscaler/cluster-autoscaler/core/scaledown/pdb"
"k8s.io/autoscaler/cluster-autoscaler/core/scaleup"
"k8s.io/autoscaler/cluster-autoscaler/debuggingsnapshot"
"k8s.io/autoscaler/cluster-autoscaler/estimator"
"k8s.io/autoscaler/cluster-autoscaler/expander"
Expand Down Expand Up @@ -52,6 +53,7 @@ type AutoscalerOptions struct {
Backoff backoff.Backoff
DebuggingSnapshotter debuggingsnapshot.DebuggingSnapshotter
RemainingPdbTracker pdb.RemainingPdbTracker
ScaleUpOrchestrator scaleup.Orchestrator
}

// Autoscaler is the main component of CA which scales up/down node groups according to its configuration
Expand Down Expand Up @@ -82,7 +84,8 @@ func NewAutoscaler(opts AutoscalerOptions) (Autoscaler, errors.AutoscalerError)
opts.EstimatorBuilder,
opts.Backoff,
opts.DebuggingSnapshotter,
opts.RemainingPdbTracker), nil
opts.RemainingPdbTracker,
opts.ScaleUpOrchestrator), nil
}

// Initialize default options if not provided.
Expand Down
633 changes: 0 additions & 633 deletions cluster-autoscaler/core/scale_up.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,35 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package core
package equivalence

import (
"k8s.io/autoscaler/cluster-autoscaler/utils"
"reflect"

"k8s.io/autoscaler/cluster-autoscaler/utils"

apiv1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/autoscaler/cluster-autoscaler/processors/status"
"k8s.io/autoscaler/cluster-autoscaler/utils/drain"
pod_utils "k8s.io/autoscaler/cluster-autoscaler/utils/pod"
)

type podEquivalenceGroup struct {
pods []*apiv1.Pod
schedulingErrors map[string]status.Reasons
schedulable bool
// PodGroup contains a group of pods that are equivalent in terms of schedulability.
type PodGroup struct {
Pods []*apiv1.Pod
SchedulingErrors map[string]status.Reasons
Schedulable bool
}

// buildPodEquivalenceGroups prepares pod groups with equivalent scheduling properties.
func buildPodEquivalenceGroups(pods []*apiv1.Pod) []*podEquivalenceGroup {
podEquivalenceGroups := []*podEquivalenceGroup{}
// BuildPodGroups prepares pod groups with equivalent scheduling properties.
func BuildPodGroups(pods []*apiv1.Pod) []*PodGroup {
podEquivalenceGroups := []*PodGroup{}
for _, pods := range groupPodsBySchedulingProperties(pods) {
podEquivalenceGroups = append(podEquivalenceGroups, &podEquivalenceGroup{
pods: pods,
schedulingErrors: map[string]status.Reasons{},
schedulable: false,
podEquivalenceGroups = append(podEquivalenceGroups, &PodGroup{
Pods: pods,
SchedulingErrors: map[string]status.Reasons{},
Schedulable: false,
})
}
return podEquivalenceGroups
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package core
package equivalence

import (
"fmt"
Expand Down
Loading

0 comments on commit 241643d

Please sign in to comment.