Merge pull request #10454 from govargo/fix/preload-side-car

Change prepareVolume func to add container name for preload side car
pull/10511/head
Medya Ghazizadeh 2021-02-18 10:33:22 -08:00 committed by GitHub
commit 92e6100edb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -100,7 +100,7 @@ func PrepareContainerNode(p CreateParams) error {
return errors.Wrapf(err, "creating volume for %s container", p.Name)
}
klog.Infof("Successfully created a %s volume %s", p.OCIBinary, p.Name)
if err := prepareVolume(p.OCIBinary, p.Image, p.Name); err != nil {
if err := prepareVolumeSideCar(p.OCIBinary, p.Image, p.Name); err != nil {
return errors.Wrapf(err, "preparing volume for %s container", p.Name)
}
klog.Infof("Successfully prepared a %s volume %s", p.OCIBinary, p.Name)

View File

@ -151,9 +151,9 @@ 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"}
// prepareVolumeSideCar will copy the initial content of the mount point by starting a temporary container to check the expected content
func prepareVolumeSideCar(ociBin string, imageName string, nodeName string) error {
cmdArgs := []string{"run", "--rm", "--name", fmt.Sprintf("%s-preload-sidecar", nodeName), "--label", fmt.Sprintf("%s=%s", CreatedByLabelKey, "true"), "--label", fmt.Sprintf("%s=%s", ProfileLabelKey, nodeName), "--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 {