Enable min size 0 in gce
This commit is contained in:
parent
faad1da0ad
commit
bfa105e959
|
|
@ -287,7 +287,7 @@ func (asg *Asg) TemplateNodeInfo() (*schedulercache.NodeInfo, error) {
|
|||
}
|
||||
|
||||
func buildAsgFromSpec(value string, awsManager *AwsManager) (*Asg, error) {
|
||||
spec, err := dynamic.SpecFromString(value)
|
||||
spec, err := dynamic.SpecFromString(value, false)
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse node group spec: %v", err)
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@ func (mig *Mig) TemplateNodeInfo() (*schedulercache.NodeInfo, error) {
|
|||
}
|
||||
|
||||
func buildMig(value string, gceManager *GceManager) (*Mig, error) {
|
||||
spec, err := dynamic.SpecFromString(value)
|
||||
spec, err := dynamic.SpecFromString(value, true)
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse node group spec: %v", err)
|
||||
|
|
|
|||
|
|
@ -30,16 +30,18 @@ type NodeGroupSpec struct {
|
|||
MinSize int `json:"minSize"`
|
||||
// Max size of the autoscaling target
|
||||
MaxSize int `json:"maxSize"`
|
||||
|
||||
supportScaleToZero bool
|
||||
}
|
||||
|
||||
// SpecFromString parses a node group spec represented in the form of `<minSize>:<maxSize>:<name>` and produces a node group spec object
|
||||
func SpecFromString(value string) (*NodeGroupSpec, error) {
|
||||
func SpecFromString(value string, supportScaleToZero bool) (*NodeGroupSpec, error) {
|
||||
tokens := strings.SplitN(value, ":", 3)
|
||||
if len(tokens) != 3 {
|
||||
return nil, fmt.Errorf("wrong nodes configuration: %s", value)
|
||||
}
|
||||
|
||||
spec := NodeGroupSpec{}
|
||||
spec := NodeGroupSpec{supportScaleToZero: supportScaleToZero}
|
||||
if size, err := strconv.Atoi(tokens[0]); err == nil {
|
||||
|
||||
spec.MinSize = size
|
||||
|
|
@ -64,8 +66,14 @@ func SpecFromString(value string) (*NodeGroupSpec, error) {
|
|||
|
||||
// Validate produces an error if there's an invalid field in the node group spec
|
||||
func (s NodeGroupSpec) Validate() error {
|
||||
if s.MinSize <= 0 {
|
||||
return fmt.Errorf("min size must be >= 1")
|
||||
if s.supportScaleToZero {
|
||||
if s.MinSize < 0 {
|
||||
return fmt.Errorf("min size must be >= 0")
|
||||
}
|
||||
} else {
|
||||
if s.MinSize <= 0 {
|
||||
return fmt.Errorf("min size must be >= 1")
|
||||
}
|
||||
}
|
||||
if s.MaxSize < s.MinSize {
|
||||
return fmt.Errorf("max size must be greater or equal to min size")
|
||||
|
|
|
|||
Loading…
Reference in New Issue