MCPcopy
hub / github.com/containerd/containerd / IsServing

Method IsServing

client/client.go:311–323  ·  view source on GitHub ↗

IsServing returns true if the client can successfully connect to the containerd daemon and the healthcheck service returns the SERVING response. This call will block if a transient error is encountered during connection. A timeout can be set in the context to ensure it returns early.

(ctx context.Context)

Source from the content-addressed store, hash-verified

309// connection. A timeout can be set in the context to ensure it returns
310// early.
311func (c *Client) IsServing(ctx context.Context) (bool, error) {
312 c.connMu.Lock()
313 if c.conn == nil {
314 c.connMu.Unlock()
315 return false, fmt.Errorf("no grpc connection available: %w", errdefs.ErrUnavailable)
316 }
317 c.connMu.Unlock()
318 r, err := c.HealthService().Check(ctx, &grpc_health_v1.HealthCheckRequest{}, grpc.WaitForReady(true))
319 if err != nil {
320 return false, err
321 }
322 return r.Status == grpc_health_v1.HealthCheckResponse_SERVING, nil
323}
324
325// Containers returns all containers created in containerd
326func (c *Client) Containers(ctx context.Context, filters ...string) ([]Container, error) {

Callers 4

waitForStartMethod · 0.80
TestDaemonRestartFunction · 0.80
TestClientReconnectFunction · 0.80

Calls 4

HealthServiceMethod · 0.95
LockMethod · 0.65
UnlockMethod · 0.65
CheckMethod · 0.65

Tested by 3

TestDaemonRestartFunction · 0.64
TestClientReconnectFunction · 0.64