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

Commit

Permalink
Merge pull request #153 from resouer/hyperhq-fix-get-vol
Browse files Browse the repository at this point in the history
Fix invalid list vol tag
  • Loading branch information
feiskyer authored Nov 24, 2016
2 parents d38abdf + 60c7a64 commit 02ff4a3
Showing 1 changed file with 31 additions and 32 deletions.
63 changes: 31 additions & 32 deletions pkg/kubelet/hyper/hyper.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,46 +431,45 @@ func (r *runtime) buildHyperPod(pod *api.Pod, restartCount int, pullSecrets []ap

// build hyper volume spec
specMap := make(map[string]interface{})

// process rbd volume globally
volumeMap, ok := r.runtimeHelper.ListVolumesForPod(pod.UID)
if !ok {
return nil, fmt.Errorf("cannot get the volumes for pod %q", kubecontainer.GetPodFullName(pod))
}
volumes := make([]map[string]interface{}, 0, 1)
for name, mounter := range volumeMap {
glog.V(4).Infof("Hyper: volume %s, path %s, meta %s", name, mounter.GetPath(), mounter.GetMetaData())
v := make(map[string]interface{})
v[KEY_NAME] = name

// Process rbd volume
metadata := mounter.GetMetaData()
if metadata != nil && metadata["volume_type"].(string) == "rbd" {
v[KEY_VOLUME_DRIVE] = metadata["volume_type"]
v["source"] = "rbd:" + metadata["name"].(string)
monitors := make([]string, 0, 1)
for _, host := range metadata["hosts"].([]interface{}) {
for _, port := range metadata["ports"].([]interface{}) {
monitors = append(monitors, fmt.Sprintf("%s:%s", host.(string), port.(string)))

volumeMap, found := r.runtimeHelper.ListVolumesForPod(pod.UID)
if found {
// process rbd volume globally
for name, mounter := range volumeMap {
glog.V(4).Infof("Hyper: volume %s, path %s, meta %s", name, mounter.GetPath(), mounter.GetMetaData())
v := make(map[string]interface{})
v[KEY_NAME] = name

// Process rbd volume
metadata := mounter.GetMetaData()
if metadata != nil && metadata["volume_type"].(string) == "rbd" {
v[KEY_VOLUME_DRIVE] = metadata["volume_type"]
v["source"] = "rbd:" + metadata["name"].(string)
monitors := make([]string, 0, 1)
for _, host := range metadata["hosts"].([]interface{}) {
for _, port := range metadata["ports"].([]interface{}) {
monitors = append(monitors, fmt.Sprintf("%s:%s", host.(string), port.(string)))
}
}
v["option"] = map[string]interface{}{
"user": metadata["auth_username"],
"keyring": metadata["keyring"],
"monitors": monitors,
}
} else {
glog.V(4).Infof("Hyper: volume %s %s", name, mounter.GetPath())

v[KEY_VOLUME_DRIVE] = VOLUME_TYPE_VFS
v[KEY_VOLUME_SOURCE] = mounter.GetPath()
}
v["option"] = map[string]interface{}{
"user": metadata["auth_username"],
"keyring": metadata["keyring"],
"monitors": monitors,
}
} else {
glog.V(4).Infof("Hyper: volume %s %s", name, mounter.GetPath())

v[KEY_VOLUME_DRIVE] = VOLUME_TYPE_VFS
v[KEY_VOLUME_SOURCE] = mounter.GetPath()
volumes = append(volumes, v)
}

volumes = append(volumes, v)
glog.V(4).Infof("Hyper volumes: %v", volumes)
}

glog.V(4).Infof("Hyper volumes: %v", volumes)

if !r.disableHyperInternalService {
services := r.buildHyperPodServices(pod)
if services == nil {
Expand Down

0 comments on commit 02ff4a3

Please sign in to comment.