Commit 402abd23 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #39493 from sjenning/fix-null-deref

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 https://github.com/kubernetes/kubernetes/pull/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 ```
parents 41d7acc0 c4e67252
...@@ -162,6 +162,9 @@ func (dswp *desiredStateOfWorldPopulator) findAndRemoveDeletedPods() { ...@@ -162,6 +162,9 @@ func (dswp *desiredStateOfWorldPopulator) findAndRemoveDeletedPods() {
} }
// Skip non-memory backed volumes belonging to terminated pods // Skip non-memory backed volumes belonging to terminated pods
volume := volumeToMount.VolumeSpec.Volume volume := volumeToMount.VolumeSpec.Volume
if volume == nil {
continue
}
if (volume.EmptyDir == nil || volume.EmptyDir.Medium != v1.StorageMediumMemory) && if (volume.EmptyDir == nil || volume.EmptyDir.Medium != v1.StorageMediumMemory) &&
volume.ConfigMap == nil && volume.Secret == nil { volume.ConfigMap == nil && volume.Secret == nil {
continue continue
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment