Skip to content

Commit

Permalink
Check ctr location (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
alxtkr77 authored Sep 17, 2024
1 parent 06a4b04 commit 1ae9da8
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pkg/cri/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"context"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path"
"strconv"
Expand Down Expand Up @@ -231,7 +232,23 @@ func (c *Containerd) createContainer(image string,

// pull the v3io-fuse image
// [IG-23016] MountVolume.SetUp failed for volume storage in k8s 1.29
cmd := exec.Command("/usr/local/bin/ctr", "-n", "k8s.io", "images", "pull", "--hosts-dir", "/etc/containerd/certs.d/", image)

var ctrPath string

// Check if "/usr/local/bin/ctr" exists
if _, err := os.Stat("/usr/local/bin/ctr"); err == nil {
ctrPath = "/usr/local/bin/ctr"
} else if _, err := os.Stat("/usr/bin/ctr"); err == nil {
ctrPath = "/usr/bin/ctr"
} else {
// Return an error if neither file exists
journal.Error("Failed to pull image: ctr not found",
"containerName", containerName,
"image", image)
return nil, err
}

cmd := exec.Command(ctrPath, "-n", "k8s.io", "images", "pull", "--hosts-dir", "/etc/containerd/certs.d/", image)
output, err := cmd.CombinedOutput()
// Handle errors
if err != nil {
Expand Down

0 comments on commit 1ae9da8

Please sign in to comment.