Merge pull request #8143 from mxpv/log
Add Fields type alias to log package
This commit is contained in:
commit
8cb00f45c9
@ -174,7 +174,7 @@ can be used and modified as necessary as a custom configuration.`
|
|||||||
log.G(ctx).WithError(w).Warn("cleanup temp mount")
|
log.G(ctx).WithError(w).Warn("cleanup temp mount")
|
||||||
}
|
}
|
||||||
|
|
||||||
log.G(ctx).WithFields(logrus.Fields{
|
log.G(ctx).WithFields(log.Fields{
|
||||||
"version": version.Version,
|
"version": version.Version,
|
||||||
"revision": version.Revision,
|
"revision": version.Revision,
|
||||||
}).Info("starting containerd")
|
}).Info("starting containerd")
|
||||||
|
@ -81,7 +81,7 @@ var pruneReferencesCommand = cli.Command{
|
|||||||
|
|
||||||
for k := range info.Labels {
|
for k := range info.Labels {
|
||||||
if isLayerLabel(k) {
|
if isLayerLabel(k) {
|
||||||
log.G(ctx).WithFields(logrus.Fields{
|
log.G(ctx).WithFields(log.Fields{
|
||||||
"digest": info.Digest,
|
"digest": info.Digest,
|
||||||
"label": k,
|
"label": k,
|
||||||
}).Debug("Removing label")
|
}).Debug("Removing label")
|
||||||
|
@ -28,7 +28,6 @@ import (
|
|||||||
"github.com/containerd/containerd/mount"
|
"github.com/containerd/containerd/mount"
|
||||||
digest "github.com/opencontainers/go-digest"
|
digest "github.com/opencontainers/go-digest"
|
||||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewFileSystemApplier returns an applier which simply mounts
|
// NewFileSystemApplier returns an applier which simply mounts
|
||||||
@ -52,7 +51,7 @@ func (s *fsApplier) Apply(ctx context.Context, desc ocispec.Descriptor, mounts [
|
|||||||
t1 := time.Now()
|
t1 := time.Now()
|
||||||
defer func() {
|
defer func() {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.G(ctx).WithFields(logrus.Fields{
|
log.G(ctx).WithFields(log.Fields{
|
||||||
"d": time.Since(t1),
|
"d": time.Since(t1),
|
||||||
"digest": desc.Digest,
|
"digest": desc.Digest,
|
||||||
"size": desc.Size,
|
"size": desc.Size,
|
||||||
|
@ -39,7 +39,6 @@ import (
|
|||||||
"github.com/containerd/containerd/plugin"
|
"github.com/containerd/containerd/plugin"
|
||||||
digest "github.com/opencontainers/go-digest"
|
digest "github.com/opencontainers/go-digest"
|
||||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -99,7 +98,7 @@ func (s windowsLcowDiff) Apply(ctx context.Context, desc ocispec.Descriptor, mou
|
|||||||
t1 := time.Now()
|
t1 := time.Now()
|
||||||
defer func() {
|
defer func() {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.G(ctx).WithFields(logrus.Fields{
|
log.G(ctx).WithFields(log.Fields{
|
||||||
"d": time.Since(t1),
|
"d": time.Since(t1),
|
||||||
"digest": desc.Digest,
|
"digest": desc.Digest,
|
||||||
"size": desc.Size,
|
"size": desc.Size,
|
||||||
|
@ -42,7 +42,6 @@ import (
|
|||||||
"github.com/containerd/containerd/plugin"
|
"github.com/containerd/containerd/plugin"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -94,7 +93,7 @@ func (s windowsDiff) Apply(ctx context.Context, desc ocispec.Descriptor, mounts
|
|||||||
t1 := time.Now()
|
t1 := time.Now()
|
||||||
defer func() {
|
defer func() {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.G(ctx).WithFields(logrus.Fields{
|
log.G(ctx).WithFields(log.Fields{
|
||||||
"d": time.Since(t1),
|
"d": time.Since(t1),
|
||||||
"digest": desc.Digest,
|
"digest": desc.Digest,
|
||||||
"size": desc.Size,
|
"size": desc.Size,
|
||||||
@ -295,7 +294,7 @@ func (s windowsDiff) Compare(ctx context.Context, lower, upper []mount.Mount, op
|
|||||||
Digest: info.Digest,
|
Digest: info.Digest,
|
||||||
}
|
}
|
||||||
|
|
||||||
log.G(ctx).WithFields(logrus.Fields{
|
log.G(ctx).WithFields(log.Fields{
|
||||||
"d": time.Since(t1),
|
"d": time.Since(t1),
|
||||||
"dgst": desc.Digest,
|
"dgst": desc.Digest,
|
||||||
"size": desc.Size,
|
"size": desc.Size,
|
||||||
|
@ -30,7 +30,6 @@ import (
|
|||||||
"github.com/containerd/containerd/namespaces"
|
"github.com/containerd/containerd/namespaces"
|
||||||
"github.com/containerd/typeurl/v2"
|
"github.com/containerd/typeurl/v2"
|
||||||
goevents "github.com/docker/go-events"
|
goevents "github.com/docker/go-events"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Exchange broadcasts events
|
// Exchange broadcasts events
|
||||||
@ -59,7 +58,7 @@ func (e *Exchange) Forward(ctx context.Context, envelope *events.Envelope) (err
|
|||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
logger := log.G(ctx).WithFields(logrus.Fields{
|
logger := log.G(ctx).WithFields(log.Fields{
|
||||||
"topic": envelope.Topic,
|
"topic": envelope.Topic,
|
||||||
"ns": envelope.Namespace,
|
"ns": envelope.Namespace,
|
||||||
"type": envelope.Event.GetTypeUrl(),
|
"type": envelope.Event.GetTypeUrl(),
|
||||||
@ -103,7 +102,7 @@ func (e *Exchange) Publish(ctx context.Context, topic string, event events.Event
|
|||||||
envelope.Event = encoded
|
envelope.Event = encoded
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
logger := log.G(ctx).WithFields(logrus.Fields{
|
logger := log.G(ctx).WithFields(log.Fields{
|
||||||
"topic": envelope.Topic,
|
"topic": envelope.Topic,
|
||||||
"ns": envelope.Namespace,
|
"ns": envelope.Namespace,
|
||||||
"type": envelope.Event.GetTypeUrl(),
|
"type": envelope.Event.GetTypeUrl(),
|
||||||
|
@ -28,7 +28,6 @@ import (
|
|||||||
|
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
"github.com/opencontainers/image-spec/identity"
|
"github.com/opencontainers/image-spec/identity"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
exec "golang.org/x/sys/execabs"
|
exec "golang.org/x/sys/execabs"
|
||||||
@ -123,7 +122,7 @@ func TestMain(m *testing.M) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// allow comparison with containerd under test
|
// allow comparison with containerd under test
|
||||||
log.G(ctx).WithFields(logrus.Fields{
|
log.G(ctx).WithFields(log.Fields{
|
||||||
"version": version.Version,
|
"version": version.Version,
|
||||||
"revision": version.Revision,
|
"revision": version.Revision,
|
||||||
"runtime": os.Getenv("TEST_RUNTIME"),
|
"runtime": os.Getenv("TEST_RUNTIME"),
|
||||||
|
@ -14,7 +14,7 @@ require (
|
|||||||
github.com/opencontainers/go-digest v1.0.0
|
github.com/opencontainers/go-digest v1.0.0
|
||||||
github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b
|
github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b
|
||||||
github.com/opencontainers/runtime-spec v1.0.3-0.20220825212826-86290f6a00fb
|
github.com/opencontainers/runtime-spec v1.0.3-0.20220825212826-86290f6a00fb
|
||||||
github.com/sirupsen/logrus v1.9.0
|
github.com/sirupsen/logrus v1.9.0 // indirect
|
||||||
github.com/stretchr/testify v1.8.1
|
github.com/stretchr/testify v1.8.1
|
||||||
go.opentelemetry.io/otel v1.12.0
|
go.opentelemetry.io/otel v1.12.0
|
||||||
go.opentelemetry.io/otel/sdk v1.12.0
|
go.opentelemetry.io/otel/sdk v1.12.0
|
||||||
|
@ -35,6 +35,9 @@ var (
|
|||||||
|
|
||||||
type (
|
type (
|
||||||
loggerKey struct{}
|
loggerKey struct{}
|
||||||
|
|
||||||
|
// Fields type to pass to `WithFields`, alias from `logrus`.
|
||||||
|
Fields = logrus.Fields
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -29,7 +29,6 @@ import (
|
|||||||
"github.com/containerd/containerd/remotes"
|
"github.com/containerd/containerd/remotes"
|
||||||
"github.com/containerd/containerd/remotes/docker"
|
"github.com/containerd/containerd/remotes/docker"
|
||||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (ts *localTransferService) pull(ctx context.Context, ir transfer.ImageFetcher, is transfer.ImageStorer, tops *transfer.Config) error {
|
func (ts *localTransferService) pull(ctx context.Context, ir transfer.ImageFetcher, is transfer.ImageStorer, tops *transfer.Config) error {
|
||||||
@ -223,7 +222,7 @@ func (ts *localTransferService) pull(ctx context.Context, ir transfer.ImageFetch
|
|||||||
|
|
||||||
func fetchHandler(ingester content.Ingester, fetcher remotes.Fetcher, pt *ProgressTracker) images.HandlerFunc {
|
func fetchHandler(ingester content.Ingester, fetcher remotes.Fetcher, pt *ProgressTracker) images.HandlerFunc {
|
||||||
return func(ctx context.Context, desc ocispec.Descriptor) (subdescs []ocispec.Descriptor, err error) {
|
return func(ctx context.Context, desc ocispec.Descriptor) (subdescs []ocispec.Descriptor, err error) {
|
||||||
ctx = log.WithLogger(ctx, log.G(ctx).WithFields(logrus.Fields{
|
ctx = log.WithLogger(ctx, log.G(ctx).WithFields(log.Fields{
|
||||||
"digest": desc.Digest,
|
"digest": desc.Digest,
|
||||||
"mediatype": desc.MediaType,
|
"mediatype": desc.MediaType,
|
||||||
"size": desc.Size,
|
"size": desc.Size,
|
||||||
|
@ -43,7 +43,6 @@ import (
|
|||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
"github.com/opencontainers/image-spec/identity"
|
"github.com/opencontainers/image-spec/identity"
|
||||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
"golang.org/x/sync/semaphore"
|
"golang.org/x/sync/semaphore"
|
||||||
)
|
)
|
||||||
@ -437,7 +436,7 @@ func (u *Unpacker) unpack(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.G(ctx).WithFields(logrus.Fields{
|
log.G(ctx).WithFields(log.Fields{
|
||||||
"config": config.Digest,
|
"config": config.Digest,
|
||||||
"chainID": chainID,
|
"chainID": chainID,
|
||||||
}).Debug("image unpacked")
|
}).Debug("image unpacked")
|
||||||
|
@ -29,7 +29,6 @@ import (
|
|||||||
"github.com/containerd/containerd/log"
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/remotes/docker/auth"
|
"github.com/containerd/containerd/remotes/docker/auth"
|
||||||
remoteerrors "github.com/containerd/containerd/remotes/errors"
|
remoteerrors "github.com/containerd/containerd/remotes/errors"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type dockerAuthorizer struct {
|
type dockerAuthorizer struct {
|
||||||
@ -312,7 +311,7 @@ func (ah *authHandler) doBearerAuth(ctx context.Context) (token, refreshToken st
|
|||||||
}
|
}
|
||||||
return resp.Token, resp.RefreshToken, nil
|
return resp.Token, resp.RefreshToken, nil
|
||||||
}
|
}
|
||||||
log.G(ctx).WithFields(logrus.Fields{
|
log.G(ctx).WithFields(log.Fields{
|
||||||
"status": errStatus.Status,
|
"status": errStatus.Status,
|
||||||
"body": string(errStatus.Body),
|
"body": string(errStatus.Body),
|
||||||
}).Debugf("token request failed")
|
}).Debugf("token request failed")
|
||||||
|
@ -38,7 +38,6 @@ import (
|
|||||||
"github.com/containerd/containerd/version"
|
"github.com/containerd/containerd/version"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -647,7 +646,7 @@ func (r *request) String() string {
|
|||||||
return r.host.Scheme + "://" + r.host.Host + r.path
|
return r.host.Scheme + "://" + r.host.Host + r.path
|
||||||
}
|
}
|
||||||
|
|
||||||
func requestFields(req *http.Request) logrus.Fields {
|
func requestFields(req *http.Request) log.Fields {
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
"request.method": req.Method,
|
"request.method": req.Method,
|
||||||
}
|
}
|
||||||
@ -665,10 +664,10 @@ func requestFields(req *http.Request) logrus.Fields {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return logrus.Fields(fields)
|
return log.Fields(fields)
|
||||||
}
|
}
|
||||||
|
|
||||||
func responseFields(resp *http.Response) logrus.Fields {
|
func responseFields(resp *http.Response) log.Fields {
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
"response.status": resp.Status,
|
"response.status": resp.Status,
|
||||||
}
|
}
|
||||||
@ -683,7 +682,7 @@ func responseFields(resp *http.Response) logrus.Fields {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return logrus.Fields(fields)
|
return log.Fields(fields)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsLocalhost checks if the registry host is local.
|
// IsLocalhost checks if the registry host is local.
|
||||||
|
@ -31,7 +31,6 @@ import (
|
|||||||
"github.com/containerd/containerd/log"
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/platforms"
|
"github.com/containerd/containerd/platforms"
|
||||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"golang.org/x/sync/semaphore"
|
"golang.org/x/sync/semaphore"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -91,7 +90,7 @@ func MakeRefKey(ctx context.Context, desc ocispec.Descriptor) string {
|
|||||||
// recursive fetch.
|
// recursive fetch.
|
||||||
func FetchHandler(ingester content.Ingester, fetcher Fetcher) images.HandlerFunc {
|
func FetchHandler(ingester content.Ingester, fetcher Fetcher) images.HandlerFunc {
|
||||||
return func(ctx context.Context, desc ocispec.Descriptor) (subdescs []ocispec.Descriptor, err error) {
|
return func(ctx context.Context, desc ocispec.Descriptor) (subdescs []ocispec.Descriptor, err error) {
|
||||||
ctx = log.WithLogger(ctx, log.G(ctx).WithFields(logrus.Fields{
|
ctx = log.WithLogger(ctx, log.G(ctx).WithFields(log.Fields{
|
||||||
"digest": desc.Digest,
|
"digest": desc.Digest,
|
||||||
"mediatype": desc.MediaType,
|
"mediatype": desc.MediaType,
|
||||||
"size": desc.Size,
|
"size": desc.Size,
|
||||||
@ -157,7 +156,7 @@ func Fetch(ctx context.Context, ingester content.Ingester, fetcher Fetcher, desc
|
|||||||
// using a writer from the pusher.
|
// using a writer from the pusher.
|
||||||
func PushHandler(pusher Pusher, provider content.Provider) images.HandlerFunc {
|
func PushHandler(pusher Pusher, provider content.Provider) images.HandlerFunc {
|
||||||
return func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
|
return func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
|
||||||
ctx = log.WithLogger(ctx, log.G(ctx).WithFields(logrus.Fields{
|
ctx = log.WithLogger(ctx, log.G(ctx).WithFields(log.Fields{
|
||||||
"digest": desc.Digest,
|
"digest": desc.Digest,
|
||||||
"mediatype": desc.MediaType,
|
"mediatype": desc.MediaType,
|
||||||
"size": desc.Size,
|
"size": desc.Size,
|
||||||
|
@ -50,7 +50,6 @@ import (
|
|||||||
"github.com/containerd/go-runc"
|
"github.com/containerd/go-runc"
|
||||||
"github.com/containerd/typeurl/v2"
|
"github.com/containerd/typeurl/v2"
|
||||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -166,7 +165,7 @@ func (r *Runtime) Create(ctx context.Context, id string, opts runtime.CreateOpts
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ctx = log.WithLogger(ctx, log.G(ctx).WithError(err).WithFields(logrus.Fields{
|
ctx = log.WithLogger(ctx, log.G(ctx).WithError(err).WithFields(log.Fields{
|
||||||
"id": id,
|
"id": id,
|
||||||
"namespace": namespace,
|
"namespace": namespace,
|
||||||
}))
|
}))
|
||||||
@ -361,7 +360,7 @@ func (r *Runtime) loadTasks(ctx context.Context, ns string) ([]*Task, error) {
|
|||||||
filepath.Join(r.root, ns, id),
|
filepath.Join(r.root, ns, id),
|
||||||
)
|
)
|
||||||
ctx = namespaces.WithNamespace(ctx, ns)
|
ctx = namespaces.WithNamespace(ctx, ns)
|
||||||
ctx = log.WithLogger(ctx, log.G(ctx).WithError(err).WithFields(logrus.Fields{
|
ctx = log.WithLogger(ctx, log.G(ctx).WithError(err).WithFields(log.Fields{
|
||||||
"id": id,
|
"id": id,
|
||||||
"namespace": ns,
|
"namespace": ns,
|
||||||
}))
|
}))
|
||||||
@ -489,7 +488,7 @@ func (r *Runtime) terminate(ctx context.Context, bundle *bundle, ns, id string)
|
|||||||
log.G(ctx).WithError(err).Warnf("delete runtime state %s", id)
|
log.G(ctx).WithError(err).Warnf("delete runtime state %s", id)
|
||||||
}
|
}
|
||||||
if err := mount.Unmount(filepath.Join(bundle.path, "rootfs"), 0); err != nil {
|
if err := mount.Unmount(filepath.Join(bundle.path, "rootfs"), 0); err != nil {
|
||||||
log.G(ctx).WithError(err).WithFields(logrus.Fields{
|
log.G(ctx).WithError(err).WithFields(log.Fields{
|
||||||
"path": bundle.path,
|
"path": bundle.path,
|
||||||
"id": id,
|
"id": id,
|
||||||
}).Warnf("unmount task rootfs")
|
}).Warnf("unmount task rootfs")
|
||||||
|
@ -40,7 +40,6 @@ import (
|
|||||||
shimapi "github.com/containerd/containerd/runtime/v1/shim/v1"
|
shimapi "github.com/containerd/containerd/runtime/v1/shim/v1"
|
||||||
"github.com/containerd/containerd/sys"
|
"github.com/containerd/containerd/sys"
|
||||||
"github.com/containerd/ttrpc"
|
"github.com/containerd/ttrpc"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
exec "golang.org/x/sys/execabs"
|
exec "golang.org/x/sys/execabs"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
@ -115,7 +114,7 @@ func WithStart(binary, address, daemonAddress, cgroup string, debug bool, exitHa
|
|||||||
socket.Close()
|
socket.Close()
|
||||||
RemoveSocket(address)
|
RemoveSocket(address)
|
||||||
}()
|
}()
|
||||||
log.G(ctx).WithFields(logrus.Fields{
|
log.G(ctx).WithFields(log.Fields{
|
||||||
"pid": cmd.Process.Pid,
|
"pid": cmd.Process.Pid,
|
||||||
"address": address,
|
"address": address,
|
||||||
"debug": debug,
|
"debug": debug,
|
||||||
@ -132,7 +131,7 @@ func WithStart(binary, address, daemonAddress, cgroup string, debug bool, exitHa
|
|||||||
if err := setCgroup(cgroup, cmd); err != nil {
|
if err := setCgroup(cgroup, cmd); err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
log.G(ctx).WithFields(logrus.Fields{
|
log.G(ctx).WithFields(log.Fields{
|
||||||
"pid": cmd.Process.Pid,
|
"pid": cmd.Process.Pid,
|
||||||
"address": address,
|
"address": address,
|
||||||
}).Infof("shim placed in cgroup %s", cgroup)
|
}).Infof("shim placed in cgroup %s", cgroup)
|
||||||
|
@ -82,7 +82,7 @@ func NewService(config Config, publisher events.Publisher) (*Service, error) {
|
|||||||
return nil, fmt.Errorf("shim namespace cannot be empty")
|
return nil, fmt.Errorf("shim namespace cannot be empty")
|
||||||
}
|
}
|
||||||
ctx := namespaces.WithNamespace(context.Background(), config.Namespace)
|
ctx := namespaces.WithNamespace(context.Background(), config.Namespace)
|
||||||
ctx = log.WithLogger(ctx, logrus.WithFields(logrus.Fields{
|
ctx = log.WithLogger(ctx, logrus.WithFields(log.Fields{
|
||||||
"namespace": config.Namespace,
|
"namespace": config.Namespace,
|
||||||
"path": config.Path,
|
"path": config.Path,
|
||||||
"pid": os.Getpid(),
|
"pid": os.Getpid(),
|
||||||
|
@ -325,7 +325,7 @@ func run(ctx context.Context, manager Manager, initFunc Init, name string, confi
|
|||||||
if debugFlag {
|
if debugFlag {
|
||||||
logrus.SetLevel(logrus.DebugLevel)
|
logrus.SetLevel(logrus.DebugLevel)
|
||||||
}
|
}
|
||||||
logger := log.G(ctx).WithFields(logrus.Fields{
|
logger := log.G(ctx).WithFields(log.Fields{
|
||||||
"pid": os.Getpid(),
|
"pid": os.Getpid(),
|
||||||
"namespace": namespaceFlag,
|
"namespace": namespaceFlag,
|
||||||
})
|
})
|
||||||
@ -504,7 +504,7 @@ func serve(ctx context.Context, server *ttrpc.Server, signals chan os.Signal, sh
|
|||||||
log.G(ctx).WithError(err).Fatal("containerd-shim: ttrpc server failure")
|
log.G(ctx).WithError(err).Fatal("containerd-shim: ttrpc server failure")
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
logger := log.G(ctx).WithFields(logrus.Fields{
|
logger := log.G(ctx).WithFields(log.Fields{
|
||||||
"pid": os.Getpid(),
|
"pid": os.Getpid(),
|
||||||
"path": path,
|
"path": path,
|
||||||
"namespace": namespaceFlag,
|
"namespace": namespaceFlag,
|
||||||
|
@ -30,7 +30,6 @@ import (
|
|||||||
ptypes "github.com/containerd/containerd/protobuf/types"
|
ptypes "github.com/containerd/containerd/protobuf/types"
|
||||||
digest "github.com/opencontainers/go-digest"
|
digest "github.com/opencontainers/go-digest"
|
||||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
@ -295,7 +294,7 @@ func (s *service) Write(session api.Content_WriteServer) (err error) {
|
|||||||
return status.Errorf(codes.InvalidArgument, "first message must have a reference")
|
return status.Errorf(codes.InvalidArgument, "first message must have a reference")
|
||||||
}
|
}
|
||||||
|
|
||||||
fields := logrus.Fields{
|
fields := log.Fields{
|
||||||
"ref": ref,
|
"ref": ref,
|
||||||
}
|
}
|
||||||
total = req.Total
|
total = req.Total
|
||||||
|
@ -363,7 +363,7 @@ func (b *snapshotter) Remove(ctx context.Context, key string) (err error) {
|
|||||||
if restore { // means failed to commit transaction
|
if restore { // means failed to commit transaction
|
||||||
// Attempt to restore source
|
// Attempt to restore source
|
||||||
if err1 := btrfs.SubvolSnapshot(source, removed, readonly); err1 != nil {
|
if err1 := btrfs.SubvolSnapshot(source, removed, readonly); err1 != nil {
|
||||||
log.G(ctx).WithFields(logrus.Fields{
|
log.G(ctx).WithFields(log.Fields{
|
||||||
logrus.ErrorKey: err1,
|
logrus.ErrorKey: err1,
|
||||||
"subvolume": source,
|
"subvolume": source,
|
||||||
"renamed": removed,
|
"renamed": removed,
|
||||||
|
@ -34,7 +34,6 @@ import (
|
|||||||
"github.com/containerd/containerd/snapshots/devmapper/dmsetup"
|
"github.com/containerd/containerd/snapshots/devmapper/dmsetup"
|
||||||
"github.com/containerd/containerd/snapshots/storage"
|
"github.com/containerd/containerd/snapshots/storage"
|
||||||
"github.com/hashicorp/go-multierror"
|
"github.com/hashicorp/go-multierror"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
exec "golang.org/x/sys/execabs"
|
exec "golang.org/x/sys/execabs"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -201,7 +200,7 @@ func (s *Snapshotter) Mounts(ctx context.Context, key string) ([]mount.Mount, er
|
|||||||
|
|
||||||
// Prepare creates thin device for an active snapshot identified by key
|
// Prepare creates thin device for an active snapshot identified by key
|
||||||
func (s *Snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) {
|
func (s *Snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) {
|
||||||
log.G(ctx).WithFields(logrus.Fields{"key": key, "parent": parent}).Debug("prepare")
|
log.G(ctx).WithFields(log.Fields{"key": key, "parent": parent}).Debug("prepare")
|
||||||
|
|
||||||
var (
|
var (
|
||||||
mounts []mount.Mount
|
mounts []mount.Mount
|
||||||
@ -218,7 +217,7 @@ func (s *Snapshotter) Prepare(ctx context.Context, key, parent string, opts ...s
|
|||||||
|
|
||||||
// View creates readonly thin device for the given snapshot key
|
// View creates readonly thin device for the given snapshot key
|
||||||
func (s *Snapshotter) View(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) {
|
func (s *Snapshotter) View(ctx context.Context, key, parent string, opts ...snapshots.Opt) ([]mount.Mount, error) {
|
||||||
log.G(ctx).WithFields(logrus.Fields{"key": key, "parent": parent}).Debug("view")
|
log.G(ctx).WithFields(log.Fields{"key": key, "parent": parent}).Debug("view")
|
||||||
|
|
||||||
var (
|
var (
|
||||||
mounts []mount.Mount
|
mounts []mount.Mount
|
||||||
@ -237,7 +236,7 @@ func (s *Snapshotter) View(ctx context.Context, key, parent string, opts ...snap
|
|||||||
// Block device unmount operation captures snapshot changes by itself, so no
|
// Block device unmount operation captures snapshot changes by itself, so no
|
||||||
// additional actions needed within Commit operation.
|
// additional actions needed within Commit operation.
|
||||||
func (s *Snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshots.Opt) error {
|
func (s *Snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshots.Opt) error {
|
||||||
log.G(ctx).WithFields(logrus.Fields{"name": name, "key": key}).Debug("commit")
|
log.G(ctx).WithFields(log.Fields{"name": name, "key": key}).Debug("commit")
|
||||||
|
|
||||||
return s.store.WithTransaction(ctx, true, func(ctx context.Context) error {
|
return s.store.WithTransaction(ctx, true, func(ctx context.Context) error {
|
||||||
id, snapInfo, _, err := storage.GetInfo(ctx, key)
|
id, snapInfo, _, err := storage.GetInfo(ctx, key)
|
||||||
|
Loading…
Reference in New Issue
Block a user