Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kubelet:rkt Fix the hostPath Volume creation #44467

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions pkg/kubelet/rkt/rkt.go
Expand Up @@ -1319,11 +1319,14 @@ 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) {
return 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))
}
glog.V(4).Infof("Created volume HostPath %q for Pod %q", v.HostPath.Path, format.Pod(pod))
}
}
return nil
Expand Down