Skip to content

Commit

Permalink
Merge pull request #1898 from dmcgowan/update-containerd-log-dependency
Browse files Browse the repository at this point in the history
Update containerd log dependency
  • Loading branch information
kevpar authored Sep 29, 2023
2 parents 4dc2c8b + 8b69b76 commit a4b4545
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
3 changes: 1 addition & 2 deletions cmd/containerd-shim-runhcs-v1/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (

"github.com/Microsoft/go-winio"
task "github.com/containerd/containerd/api/runtime/task/v2"
"github.com/containerd/containerd/log"
"github.com/containerd/ttrpc"
typeurl "github.com/containerd/typeurl/v2"
"github.com/pkg/errors"
Expand Down Expand Up @@ -109,7 +108,7 @@ var serveCommand = cli.Command{
switch shimOpts.DebugType {
case runhcsopts.Options_NPIPE:
logrus.SetFormatter(&logrus.TextFormatter{
TimestampFormat: log.RFC3339NanoFixed,
TimestampFormat: hcslog.TimeFormat,
FullTimestamp: true,
})
// Setup the log listener
Expand Down
7 changes: 5 additions & 2 deletions internal/log/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ import (
"reflect"
"time"

"github.com/containerd/containerd/log"
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
)

const TimeFormat = log.RFC3339NanoFixed
// TimeFormat is [time.RFC3339Nano] with nanoseconds padded using
// zeros to ensure the formatted time is always the same number of
// characters.
// Based on RFC3339NanoFixed from github.com/containerd/log
const TimeFormat = "2006-01-02T15:04:05.000000000Z07:00"

func FormatTime(t time.Time) string {
return t.Format(TimeFormat)
Expand Down
5 changes: 2 additions & 3 deletions internal/log/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"time"

"github.com/Microsoft/hcsshim/internal/logfields"
"github.com/containerd/containerd/log"
"github.com/sirupsen/logrus"
"go.opencensus.io/trace"
)
Expand All @@ -30,7 +29,7 @@ type Hook struct {
// An empty string disables formatting.
// When disabled, the fall back will the JSON encoding, if enabled.
//
// Default is [github.com/containerd/containerd/log.RFC3339NanoFixed].
// Default is [TimeFormat].
TimeFormat string

// Duration format converts a [time.Duration] fields to an appropriate encoding.
Expand All @@ -49,7 +48,7 @@ var _ logrus.Hook = &Hook{}

func NewHook() *Hook {
return &Hook{
TimeFormat: log.RFC3339NanoFixed,
TimeFormat: TimeFormat,
DurationFormat: DurationFormatString,
AddSpanContext: true,
}
Expand Down
2 changes: 1 addition & 1 deletion test/cri-containerd/runpodsandbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/Microsoft/hcsshim/test/pkg/definitions/shimdiag"
"github.com/Microsoft/hcsshim/test/pkg/require"
testuvm "github.com/Microsoft/hcsshim/test/pkg/uvm"
"github.com/containerd/containerd/log"
"github.com/containerd/log"
"golang.org/x/sys/windows"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
)
Expand Down
1 change: 1 addition & 0 deletions test/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/containerd/cgroups/v3 v3.0.2
github.com/containerd/containerd v1.7.0
github.com/containerd/go-runc v1.0.0
github.com/containerd/log v0.1.0
github.com/containerd/ttrpc v1.2.2
github.com/containerd/typeurl/v2 v2.1.1
github.com/google/go-containerregistry v0.16.1
Expand Down
2 changes: 2 additions & 0 deletions test/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,8 @@ github.com/containerd/imgcrypt v1.1.1/go.mod h1:xpLnwiQmEUJPvQoAapeb2SNCxz7Xr6PJ
github.com/containerd/imgcrypt v1.1.3/go.mod h1:/TPA1GIDXMzbj01yd8pIbQiLdQxed5ue1wb8bP7PQu4=
github.com/containerd/imgcrypt v1.1.4/go.mod h1:LorQnPtzL/T0IyCeftcsMEO7AqxUDbdO8j/tSUpgxvo=
github.com/containerd/imgcrypt v1.1.7/go.mod h1:FD8gqIcX5aTotCtOmjeCsi3A1dHmTZpnMISGKSczt4k=
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
github.com/containerd/nri v0.0.0-20201007170849-eb1350a75164/go.mod h1:+2wGSDGFYfE5+So4M5syatU0N0f0LbWpuqyMi4/BE8c=
github.com/containerd/nri v0.0.0-20210316161719-dbaa18c31c14/go.mod h1:lmxnXF6oMkbqs39FiCt1s0R2HSMhcLel9vNL3m4AaeY=
github.com/containerd/nri v0.1.0/go.mod h1:lmxnXF6oMkbqs39FiCt1s0R2HSMhcLel9vNL3m4AaeY=
Expand Down

0 comments on commit a4b4545

Please sign in to comment.