Mark BasicEstimator as deprecated
This commit is contained in:
parent
bf6ff4be8e
commit
d9f804c686
|
|
@ -21,14 +21,20 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
|
||||||
|
"github.com/golang/glog"
|
||||||
apiv1 "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
schedulercache "k8s.io/kubernetes/pkg/scheduler/cache"
|
schedulercache "k8s.io/kubernetes/pkg/scheduler/cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const basicEstimatorDeprecationMessage = "WARNING: basic estimator is deprecated. It will be removed in Cluster Autoscaler 1.5."
|
||||||
|
|
||||||
// BasicNodeEstimator estimates the number of needed nodes to handle the given amount of pods.
|
// BasicNodeEstimator estimates the number of needed nodes to handle the given amount of pods.
|
||||||
// It will never overestimate the number of nodes but is quite likely to provide a number that
|
// It will never overestimate the number of nodes but is quite likely to provide a number that
|
||||||
// is too small.
|
// is too small.
|
||||||
|
//
|
||||||
|
// Deprecated.
|
||||||
|
// TODO(aleksandra-malinowska): remove this in 1.5.
|
||||||
type BasicNodeEstimator struct {
|
type BasicNodeEstimator struct {
|
||||||
cpuSum resource.Quantity
|
cpuSum resource.Quantity
|
||||||
memorySum resource.Quantity
|
memorySum resource.Quantity
|
||||||
|
|
@ -38,6 +44,7 @@ type BasicNodeEstimator struct {
|
||||||
|
|
||||||
// NewBasicNodeEstimator builds BasicNodeEstimator.
|
// NewBasicNodeEstimator builds BasicNodeEstimator.
|
||||||
func NewBasicNodeEstimator() *BasicNodeEstimator {
|
func NewBasicNodeEstimator() *BasicNodeEstimator {
|
||||||
|
glog.Warning(basicEstimatorDeprecationMessage)
|
||||||
return &BasicNodeEstimator{
|
return &BasicNodeEstimator{
|
||||||
portSum: make(map[int32]int),
|
portSum: make(map[int32]int),
|
||||||
FittingPods: make(map[*apiv1.Pod]struct{}),
|
FittingPods: make(map[*apiv1.Pod]struct{}),
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ package estimator
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/golang/glog"
|
||||||
apiv1 "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/autoscaler/cluster-autoscaler/simulator"
|
"k8s.io/autoscaler/cluster-autoscaler/simulator"
|
||||||
schedulercache "k8s.io/kubernetes/pkg/scheduler/cache"
|
schedulercache "k8s.io/kubernetes/pkg/scheduler/cache"
|
||||||
|
|
@ -31,25 +32,35 @@ const (
|
||||||
BinpackingEstimatorName = "binpacking"
|
BinpackingEstimatorName = "binpacking"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AvailableEstimators is a list of available estimators.
|
func deprecated(name string) string {
|
||||||
var AvailableEstimators = []string{BasicEstimatorName, BinpackingEstimatorName}
|
return fmt.Sprintf("%s (DEPRECATED)", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AvailableEstimators is a list of available estimators.
|
||||||
|
var AvailableEstimators = []string{BinpackingEstimatorName, deprecated(BasicEstimatorName)}
|
||||||
|
|
||||||
|
// Estimator calculates the number of nodes of given type needed to schedule pods.
|
||||||
type Estimator interface {
|
type Estimator interface {
|
||||||
Estimate([]*apiv1.Pod, *schedulercache.NodeInfo, []*schedulercache.NodeInfo) int
|
Estimate([]*apiv1.Pod, *schedulercache.NodeInfo, []*schedulercache.NodeInfo) int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EstimatorBuilder creates a new estimator object.
|
||||||
type EstimatorBuilder func(*simulator.PredicateChecker) Estimator
|
type EstimatorBuilder func(*simulator.PredicateChecker) Estimator
|
||||||
|
|
||||||
|
// NewEstimatorBuilder creates a new estimator object from flag.
|
||||||
func NewEstimatorBuilder(name string) (EstimatorBuilder, error) {
|
func NewEstimatorBuilder(name string) (EstimatorBuilder, error) {
|
||||||
switch name {
|
switch name {
|
||||||
case BasicEstimatorName:
|
|
||||||
return func(_ *simulator.PredicateChecker) Estimator {
|
|
||||||
return NewBasicNodeEstimator()
|
|
||||||
}, nil
|
|
||||||
case BinpackingEstimatorName:
|
case BinpackingEstimatorName:
|
||||||
return func(predicateChecker *simulator.PredicateChecker) Estimator {
|
return func(predicateChecker *simulator.PredicateChecker) Estimator {
|
||||||
return NewBinpackingNodeEstimator(predicateChecker)
|
return NewBinpackingNodeEstimator(predicateChecker)
|
||||||
}, nil
|
}, nil
|
||||||
|
// Deprecated.
|
||||||
|
// TODO(aleksandra-malinowska): remove in 1.5.
|
||||||
|
case BasicEstimatorName:
|
||||||
|
glog.Warning(basicEstimatorDeprecationMessage)
|
||||||
|
return func(_ *simulator.PredicateChecker) Estimator {
|
||||||
|
return NewBasicNodeEstimator()
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("Unknown estimator: %s", name)
|
return nil, fmt.Errorf("Unknown estimator: %s", name)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue