Skip to content

test: add retry to getMetricsFromNode and deflake 'should grab all metrics from kubelet /metrics/resource endpoint' #133392

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rphillips
Copy link
Member

@rphillips rphillips commented Aug 5, 2025

What type of PR is this?

/kind bug
/kind failing-test

Test: should grab all metrics from kubelet /metrics/resource endpoint

What this PR does / why we need it:

It's unclear why #114997 was seeing a proxy timeout. 114997 added logic to timeout the connection and error out on the timeout. In OpenShift CI we do see something similar. The case is rare - only about 3% of the time.

Instead of erroring completely we can improve the design of the getMetricsFromNode function to issue a retry, and setup the client to have a 45 second timeout. This will allow the function to gracefully recover and always return metrics - effectively deflaking the test.

45 seconds was selected for the timeout since the metrics endpoint in the Kubelet is sometimes returning metrics within 30 seconds. 30 seconds is a long time and is a separate issue under investigation.

Which issue(s) this PR is related to:

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 size/M Denotes a PR that changes 30-99 lines, ignoring generated files. release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. kind/failing-test Categorizes issue or PR as related to a consistently or frequently failing test. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Aug 5, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: rphillips
Once this PR has been reviewed and has the lgtm label, please assign rexagod for approval. For more information see the Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework area/test sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Aug 5, 2025
@rphillips
Copy link
Member Author

/triage accepted
/priority important-longterm

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Aug 6, 2025
Resource("nodes").
SubResource("proxy").
Name(fmt.Sprintf("%v:%v", nodeName, kubeletPort)).
Suffix(pathSuffix).
Timeout(45 * time.Second).
Copy link
Contributor

Choose a reason for hiding this comment

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

I find this a confusing.

So we are calling this function every 15 s (up to 120 s). And we set a timeout for 45 seconds?

There seems to be overlap where the function will be polling while we are still requesting the call?

Should we drop timeout or match the polling intervanl?

Copy link
Member Author

Choose a reason for hiding this comment

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

We are calling this function once if it succeeds. Setting a client side timeout of 45 seconds in case the client request has a timeout. If there is a timeout then the function is run again. If there is not a successful response within 2 minutes then that is fatal.

@kannon92
Copy link
Contributor

kannon92 commented Aug 6, 2025

/lgtm
/milestone v1.35

This is not flaky in upstream so I don't think it needs to merge post code freeze. Can wait for 1.35.

@k8s-ci-robot k8s-ci-robot added this to the v1.35 milestone Aug 6, 2025
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 6, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 133f5e5cef4aad7db266c9b204c64a01c0524be5

@dgrisonnet
Copy link
Member

Assigning myself for sig-instrumentation review.

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. kind/failing-test Categorizes issue or PR as related to a consistently or frequently failing test. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note-none Denotes a PR that doesn't merit a release note. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants