Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 02ff4a3

Browse files
authored
Merge pull request #153 from resouer/hyperhq-fix-get-vol
Fix invalid list vol tag
2 parents d38abdf + 60c7a64 commit 02ff4a3

File tree

1 file changed

+31
-32
lines changed

1 file changed

+31
-32
lines changed

pkg/kubelet/hyper/hyper.go

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -431,46 +431,45 @@ func (r *runtime) buildHyperPod(pod *api.Pod, restartCount int, pullSecrets []ap
431431

432432
// build hyper volume spec
433433
specMap := make(map[string]interface{})
434-
435-
// process rbd volume globally
436-
volumeMap, ok := r.runtimeHelper.ListVolumesForPod(pod.UID)
437-
if !ok {
438-
return nil, fmt.Errorf("cannot get the volumes for pod %q", kubecontainer.GetPodFullName(pod))
439-
}
440434
volumes := make([]map[string]interface{}, 0, 1)
441-
for name, mounter := range volumeMap {
442-
glog.V(4).Infof("Hyper: volume %s, path %s, meta %s", name, mounter.GetPath(), mounter.GetMetaData())
443-
v := make(map[string]interface{})
444-
v[KEY_NAME] = name
445-
446-
// Process rbd volume
447-
metadata := mounter.GetMetaData()
448-
if metadata != nil && metadata["volume_type"].(string) == "rbd" {
449-
v[KEY_VOLUME_DRIVE] = metadata["volume_type"]
450-
v["source"] = "rbd:" + metadata["name"].(string)
451-
monitors := make([]string, 0, 1)
452-
for _, host := range metadata["hosts"].([]interface{}) {
453-
for _, port := range metadata["ports"].([]interface{}) {
454-
monitors = append(monitors, fmt.Sprintf("%s:%s", host.(string), port.(string)))
435+
436+
volumeMap, found := r.runtimeHelper.ListVolumesForPod(pod.UID)
437+
if found {
438+
// process rbd volume globally
439+
for name, mounter := range volumeMap {
440+
glog.V(4).Infof("Hyper: volume %s, path %s, meta %s", name, mounter.GetPath(), mounter.GetMetaData())
441+
v := make(map[string]interface{})
442+
v[KEY_NAME] = name
443+
444+
// Process rbd volume
445+
metadata := mounter.GetMetaData()
446+
if metadata != nil && metadata["volume_type"].(string) == "rbd" {
447+
v[KEY_VOLUME_DRIVE] = metadata["volume_type"]
448+
v["source"] = "rbd:" + metadata["name"].(string)
449+
monitors := make([]string, 0, 1)
450+
for _, host := range metadata["hosts"].([]interface{}) {
451+
for _, port := range metadata["ports"].([]interface{}) {
452+
monitors = append(monitors, fmt.Sprintf("%s:%s", host.(string), port.(string)))
453+
}
455454
}
455+
v["option"] = map[string]interface{}{
456+
"user": metadata["auth_username"],
457+
"keyring": metadata["keyring"],
458+
"monitors": monitors,
459+
}
460+
} else {
461+
glog.V(4).Infof("Hyper: volume %s %s", name, mounter.GetPath())
462+
463+
v[KEY_VOLUME_DRIVE] = VOLUME_TYPE_VFS
464+
v[KEY_VOLUME_SOURCE] = mounter.GetPath()
456465
}
457-
v["option"] = map[string]interface{}{
458-
"user": metadata["auth_username"],
459-
"keyring": metadata["keyring"],
460-
"monitors": monitors,
461-
}
462-
} else {
463-
glog.V(4).Infof("Hyper: volume %s %s", name, mounter.GetPath())
464466

465-
v[KEY_VOLUME_DRIVE] = VOLUME_TYPE_VFS
466-
v[KEY_VOLUME_SOURCE] = mounter.GetPath()
467+
volumes = append(volumes, v)
467468
}
468469

469-
volumes = append(volumes, v)
470+
glog.V(4).Infof("Hyper volumes: %v", volumes)
470471
}
471472

472-
glog.V(4).Infof("Hyper volumes: %v", volumes)
473-
474473
if !r.disableHyperInternalService {
475474
services := r.buildHyperPodServices(pod)
476475
if services == nil {

0 commit comments

Comments
 (0)