Skip to content

Commit

Permalink
fix(containerd): readable query failure error message (When CRI is no…
Browse files Browse the repository at this point in the history
…t set up) (#129)

* fix(containerd): readable query failure error message (When CRI is not set up)

Signed-off-by: Gyuho Lee <[email protected]>

* update

Signed-off-by: Gyuho Lee <[email protected]>

---------

Signed-off-by: Gyuho Lee <[email protected]>
  • Loading branch information
gyuho authored Oct 21, 2024
1 parent f76bd98 commit 7b629d6
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion components/containerd/pod/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import (
"github.com/leptonai/gpud/components"
"github.com/leptonai/gpud/components/query"
"github.com/leptonai/gpud/log"

"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)

const Name = "containerd-pod"
Expand Down Expand Up @@ -47,12 +50,24 @@ func (c *component) States(ctx context.Context) ([]components.State, error) {
return nil, nil
}
if last.Error != nil {
// this is the error from "ListSandboxStatus"
//
// e.g.,
// rpc error: code = Unimplemented desc = unknown service runtime.v1.RuntimeService
reason := "failed gRPC call to the containerd socket"
st, ok := status.FromError(last.Error)
if ok {
if st.Code() == codes.Unimplemented {
reason += "; no CRI configured for containerd"
}
}

return []components.State{
{
Name: Name,
Healthy: false,
Error: last.Error.Error(),
Reason: "last query failed",
Reason: reason,
},
}, nil
}
Expand Down

0 comments on commit 7b629d6

Please sign in to comment.