-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat(nodeScaleDownTime): add a new metric to track unprocessed nodes during scaleDown #8614
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
base: master
Are you sure you want to change the base?
feat(nodeScaleDownTime): add a new metric to track unprocessed nodes during scaleDown #8614
Conversation
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Welcome @shaikenov! |
Hi @shaikenov. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very good
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: kada2004, shaikenov The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
b9e7969
to
86a98d1
Compare
86a98d1
to
0457f73
Compare
0457f73
to
c2756ca
Compare
// We want to track all the nodes that were marked as unneeded, but were unprocessed during the ScaleDown. | ||
// If a node was unneeded, but unprocessed multiple times consecutively, we store only the earliest time it happened. | ||
// The difference between the current time and the earliest time among all unprocessed nodes will give the longest time | ||
LongestNodeScaleDownTimeTrackerEnabled bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds a bit like a node has been deleted...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pointed that nodes are unprocessed and not deleted
// if l.minimumTime is 0, then in previous iteration we also processed all the nodes, so the longest time is 0 | ||
// otherwise -> report the longest time from previous iteration and reset the minimumTime | ||
if l.minimumTime.IsZero() { | ||
longestTime = 0 | ||
} else { | ||
longestTime = currentTime.Sub(l.minimumTime) | ||
l.minimumTime = time.Time{} | ||
} | ||
l.nodeNamesWithTimeStamps = make(map[string]time.Time) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this will never be called, because you check for null in handleUnprocessedNodes and return early in that case. I would also add unit test covering this path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in handleUnprocessedNodes() I do check the p.longestNodeScaleDownT
for being null and not nodeNames
. It is needed for the case when flag is disabled and longestNodeScaleDownT
is not instantiated.
We will end up in this part of code if we have processed all the nodes.
About the unit tests I already check this behavior in "Test the functionality of longestNodeScaleDownT with all nodes processed in the first iteration"
and "LongestLastScaleDownEvalDuration flag is disabled"
func TestLongestNodeScaleDownTime(t *testing.T) { | ||
testCases := []struct { | ||
name string | ||
nodes []*apiv1.Node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems unused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, agree
assert.Equal(t, val, start) | ||
} | ||
} | ||
tc.unprocessedNodes = []string{"n2", "n3"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not very readable, I mean updating test case params here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
introduced 2d array for unprocessedNodes
testCases := []struct { | ||
name string | ||
nodes []*apiv1.Node | ||
unprocessedNodesInFirstIter []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wandering if having 2 dim array where each row reflects one iteration wouldn't be more flexible? You could also then get rid of run
param.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree
registry := kube_util.NewListerRegistry(nil, nil, nil, nil, nil, nil, nil, nil, nil) | ||
provider := testprovider.NewTestCloudProviderBuilder().Build() | ||
provider.AddNodeGroup("ng1", 0, 0, 0) | ||
for _, node := range tc.nodes { | ||
provider.AddNode("ng1", node) | ||
} | ||
autoscalingCtx, err := NewScaleTestAutoscalingContext(config.AutoscalingOptions{ | ||
NodeGroupDefaults: config.NodeGroupAutoscalingOptions{ | ||
ScaleDownUnneededTime: 10 * time.Minute, | ||
}, | ||
ScaleDownSimulationTimeout: 1 * time.Second, | ||
MaxScaleDownParallelism: tc.maxParallel, | ||
LongestNodeScaleDownTimeTrackerEnabled: tc.isFlagEnabled, | ||
}, &fake.Clientset{}, registry, provider, nil, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like setup. Do we need to recreate it for each test case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think before autoscalingCtx instantiation - yes, we can put it as part of setup. autoscalingCtx has MaxScaleDownParallelism and LongestNodeScaleDownTimeTrackerEnabled which I alternate in different test cases, so I would prefer to have it recreated
… nodes during scaleDown
c2756ca
to
a279f58
Compare
What type of PR is this?
/kind feature
What this PR does / why we need it:
This PR adds a new metric to the exported prometheus metrics list: LongestNodeScaleDownTime
We want to track all the nodes that were marked as unneeded, but were unprocessed during the ScaleDown. If a node was unneeded, but unprocessed multiple times consecutively, we store only the earliest time it happened. The difference between the current time and the earliest time among all unprocessed nodes will give the longest time. This time can give us an indication of possible throttling and helps to better monitor what happens during ScaleDown.
Which issue(s) this PR fixes:
None
Special notes for your reviewer: this is a draft PR, work is still in progress
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
None