本文整理汇总了Golang中k8s/io/kubernetes/pkg/util.ReadDirNoExit函数的典型用法代码示例。如果您正苦于以下问题:Golang ReadDirNoExit函数的具体用法?Golang ReadDirNoExit怎么用?Golang ReadDirNoExit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ReadDirNoExit函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getPodVolumes
func (kl *Kubelet) getPodVolumes(podUID types.UID) ([]*volumeTuple, error) {
var volumes []*volumeTuple
podVolDir := kl.getPodVolumesDir(podUID)
volumeKindDirs, err := ioutil.ReadDir(podVolDir)
if err != nil {
glog.Errorf("Could not read directory %s: %v", podVolDir, err)
}
for _, volumeKindDir := range volumeKindDirs {
volumeKind := volumeKindDir.Name()
volumeKindPath := path.Join(podVolDir, volumeKind)
// ioutil.ReadDir exits without returning any healthy dir when encountering the first lstat error
// but skipping dirs means no cleanup for healthy volumes. switching to a no-exit api solves this problem
volumeNameDirs, volumeNameDirsStat, err := util.ReadDirNoExit(volumeKindPath)
if err != nil {
return []*volumeTuple{}, fmt.Errorf("could not read directory %s: %v", volumeKindPath, err)
}
for i, volumeNameDir := range volumeNameDirs {
if volumeNameDir != nil {
volumes = append(volumes, &volumeTuple{Kind: volumeKind, Name: volumeNameDir.Name()})
} else {
glog.Errorf("Could not read directory %s: %v", podVolDir, volumeNameDirsStat[i])
}
}
}
return volumes, nil
}
示例2: getPodVolumeNameListFromDisk
// getPodVolumeNameListFromDisk returns a list of the volume names by reading the
// volume directories for the given pod from the disk.
func (kl *Kubelet) getPodVolumeNameListFromDisk(podUID types.UID) ([]string, error) {
volumes := []string{}
podVolDir := kl.getPodVolumesDir(podUID)
volumePluginDirs, err := ioutil.ReadDir(podVolDir)
if err != nil {
glog.Errorf("Could not read directory %s: %v", podVolDir, err)
return volumes, err
}
for _, volumePluginDir := range volumePluginDirs {
volumePluginName := volumePluginDir.Name()
volumePluginPath := path.Join(podVolDir, volumePluginName)
volumeDirs, volumeDirsStatErrs, err := util.ReadDirNoExit(volumePluginPath)
if err != nil {
return volumes, fmt.Errorf("Could not read directory %s: %v", volumePluginPath, err)
}
for i, volumeDir := range volumeDirs {
if volumeDir != nil {
volumes = append(volumes, volumeDir.Name())
continue
}
glog.Errorf("Could not read directory %s: %v", podVolDir, volumeDirsStatErrs[i])
}
}
return volumes, nil
}