Skip to content

Commit

Permalink
remove extra check for scaling from zero
Browse files Browse the repository at this point in the history
since the CanScaleFromZero function checks to see if both CPU and
memory are present, there is no need to check a second time. This also
adds some documentation to the CanScaleFromZero function to make it
clearer what is happening.
  • Loading branch information
elmiko committed May 2, 2022
1 parent 9450e75 commit 57fffa1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,6 @@ func (ng *nodegroup) TemplateNodeInfo() (*schedulerframework.NodeInfo, error) {
return nil, err
}

_, cpuPresent := capacity[corev1.ResourceCPU]
_, memPresent := capacity[corev1.ResourceMemory]
if !cpuPresent || !memPresent {
return nil, cloudprovider.ErrNotImplemented
}

nodeName := fmt.Sprintf("%s-asg-%d", ng.scalableResource.Name(), rand.Int63())
node := corev1.Node{
ObjectMeta: metav1.ObjectMeta{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ func (r unstructuredScalableResource) Taints() []apiv1.Taint {
return ret
}

// A node group can scale from zero if it can inform about the CPU and memory
// capacity of the nodes within the group.
func (r unstructuredScalableResource) CanScaleFromZero() bool {
capacity, err := r.InstanceCapacity()
if err != nil {
Expand Down

0 comments on commit 57fffa1

Please sign in to comment.