diff --git a/pkg/drivers/kic/oci/oci.go b/pkg/drivers/kic/oci/oci.go index 3ef6a94cfb..e66b76597c 100644 --- a/pkg/drivers/kic/oci/oci.go +++ b/pkg/drivers/kic/oci/oci.go @@ -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 } diff --git a/pkg/drivers/kic/oci/volumes.go b/pkg/drivers/kic/oci/volumes.go index f3fb62d13a..f43007ec7b 100644 --- a/pkg/drivers/kic/oci/volumes.go +++ b/pkg/drivers/kic/oci/volumes.go @@ -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