Skip to content

kubelet: fix nil deref in volume type check#39493

Merged
k8s-github-robot merged 1 commit into
kubernetes:masterfrom
sjenning:fix-null-deref
Jan 6, 2017
Merged

kubelet: fix nil deref in volume type check#39493
k8s-github-robot merged 1 commit into
kubernetes:masterfrom
sjenning:fix-null-deref

Conversation

@sjenning

@sjenning sjenning commented Jan 5, 2017

Copy link
Copy Markdown
Contributor

An attempt to address memory exhaustion through a build up of terminated pods with memory backed volumes on the node in PR #36779 introduced this.

For the VolumeSpec, either the Volume or PersistentVolume field is set, not both. This results in a situation where there is a nil deref on PVs. Since PVs are inherently not memory-backend, only local/temporal volumes should be considered.

This needs to go into 1.5 as well.

Fixes #39480

@saad-ali @derekwaynecarr @grosskur @gnufied

fixes nil dereference when doing a volume type check on persistent volumes

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 5, 2017
@k8s-reviewable

Copy link
Copy Markdown

This change is Reviewable

@k8s-github-robot k8s-github-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. release-note-label-needed labels Jan 5, 2017
@sjenning

sjenning commented Jan 5, 2017

Copy link
Copy Markdown
Contributor Author

@saad-ali note that my follow up PR for 1.6 removes this check completely

e3f4bfb#diff-94e527d26427ceb4f990f05f76952656L163

@saad-ali saad-ali added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-label-needed labels Jan 5, 2017
@saad-ali

saad-ali commented Jan 5, 2017

Copy link
Copy Markdown
Member

Thanks for the quick fix @sjenning. LGTM. Please prepare a cherry-pick for this PR, as soon as it merges. 1.5.2 should go out on Tuesday, Jan 10. Let's make sure that this fix makes it in.

Could you also add a release note to this PR.

@saad-ali saad-ali added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 5, 2017
@saad-ali saad-ali added this to the v1.5 milestone Jan 5, 2017
if volume == nil {
continue
}
if (volume.EmptyDir == nil || volume.EmptyDir.Medium != v1.StorageMediumMemory) &&

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we still need this check below? Since if Volume field is nil - it would automatically mean we are dealing with temporal storage?

Also - it may be good idea to cover this with some test? Not sure how easy that will be though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We still need to check if the temporal storage is disk- or memory-backed. The idea here was that we wanted to skip removing disk-backed temporal storage until the pod is removed from the API server, but remove memory-backed volumes as soon as the pod is in a terminal state.

I have a follow-on PR #37228 for 1.6 that removes this check entirely.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we still need this check below? Since if Volume field is nil - it would automatically mean we are dealing with temporal storage?

No, VolumeSource volumes could include both.

Also - it may be good idea to cover this with some test? Not sure how easy that will be though.

Always a good idea.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Also - it may be good idea to cover this with some test? Not sure how easy that will be though.

I'll try to write a test as part of my follow-on PR.

@gnufied

gnufied commented Jan 5, 2017

Copy link
Copy Markdown
Member

LGTM

@sjenning

sjenning commented Jan 6, 2017

Copy link
Copy Markdown
Contributor Author

@k8s-bot gce e2e test this

@saad-ali

saad-ali commented Jan 6, 2017

Copy link
Copy Markdown
Member

@k8s-bot test this

@saad-ali

saad-ali commented Jan 6, 2017

Copy link
Copy Markdown
Member

@k8s-bot gce etcd3 e2e test this

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Jenkins GCE etcd3 e2e failed for commit c4e6725. Full PR test history.

The magic incantation to run this job again is @k8s-bot gce etcd3 e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

Details

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/test-infra repository. I understand the commands that are listed here.

@sjenning

sjenning commented Jan 6, 2017

Copy link
Copy Markdown
Contributor Author

@k8s-bot gce etcd3 e2e test this

@k8s-github-robot

Copy link
Copy Markdown

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot

Copy link
Copy Markdown

Automatic merge from submit-queue (batch tested with PRs 39493, 39496)

@k8s-github-robot k8s-github-robot merged commit 402abd2 into kubernetes:master Jan 6, 2017
@saad-ali saad-ali added the cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. label Jan 6, 2017
k8s-github-robot pushed a commit that referenced this pull request Jan 11, 2017
Automatic merge from submit-queue

kubelet: fix nil deref in volume type check

Cherry pick #39493

@saad-ali @derekwaynecarr @grosskur @gnufied

```release-note
fix nil dereference when doing a volume type check on persistent volumes
```
@k8s-cherrypick-bot

Copy link
Copy Markdown

Commit found in the "release-1.5" branch appears to be this PR. Removing the "cherrypick-candidate" label. If this is an error find help to get your PR picked.

@sjenning sjenning deleted the fix-null-deref branch August 16, 2017 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

kubelet panic: "invalid memory address or nil pointer dereference" in findAndRemoveDeletedPods()

7 participants