Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ef5d694

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request #34251 from jingxu97/Oct/nil-mounter-10-6
Automatic merge from submit-queue Fix nil pointer issue when getting metrics from volume mounter Currently it is possible that the mounter object stored in Mounted Volume data structure in the actual state of kubelet volume manager is nil if this information is recovered from state sync process. This will cause nil pointer issue when calculating stats in volume_stat_calculator. A quick fix is to not return the volume if its mounter is nil. A more complete fix is to also recover mounter object when reconstructing the volume data structure which will be addressed in PR #33616
2 parents 86c322e + b2b0409 commit ef5d694

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

pkg/kubelet/kubelet_volumes.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ func (kl *Kubelet) ListVolumesForPod(podUID types.UID) (map[string]volume.Volume
4040
podVolumes := kl.volumeManager.GetMountedVolumesForPod(
4141
volumetypes.UniquePodName(podUID))
4242
for outerVolumeSpecName, volume := range podVolumes {
43+
// TODO: volume.Mounter could be nil if volume object is recovered
44+
// from reconciler's sync state process. PR 33616 will fix this problem
45+
// to create Mounter object when recovering volume state.
46+
if volume.Mounter == nil {
47+
continue
48+
}
4349
volumesToReturn[outerVolumeSpecName] = volume.Mounter
4450
}
4551

0 commit comments

Comments
 (0)