提交 2a9e9b24 编写于 作者: A Anders F Björklund

Make sure to prepare the kic volume after creation

The volume is created as empty, so make sure that we run a
container to do the initial copy of /var from the image.

This is to avoid race conditions later on, where the preload
starts to use the created volume for packing up the tarball.
上级 bf387850
......@@ -99,6 +99,10 @@ func PrepareContainerNode(p CreateParams) error {
return errors.Wrapf(err, "creating volume for %s container", p.Name)
}
glog.Infof("Successfully created a %s volume %s", p.OCIBinary, p.Name)
if err := prepareVolume(p.OCIBinary, p.Image, p.Name); err != nil {
return errors.Wrapf(err, "preparing volume for %s container", p.Name)
}
glog.Infof("Successfully prepared a %s volume %s", p.OCIBinary, p.Name)
return nil
}
......
......@@ -106,3 +106,14 @@ func createVolume(ociBin string, profile string, nodeName string) error {
}
return nil
}
// prepareVolume will copy the initial content of the mount point by starting a container to check the expected content
func prepareVolume(ociBin string, imageName string, nodeName string) error {
cmdArgs := []string{"run", "--rm", "--entrypoint", "/usr/bin/test"}
cmdArgs = append(cmdArgs, "-v", fmt.Sprintf("%s:/var", nodeName), imageName, "-d", "/var/lib")
cmd := exec.Command(ociBin, cmdArgs...)
if _, err := runCmd(cmd); err != nil {
return err
}
return nil
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册