mirror of https://github.com/k3s-io/k3s
rootless: fix mounting /var/lib/cni
k3s was unable to start up when /var/lib/cni is missing on the host. Fix https://github.com/rancher/k3s/issues/470 Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>pull/505/head
parent
9efbeb11e4
commit
490d6aefe0
|
@ -42,13 +42,17 @@ func setupMount(target, dir string) error {
|
|||
toCreate = filepath.Base(toCreate)
|
||||
}
|
||||
|
||||
if err := os.MkdirAll(toCreate, 0700); err != nil {
|
||||
return errors.Wrapf(err, "failed to create directory %s", toCreate)
|
||||
}
|
||||
|
||||
logrus.Debug("Mounting none ", toCreate, " tmpfs")
|
||||
if err := unix.Mount("none", toCreate, "tmpfs", 0, ""); err != nil {
|
||||
return errors.Wrapf(err, "failed to mount tmpfs to %s", toCreate)
|
||||
}
|
||||
|
||||
if err := os.MkdirAll(target, 0700); err != nil {
|
||||
return errors.Wrapf(err, "failed to create directory %s")
|
||||
return errors.Wrapf(err, "failed to create directory %s", target)
|
||||
}
|
||||
|
||||
if dir == "" {
|
||||
|
@ -56,7 +60,7 @@ func setupMount(target, dir string) error {
|
|||
}
|
||||
|
||||
if err := os.MkdirAll(dir, 0700); err != nil {
|
||||
return errors.Wrapf(err, "failed to create directory %s")
|
||||
return errors.Wrapf(err, "failed to create directory %s", dir)
|
||||
}
|
||||
|
||||
logrus.Debug("Mounting ", dir, target, " none bind")
|
||||
|
|
|
@ -127,7 +127,7 @@ func createChildOpt() (*child.Opt, error) {
|
|||
opt.TargetCmd = os.Args
|
||||
opt.PipeFDEnvKey = pipeFD
|
||||
opt.NetworkDriver = slirp4netns.NewChildDriver()
|
||||
opt.CopyUpDirs = []string{"/etc", "/run"}
|
||||
opt.CopyUpDirs = []string{"/etc", "/run", "/var/lib"}
|
||||
opt.CopyUpDriver = tmpfssymlink.NewChildDriver()
|
||||
return opt, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue