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

runtime: display accurate error msg to avoid misleading users. #9015

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/runtime/pkg/containerd-shim-v2/shim_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion src/runtime/pkg/kata-monitor/pprof.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion src/runtime/pkg/utils/shimclient/shim_management_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down