mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 13:45:06 +00:00
Add Kubelet.ListBlockVolumesForPod()
This commit is contained in:
@@ -50,6 +50,26 @@ func (kl *Kubelet) ListVolumesForPod(podUID types.UID) (map[string]volume.Volume
|
|||||||
return volumesToReturn, len(volumesToReturn) > 0
|
return volumesToReturn, len(volumesToReturn) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListBlockVolumesForPod returns a map of the mounted volumes for the given
|
||||||
|
// pod. The key in the map is the OuterVolumeSpecName (i.e.
|
||||||
|
// pod.Spec.Volumes[x].Name)
|
||||||
|
func (kl *Kubelet) ListBlockVolumesForPod(podUID types.UID) (map[string]volume.BlockVolume, bool) {
|
||||||
|
volumesToReturn := make(map[string]volume.BlockVolume)
|
||||||
|
podVolumes := kl.volumeManager.GetMountedVolumesForPod(
|
||||||
|
volumetypes.UniquePodName(podUID))
|
||||||
|
for outerVolumeSpecName, volume := range podVolumes {
|
||||||
|
// TODO: volume.Mounter could be nil if volume object is recovered
|
||||||
|
// from reconciler's sync state process. PR 33616 will fix this problem
|
||||||
|
// to create Mounter object when recovering volume state.
|
||||||
|
if volume.BlockVolumeMapper == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
volumesToReturn[outerVolumeSpecName] = volume.BlockVolumeMapper
|
||||||
|
}
|
||||||
|
|
||||||
|
return volumesToReturn, len(volumesToReturn) > 0
|
||||||
|
}
|
||||||
|
|
||||||
// podVolumesExist checks with the volume manager and returns true any of the
|
// podVolumesExist checks with the volume manager and returns true any of the
|
||||||
// pods for the specified volume are mounted.
|
// pods for the specified volume are mounted.
|
||||||
func (kl *Kubelet) podVolumesExist(podUID types.UID) bool {
|
func (kl *Kubelet) podVolumesExist(podUID types.UID) bool {
|
||||||
|
@@ -259,7 +259,9 @@ func (*fakeKubelet) GetPodByCgroupfs(cgroupfs string) (*v1.Pod, bool) { return n
|
|||||||
func (fk *fakeKubelet) ListVolumesForPod(podUID types.UID) (map[string]volume.Volume, bool) {
|
func (fk *fakeKubelet) ListVolumesForPod(podUID types.UID) (map[string]volume.Volume, bool) {
|
||||||
return map[string]volume.Volume{}, true
|
return map[string]volume.Volume{}, true
|
||||||
}
|
}
|
||||||
|
func (*fakeKubelet) ListBlockVolumesForPod(podUID types.UID) (map[string]volume.BlockVolume, bool) {
|
||||||
|
return map[string]volume.BlockVolume{}, true
|
||||||
|
}
|
||||||
func (*fakeKubelet) RootFsStats() (*statsapi.FsStats, error) { return nil, nil }
|
func (*fakeKubelet) RootFsStats() (*statsapi.FsStats, error) { return nil, nil }
|
||||||
func (*fakeKubelet) ListPodStats() ([]statsapi.PodStats, error) { return nil, nil }
|
func (*fakeKubelet) ListPodStats() ([]statsapi.PodStats, error) { return nil, nil }
|
||||||
func (*fakeKubelet) ListPodStatsAndUpdateCPUNanoCoreUsage() ([]statsapi.PodStats, error) {
|
func (*fakeKubelet) ListPodStatsAndUpdateCPUNanoCoreUsage() ([]statsapi.PodStats, error) {
|
||||||
|
@@ -88,6 +88,9 @@ type Provider interface {
|
|||||||
// ListVolumesForPod returns the stats of the volume used by the pod with
|
// ListVolumesForPod returns the stats of the volume used by the pod with
|
||||||
// the podUID.
|
// the podUID.
|
||||||
ListVolumesForPod(podUID types.UID) (map[string]volume.Volume, bool)
|
ListVolumesForPod(podUID types.UID) (map[string]volume.Volume, bool)
|
||||||
|
// ListBlockVolumesForPod returns the stats of the volume used by the
|
||||||
|
// pod with the podUID.
|
||||||
|
ListBlockVolumesForPod(podUID types.UID) (map[string]volume.BlockVolume, bool)
|
||||||
// GetPods returns the specs of all the pods running on this node.
|
// GetPods returns the specs of all the pods running on this node.
|
||||||
GetPods() []*v1.Pod
|
GetPods() []*v1.Pod
|
||||||
|
|
||||||
|
@@ -351,6 +351,29 @@ func (_m *StatsProvider) ListVolumesForPod(podUID types.UID) (map[string]volume.
|
|||||||
return r0, r1
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListBlockVolumesForPod provides a mock function with given fields: podUID
|
||||||
|
func (_m *StatsProvider) ListBlockVolumesForPod(podUID types.UID) (map[string]volume.BlockVolume, bool) {
|
||||||
|
ret := _m.Called(podUID)
|
||||||
|
|
||||||
|
var r0 map[string]volume.BlockVolume
|
||||||
|
if rf, ok := ret.Get(0).(func(types.UID) map[string]volume.BlockVolume); ok {
|
||||||
|
r0 = rf(podUID)
|
||||||
|
} else {
|
||||||
|
if ret.Get(0) != nil {
|
||||||
|
r0 = ret.Get(0).(map[string]volume.BlockVolume)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var r1 bool
|
||||||
|
if rf, ok := ret.Get(1).(func(types.UID) bool); ok {
|
||||||
|
r1 = rf(podUID)
|
||||||
|
} else {
|
||||||
|
r1 = ret.Get(1).(bool)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0, r1
|
||||||
|
}
|
||||||
|
|
||||||
// RootFsStats provides a mock function with given fields:
|
// RootFsStats provides a mock function with given fields:
|
||||||
func (_m *StatsProvider) RootFsStats() (*v1alpha1.FsStats, error) {
|
func (_m *StatsProvider) RootFsStats() (*v1alpha1.FsStats, error) {
|
||||||
ret := _m.Called()
|
ret := _m.Called()
|
||||||
|
Reference in New Issue
Block a user