Skip to content

Commit

Permalink
Merge pull request #39493 from sjenning/fix-null-deref
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue (batch tested with PRs 39493, 39496)

kubelet: fix nil deref in volume type check

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

```release-note
fixes nil dereference when doing a volume type check on persistent volumes
```
  • Loading branch information
Kubernetes Submit Queue committed Jan 6, 2017
2 parents 41d7acc + c4e6725 commit 402abd2
Showing 1 changed file with 3 additions and 0 deletions.
Expand Up @@ -162,6 +162,9 @@ func (dswp *desiredStateOfWorldPopulator) findAndRemoveDeletedPods() {
}
// Skip non-memory backed volumes belonging to terminated pods
volume := volumeToMount.VolumeSpec.Volume
if volume == nil {
continue
}
if (volume.EmptyDir == nil || volume.EmptyDir.Medium != v1.StorageMediumMemory) &&
volume.ConfigMap == nil && volume.Secret == nil {
continue
Expand Down

0 comments on commit 402abd2

Please sign in to comment.