Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRI-O: try connecting with different socket paths #129

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions containers/crio.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net"
"net/http"
"os"
"strings"
"time"

"github.com/coroot/coroot-node-agent/common"
Expand All @@ -20,7 +21,6 @@ const crioTimeout = 30 * time.Second

var (
crioClient *http.Client
crioSocket = proc.HostPath("/var/run/crio/crio.sock")
)

type CrioContainerInfo struct {
Expand All @@ -37,8 +37,23 @@ type CrioVolume struct {
}

func CrioInit() error {
if _, err := os.Stat(crioSocket); err != nil {
return err
sockets := []string{
"/var/run/crio/crio.sock",
"/run/crio/crio.sock",
}
var crioSocket string
var err error
for _, socket := range sockets {
socketHostPath := proc.HostPath(socket)
if _, err := os.Stat(socketHostPath); err == nil {
def marked this conversation as resolved.
Show resolved Hide resolved
crioSocket = socketHostPath
break
}
}
if err != nil {
return fmt.Errorf("couldn't connect to CRI-O through the following UNIX sockets: [%s]: %s",
strings.Join(sockets, ","), err,
)
}
klog.Infoln("cri-o socket:", crioSocket)

Expand All @@ -50,6 +65,7 @@ func CrioInit() error {
DisableCompression: true,
},
}

return nil
}

Expand Down