Merge pull request #6149 from openanolis/fix_kata_runtime

runtime:fix stat uds path
This commit is contained in:
Peng Tao 2023-02-02 11:00:07 +08:00 committed by GitHub
commit a34f36f8f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -315,11 +315,11 @@ func GetSandboxesStoragePathRust() string {
// SocketAddress returns the address of the unix domain socket for communicating with the // SocketAddress returns the address of the unix domain socket for communicating with the
// shim management endpoint // shim management endpoint
func SocketAddress(id string) string { func SocketAddress(id string) string {
socketAddress := fmt.Sprintf("unix://%s", filepath.Join(string(filepath.Separator), GetSandboxesStoragePath(), id, "shim-monitor.sock")) // get the go runtime uds path
_, err := os.Stat(socketAddress) socketPath := filepath.Join(string(filepath.Separator), GetSandboxesStoragePath(), id, "shim-monitor.sock")
// if the path not exist, check the rust runtime path // if the path not exist, use the rust runtime uds path instead
if err != nil { if _, err := os.Stat(socketPath); err != nil {
return fmt.Sprintf("unix://%s", filepath.Join(string(filepath.Separator), GetSandboxesStoragePathRust(), id, "shim-monitor.sock")) return fmt.Sprintf("unix://%s", filepath.Join(string(filepath.Separator), GetSandboxesStoragePathRust(), id, "shim-monitor.sock"))
} }
return socketAddress return fmt.Sprintf("unix://%s", socketPath)
} }