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

Add HasNodeGroupStartedScaleUp to cluster state registry. #6169

Merged
merged 1 commit into from
Oct 13, 2023

Conversation

hbostan
Copy link
Contributor

@hbostan hbostan commented Oct 3, 2023

What type of PR is this?

/kind feature

What this PR does / why we need it:

Adds a new function to ClusterStateRegistry called HasNodeGroupStartedScaleUp() which returns whether the node group has a scale up request without checking if there are any upcoming nodes in the node group.

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 3, 2023
@k8s-ci-robot k8s-ci-robot added area/cluster-autoscaler size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 3, 2023
@kawych
Copy link
Contributor

kawych commented Oct 3, 2023

/LGTM

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 3, 2023
@x13n
Copy link
Member

x13n commented Oct 11, 2023

/assign

// Difference between IsNodeGroupScalingUp() is, this function doesn't check whether
// there are any upcoming nodes for the node group.
func (csr *ClusterStateRegistry) HasNodeGroupStartedScaleUp(nodeGroupName string) bool {
_, found := csr.scaleUpRequests[nodeGroupName]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Node group requests are cleared in

delete(csr.scaleUpRequests, nodeGroupName)
, what semantics exactly are you looking for here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required in the forked CA to see whether a node group has started scale up regardless of any upcoming nodes. In forked CA, node group's target size can change before the next call to UpdateNodes (and in turn to updateScaleRequests).

@@ -501,6 +501,14 @@ func (csr *ClusterStateRegistry) IsNodeGroupScalingUp(nodeGroupName string) bool
return found
}

// HasNodeGroupStartedScaleUp returns true if the node group has started scale up.
// Difference between IsNodeGroupScalingUp() is, this function doesn't check whether
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment would be more useful if it explained why this is useful rather than describing how it is implemented.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworded the comment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test case that would illustrate the difference betwen IsNodeGroupScalingUp and HasNodeGroupStartedScaleUp. As far as unit testing goes, they seem to be identical.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a new test demonstrating the case where two methods differ.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 12, 2023
Copy link
Member

@x13n x13n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a minor nit.

/approve

@@ -501,6 +501,17 @@ func (csr *ClusterStateRegistry) IsNodeGroupScalingUp(nodeGroupName string) bool
return found
}

// HasNodeGroupStartedScaleUp returns true if the node group has started scale up regarless
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, typo: regardless

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed :)

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hbostan, x13n

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 12, 2023
- HasNodeGroupStartedScaleUp checks wheter a scale up request exists
  without checking any upcoming nodes.
@x13n
Copy link
Member

x13n commented Oct 13, 2023

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 13, 2023
@k8s-ci-robot k8s-ci-robot merged commit 3065285 into kubernetes:master Oct 13, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/cluster-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants