Update cadvisor to 6116f265302357cbb10f84737af30b1f13ce2d6c
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
53
vendor/github.com/google/cadvisor/container/containerd/client.go
generated
vendored
53
vendor/github.com/google/cadvisor/container/containerd/client.go
generated
vendored
@@ -16,6 +16,7 @@ package containerd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
containersapi "github.com/containerd/containerd/api/services/containers/v1"
|
||||
@@ -45,32 +46,38 @@ type containerdClient interface {
|
||||
Version(ctx context.Context) (string, error)
|
||||
}
|
||||
|
||||
var once sync.Once
|
||||
var ctrdClient containerdClient = nil
|
||||
|
||||
// Client creates a containerd client
|
||||
func Client() (containerdClient, error) {
|
||||
gopts := []grpc.DialOption{
|
||||
grpc.WithInsecure(),
|
||||
grpc.FailOnNonTempDialError(true),
|
||||
grpc.WithDialer(dialer.Dialer),
|
||||
grpc.WithBlock(),
|
||||
grpc.WithTimeout(2 * time.Second),
|
||||
grpc.WithBackoffMaxDelay(3 * time.Second),
|
||||
}
|
||||
unary, stream := newNSInterceptors(k8sNamespace)
|
||||
gopts = append(gopts,
|
||||
grpc.WithUnaryInterceptor(unary),
|
||||
grpc.WithStreamInterceptor(stream),
|
||||
)
|
||||
var retErr error
|
||||
once.Do(func() {
|
||||
gopts := []grpc.DialOption{
|
||||
grpc.WithInsecure(),
|
||||
grpc.WithDialer(dialer.Dialer),
|
||||
grpc.WithBlock(),
|
||||
grpc.WithTimeout(2 * time.Second),
|
||||
grpc.WithBackoffMaxDelay(3 * time.Second),
|
||||
}
|
||||
unary, stream := newNSInterceptors(k8sNamespace)
|
||||
gopts = append(gopts,
|
||||
grpc.WithUnaryInterceptor(unary),
|
||||
grpc.WithStreamInterceptor(stream),
|
||||
)
|
||||
|
||||
conn, err := grpc.Dial(dialer.DialAddress("/var/run/containerd/containerd.sock"), gopts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c := &client{
|
||||
containerService: containersapi.NewContainersClient(conn),
|
||||
taskService: tasksapi.NewTasksClient(conn),
|
||||
versionService: versionapi.NewVersionClient(conn),
|
||||
}
|
||||
return c, err
|
||||
conn, err := grpc.Dial(dialer.DialAddress("/var/run/containerd/containerd.sock"), gopts...)
|
||||
if err != nil {
|
||||
retErr = err
|
||||
return
|
||||
}
|
||||
ctrdClient = &client{
|
||||
containerService: containersapi.NewContainersClient(conn),
|
||||
taskService: tasksapi.NewTasksClient(conn),
|
||||
versionService: versionapi.NewVersionClient(conn),
|
||||
}
|
||||
})
|
||||
return ctrdClient, retErr
|
||||
}
|
||||
|
||||
func (c *client) LoadContainer(ctx context.Context, id string) (*containers.Container, error) {
|
||||
|
14
vendor/github.com/google/cadvisor/container/docker/docker.go
generated
vendored
14
vendor/github.com/google/cadvisor/container/docker/docker.go
generated
vendored
@@ -29,19 +29,27 @@ import (
|
||||
"github.com/google/cadvisor/machine"
|
||||
)
|
||||
|
||||
const defaultTimeout = time.Second * 5
|
||||
var dockerTimeout = 10 * time.Second
|
||||
|
||||
func defaultContext() context.Context {
|
||||
ctx, _ := context.WithTimeout(context.Background(), defaultTimeout)
|
||||
ctx, _ := context.WithTimeout(context.Background(), dockerTimeout)
|
||||
return ctx
|
||||
}
|
||||
|
||||
func SetTimeout(timeout time.Duration) {
|
||||
dockerTimeout = timeout
|
||||
}
|
||||
|
||||
func Status() (v1.DockerStatus, error) {
|
||||
return StatusWithContext(defaultContext())
|
||||
}
|
||||
|
||||
func StatusWithContext(ctx context.Context) (v1.DockerStatus, error) {
|
||||
client, err := Client()
|
||||
if err != nil {
|
||||
return v1.DockerStatus{}, fmt.Errorf("unable to communicate with docker daemon: %v", err)
|
||||
}
|
||||
dockerInfo, err := client.Info(defaultContext())
|
||||
dockerInfo, err := client.Info(ctx)
|
||||
if err != nil {
|
||||
return v1.DockerStatus{}, err
|
||||
}
|
||||
|
3
vendor/github.com/google/cadvisor/container/docker/handler.go
generated
vendored
3
vendor/github.com/google/cadvisor/container/docker/handler.go
generated
vendored
@@ -44,6 +44,7 @@ import (
|
||||
const (
|
||||
// The read write layers exist here.
|
||||
aufsRWLayer = "diff"
|
||||
overlayRWLayer = "upper"
|
||||
overlay2RWLayer = "diff"
|
||||
|
||||
// Path to the directory where docker stores log files if the json logging driver is enabled.
|
||||
@@ -197,7 +198,7 @@ func newDockerContainerHandler(
|
||||
case aufsStorageDriver:
|
||||
rootfsStorageDir = path.Join(storageDir, string(aufsStorageDriver), aufsRWLayer, rwLayerID)
|
||||
case overlayStorageDriver:
|
||||
rootfsStorageDir = path.Join(storageDir, string(storageDriver), rwLayerID)
|
||||
rootfsStorageDir = path.Join(storageDir, string(storageDriver), rwLayerID, overlayRWLayer)
|
||||
case overlay2StorageDriver:
|
||||
rootfsStorageDir = path.Join(storageDir, string(storageDriver), rwLayerID, overlay2RWLayer)
|
||||
case zfsStorageDriver:
|
||||
|
Reference in New Issue
Block a user