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

kubelet_stats: fix potential e2e crash dereferencing ContainerStats.CPU #79057

Merged

Conversation

rphillips
Copy link
Member

What type of PR is this?
/kind flake

What this PR does / why we need it:
The kubelet's stats API can return nil within the CPU attribute of cadvisorapiv2.ContainerStats. This patch fixes the e2e test to check for nil CPU attributes before trying to dereference oldStats.CPU and cStats.CPU. We are seeing this flake currently within CI.

ref: https://bugzilla.redhat.com/show_bug.cgi?id=1679612
ref: https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/stats/helper.go#L36-L40
ref: https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/stats/helper.go#L77-L84

/cc @kubernetes/sig-node-pr-reviews @sjenning

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/flake Categorizes issue or PR as related to a flaky test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. sig/node Categorizes an issue or PR as relevant to SIG Node. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Jun 15, 2019
Copy link
Contributor

@mattjmcnaughton mattjmcnaughton left a comment

Choose a reason for hiding this comment

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

Thanks for this fix :)

/lgtm
/assign @BenTheElder

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 15, 2019
@mattjmcnaughton
Copy link
Contributor

mattjmcnaughton commented Jun 15, 2019

/test pull-kubernetes-bazel-build

Copy link
Contributor

@mattjmcnaughton mattjmcnaughton left a comment

Choose a reason for hiding this comment

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

/lgtm cancel

whoops, jumped the gun here. I'm not sure this is actually going to work the way we are hoping.

I think this change will just push the nil failure back to the computeContainerResourceUsage method.

Maybe we should also continue if either cStats or oldStats is nil?

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 15, 2019
@rphillips rphillips force-pushed the fixes/e2e_kubelet_stats_fix branch from 8bdc819 to 9553434 Compare June 15, 2019 18:36
@rphillips
Copy link
Member Author

@mattjmcnaughton thanks for the review... I've tweaked the PR with your suggestion.

@rphillips
Copy link
Member Author

/retest

@rphillips rphillips force-pushed the fixes/e2e_kubelet_stats_fix branch from 9553434 to b9feff9 Compare June 15, 2019 19:49
@rphillips
Copy link
Member Author

/retest

Copy link
Contributor

@mattjmcnaughton mattjmcnaughton left a comment

Choose a reason for hiding this comment

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

Cool, I'm convinced that this won't crash :)

My only request is for someone else with more context on this code than me to confirm that we do not want to treat either oldStats or cStats being new as a test failure. I'll let whoever does that confirmation approve.

@rphillips
Copy link
Member Author

/assign @timothysc

@@ -598,6 +598,9 @@ func (r *resourceCollector) collectStats(oldStatsMap map[string]*stats.Container
}

if oldStats, ok := oldStatsMap[name]; ok {
if oldStats.CPU == nil || cStats.CPU == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

cStats.Memory looks like it might be subject to the same problem if that comes back nil.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the review... Updated the PR :)

@rphillips rphillips force-pushed the fixes/e2e_kubelet_stats_fix branch from b9feff9 to 997e1f6 Compare June 17, 2019 14:57
@RobertKrawitz
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 17, 2019
@rphillips
Copy link
Member Author

/retest

@BenTheElder
Copy link
Member

/priority important-soon

@k8s-ci-robot k8s-ci-robot added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jun 21, 2019
Copy link
Member

@BenTheElder BenTheElder left a comment

Choose a reason for hiding this comment

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

/approve
/hold
this seems reasonable, holding in case we still want input from @timothysc, feel free to hold cancel to unflake and follow up later :-)

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 21, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: BenTheElder, rphillips

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 Jun 21, 2019
@timothysc timothysc assigned timothysc and unassigned timothysc Jun 24, 2019
@timothysc
Copy link
Member

I don't see an issue, but I'd defer to @kubernetes/sig-node-pr-reviews for final lgtm.

@sjenning
Copy link
Contributor

/lgtm
/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 24, 2019
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

2 similar comments
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@k8s-ci-robot k8s-ci-robot merged commit 1db31d4 into kubernetes:master Jun 25, 2019
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/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework area/kubelet area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/flake Categorizes issue or PR as related to a flaky test. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note-none Denotes a PR that doesn't merit a release note. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants