Add UUID and server info to introspection
Closes #1862 This adds a new rpc to the introspection service to provide server information with a generated UUID that is done on demand and the os and arch of the server. ctr output: ```bash > sudo ctr version Client: Version: v1.2.0-802-g57821695.m Revision: 578216950de9c1c188708369e2a31ac6c494dfee.m Server: Version: v1.2.0-802-g57821695.m Revision: 578216950de9c1c188708369e2a31ac6c494dfee.m UUID: 92e982a9-f13e-4a2c-9032-e69b27fed454 OS: linux ARCH: amd64 ``` Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
22
client.go
22
client.go
@@ -57,6 +57,7 @@ import (
|
||||
"github.com/containerd/containerd/snapshots"
|
||||
snproxy "github.com/containerd/containerd/snapshots/proxy"
|
||||
"github.com/containerd/typeurl"
|
||||
"github.com/gogo/protobuf/types"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
@@ -678,6 +679,27 @@ func (c *Client) Version(ctx context.Context) (Version, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
type ServerInfo struct {
|
||||
UUID string
|
||||
}
|
||||
|
||||
func (c *Client) Server(ctx context.Context) (ServerInfo, error) {
|
||||
c.connMu.Lock()
|
||||
if c.conn == nil {
|
||||
c.connMu.Unlock()
|
||||
return ServerInfo{}, errors.Wrap(errdefs.ErrUnavailable, "no grpc connection available")
|
||||
}
|
||||
c.connMu.Unlock()
|
||||
|
||||
response, err := c.IntrospectionService().Server(ctx, &types.Empty{})
|
||||
if err != nil {
|
||||
return ServerInfo{}, err
|
||||
}
|
||||
return ServerInfo{
|
||||
UUID: response.UUID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *Client) resolveSnapshotterName(ctx context.Context, name string) (string, error) {
|
||||
if name == "" {
|
||||
label, err := c.GetLabel(ctx, defaults.DefaultSnapshotterNSLabel)
|
||||
|
Reference in New Issue
Block a user