mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-21 13:08:00 +00:00
Merge pull request #9015 from Apokleos/bugfix-exec-uds
runtime: display accurate error msg to avoid misleading users.
This commit is contained in:
commit
cf74166d75
@ -338,12 +338,16 @@ func ServerSocketAddress(id string) string {
|
||||
// shim management endpoint
|
||||
// NOTE: this code allows various go clients, e.g. kata-runtime or kata-monitor commands, to
|
||||
// connect to the rust shim management implementation.
|
||||
func ClientSocketAddress(id string) string {
|
||||
func ClientSocketAddress(id string) (string, error) {
|
||||
// get the go runtime uds path
|
||||
socketPath := SocketPathGo(id)
|
||||
// if the path not exist, use the rust runtime uds path instead
|
||||
if _, err := os.Stat(socketPath); err != nil {
|
||||
socketPath = SocketPathRust(id)
|
||||
if _, err := os.Stat(socketPath); err != nil {
|
||||
return "", fmt.Errorf("It fails to stat both %s and %s with error %v.", SocketPathGo(id), SocketPathRust(id), err)
|
||||
}
|
||||
}
|
||||
return fmt.Sprintf("unix://%s", socketPath)
|
||||
|
||||
return fmt.Sprintf("unix://%s", socketPath), nil
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ func (km *KataMonitor) composeSocketAddress(r *http.Request) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return shim.ClientSocketAddress(sandbox), nil
|
||||
return shim.ClientSocketAddress(sandbox)
|
||||
}
|
||||
|
||||
func (km *KataMonitor) proxyRequest(w http.ResponseWriter, r *http.Request,
|
||||
|
@ -19,7 +19,12 @@ import (
|
||||
|
||||
// BuildShimClient builds and returns an http client for communicating with the provided sandbox
|
||||
func BuildShimClient(sandboxID string, timeout time.Duration) (*http.Client, error) {
|
||||
return buildUnixSocketClient(shim.ClientSocketAddress(sandboxID), timeout)
|
||||
socketAddress, err := shim.ClientSocketAddress(sandboxID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return buildUnixSocketClient(socketAddress, timeout)
|
||||
}
|
||||
|
||||
// buildUnixSocketClient build http client for Unix socket
|
||||
|
Loading…
Reference in New Issue
Block a user