未验证 提交 c6000e6c 编写于 作者: M Medya Ghazizadeh 提交者: GitHub

Merge pull request #8777 from afbjorklund/kic-var

Make sure to prepare the kic volume after creation
...@@ -122,27 +122,22 @@ func (d *Driver) Create() error { ...@@ -122,27 +122,22 @@ func (d *Driver) Create() error {
} }
var waitForPreload sync.WaitGroup var waitForPreload sync.WaitGroup
if d.NodeConfig.OCIBinary == oci.Docker { waitForPreload.Add(1)
waitForPreload.Add(1) go func() {
go func() { defer waitForPreload.Done()
defer waitForPreload.Done() // If preload doesn't exist, don't bother extracting tarball to volume
// If preload doesn't exist, don't bother extracting tarball to volume if !download.PreloadExists(d.NodeConfig.KubernetesVersion, d.NodeConfig.ContainerRuntime) {
if !download.PreloadExists(d.NodeConfig.KubernetesVersion, d.NodeConfig.ContainerRuntime) { return
return }
} t := time.Now()
t := time.Now() glog.Infof("Starting extracting preloaded images to volume ...")
glog.Infof("Starting extracting preloaded images to volume ...") // Extract preloaded images to container
// Extract preloaded images to container if err := oci.ExtractTarballToVolume(d.NodeConfig.OCIBinary, download.TarballPath(d.NodeConfig.KubernetesVersion, d.NodeConfig.ContainerRuntime), params.Name, d.NodeConfig.ImageDigest); err != nil {
if err := oci.ExtractTarballToVolume(d.NodeConfig.OCIBinary, download.TarballPath(d.NodeConfig.KubernetesVersion, d.NodeConfig.ContainerRuntime), params.Name, d.NodeConfig.ImageDigest); err != nil { glog.Infof("Unable to extract preloaded tarball to volume: %v", err)
glog.Infof("Unable to extract preloaded tarball to volume: %v", err) } else {
} else { glog.Infof("duration metric: took %f seconds to extract preloaded images to volume", time.Since(t).Seconds())
glog.Infof("duration metric: took %f seconds to extract preloaded images to volume", time.Since(t).Seconds()) }
} }()
}()
} else {
// driver == "podman"
glog.Info("Driver isn't docker, skipping extracting preloaded images")
}
if err := oci.CreateContainerNode(params); err != nil { if err := oci.CreateContainerNode(params); err != nil {
return errors.Wrap(err, "create kic node") return errors.Wrap(err, "create kic node")
......
...@@ -99,6 +99,10 @@ func PrepareContainerNode(p CreateParams) error { ...@@ -99,6 +99,10 @@ func PrepareContainerNode(p CreateParams) error {
return errors.Wrapf(err, "creating volume for %s container", p.Name) return errors.Wrapf(err, "creating volume for %s container", p.Name)
} }
glog.Infof("Successfully created a %s volume %s", p.OCIBinary, 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 return nil
} }
......
...@@ -106,3 +106,14 @@ func createVolume(ociBin string, profile string, nodeName string) error { ...@@ -106,3 +106,14 @@ func createVolume(ociBin string, profile string, nodeName string) error {
} }
return nil 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
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册