Skip to content

Commit

Permalink
Merge pull request #89013 from dims/copy-jsonlog-from-docker/docker-l…
Browse files Browse the repository at this point in the history
…ocally

Copy jsonlog from docker/docker locally
  • Loading branch information
k8s-ci-robot committed Mar 19, 2020
2 parents 2c8ef3b + 825f99c commit e74ad38
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 204 deletions.
1 change: 0 additions & 1 deletion pkg/kubelet/kuberuntime/logs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ go_library(
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/cri-api/pkg/apis:go_default_library",
"//staging/src/k8s.io/cri-api/pkg/apis/runtime/v1alpha2:go_default_library",
"//vendor/github.com/docker/docker/daemon/logger/jsonfilelog/jsonlog:go_default_library",
"//vendor/github.com/fsnotify/fsnotify:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
],
Expand Down
16 changes: 13 additions & 3 deletions pkg/kubelet/kuberuntime/logs/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"path/filepath"
"time"

"github.com/docker/docker/daemon/logger/jsonfilelog/jsonlog"
"github.com/fsnotify/fsnotify"
"k8s.io/klog"

Expand Down Expand Up @@ -165,13 +164,24 @@ func parseCRILog(log []byte, msg *logMessage) error {
return nil
}

// jsonLog is a log message, typically a single entry from a given log stream.
// since the data structure is originally from docker, we should be careful to
// with any changes to jsonLog
type jsonLog struct {
// Log is the log message
Log string `json:"log,omitempty"`
// Stream is the log source
Stream string `json:"stream,omitempty"`
// Created is the created timestamp of log
Created time.Time `json:"time"`
}

// parseDockerJSONLog parses logs in Docker JSON log format. Docker JSON log format
// example:
// {"log":"content 1","stream":"stdout","time":"2016-10-20T18:39:20.57606443Z"}
// {"log":"content 2","stream":"stderr","time":"2016-10-20T18:39:20.57606444Z"}
func parseDockerJSONLog(log []byte, msg *logMessage) error {
var l = &jsonlog.JSONLog{}
l.Reset()
var l = &jsonLog{}

// TODO: JSON decoding is fairly expensive, we should evaluate this.
if err := json.Unmarshal(log, l); err != nil {
Expand Down
1 change: 0 additions & 1 deletion vendor/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ filegroup(
"//vendor/github.com/docker/distribution/registry/api/errcode:all-srcs",
"//vendor/github.com/docker/docker/api:all-srcs",
"//vendor/github.com/docker/docker/client:all-srcs",
"//vendor/github.com/docker/docker/daemon/logger/jsonfilelog/jsonlog:all-srcs",
"//vendor/github.com/docker/docker/errdefs:all-srcs",
"//vendor/github.com/docker/docker/pkg/jsonmessage:all-srcs",
"//vendor/github.com/docker/docker/pkg/mount:all-srcs",
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ github.com/docker/docker/api/types/time
github.com/docker/docker/api/types/versions
github.com/docker/docker/api/types/volume
github.com/docker/docker/client
github.com/docker/docker/daemon/logger/jsonfilelog/jsonlog
github.com/docker/docker/errdefs
github.com/docker/docker/pkg/jsonmessage
github.com/docker/docker/pkg/mount
Expand Down

0 comments on commit e74ad38

Please sign in to comment.