Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put ScaleUp logic behind an interface #5597

Merged
merged 7 commits into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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