Commit edc4ccd6 authored by Julien Balestra's avatar Julien Balestra Committed by JulienBalestra

Kubelet:rkt Fix the hostPath Volume creation

Kubelet:rkt Fix the hostPath Volume creation
parent a9019fe1
......@@ -1319,13 +1319,16 @@ func (r *Runtime) setupPodNetwork(pod *v1.Pod) (string, string, error) {
func createHostPathVolumes(pod *v1.Pod) (err error) {
for _, v := range pod.Spec.Volumes {
if v.VolumeSource.HostPath != nil {
err = os.MkdirAll(v.HostPath.Path, os.ModePerm)
if err != nil && !os.IsExist(err) {
_, err = os.Stat(v.HostPath.Path)
if os.IsNotExist(err) {
if err = os.MkdirAll(v.HostPath.Path, os.ModePerm); err != nil {
glog.Errorf("Create volume HostPath %q for Pod %q failed: %q", v.HostPath.Path, format.Pod(pod), err.Error())
return err
}
glog.V(4).Infof("Created volume HostPath %q for Pod %q", v.HostPath.Path, format.Pod(pod))
}
}
}
return nil
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment