Skip to content

Commit

Permalink
Remove log package dependency
Browse files Browse the repository at this point in the history
Signed-off-by: Derek McGowan <derek@mcg.dev>
(cherry picked from commit 8b69b76)
Signed-off-by: Kirtana Ashok <kiashok@microsoft.com>
  • Loading branch information
dmcgowan authored and kiashok committed Nov 2, 2023
1 parent b5725e5 commit b16edf6
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 44 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 @@ -13,7 +13,6 @@ import (
"unsafe"

"github.com/Microsoft/go-winio"
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/runtime/v2/task"
"github.com/containerd/ttrpc"
"github.com/containerd/typeurl"
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
8 changes: 5 additions & 3 deletions internal/log/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import (
"net"
"reflect"
"time"

"github.com/containerd/containerd/log"
)

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
35 changes: 18 additions & 17 deletions test/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@ require (
github.com/containerd/cgroups v1.1.0
github.com/containerd/containerd v1.6.23
github.com/containerd/go-runc v1.0.0
github.com/containerd/ttrpc v1.2.1
github.com/containerd/log v0.1.0
github.com/containerd/ttrpc v1.2.2
github.com/containerd/typeurl v1.0.2
github.com/gogo/protobuf v1.3.2
github.com/google/go-containerregistry v0.14.0
github.com/google/go-containerregistry v0.16.1
github.com/kevpar/cri v1.11.1-0.20220302210600-4c5c347230b2
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-rc3
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417
github.com/opencontainers/runtime-tools v0.9.0
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.9.0
github.com/stretchr/testify v1.8.1
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.8.2
go.opencensus.io v0.24.0
golang.org/x/sync v0.1.0
golang.org/x/sys v0.7.0
golang.org/x/sync v0.2.0
golang.org/x/sys v0.8.0
google.golang.org/grpc v1.54.0
k8s.io/cri-api v0.25.0
)
Expand All @@ -39,9 +40,9 @@ require (
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.0-20210816181553-5444fa50b93d // indirect
github.com/docker/cli v23.0.3+incompatible // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/docker v23.0.3+incompatible // indirect
github.com/docker/cli v24.0.0+incompatible // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/docker v24.0.0+incompatible // indirect
github.com/docker/docker-credential-helpers v0.7.0 // indirect
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
github.com/docker/go-units v0.5.0 // indirect
Expand All @@ -56,7 +57,7 @@ require (
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/klauspost/compress v1.16.0 // indirect
github.com/klauspost/compress v1.16.5 // indirect
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
github.com/lestrrat-go/blackmagic v1.0.0 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
Expand All @@ -77,7 +78,7 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect
github.com/vbatts/tar-split v0.11.2 // indirect
github.com/vbatts/tar-split v0.11.3 // indirect
github.com/vektah/gqlparser/v2 v2.4.5 // indirect
github.com/veraison/go-cose v1.0.0-rc.1 // indirect
github.com/vishvananda/netlink v1.2.1-beta.2 // indirect
Expand All @@ -88,12 +89,12 @@ require (
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/yashtewari/glob-intersection v0.1.0 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/tools v0.7.0 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/tools v0.9.1 // indirect
google.golang.org/genproto v0.0.0-20230124163310-31e0e69b6fc2 // indirect
google.golang.org/protobuf v1.29.1 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Expand Down
Loading

0 comments on commit b16edf6

Please sign in to comment.