Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRI log parser improvements #232

Merged
merged 2 commits into from
Feb 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions pkg/validate/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package validate
import (
"bufio"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
Expand Down Expand Up @@ -429,15 +430,19 @@ func parseDockerJSONLog(log []byte, msg *logMessage) {
// 2016-10-06T00:17:09.669794202Z stdout P The content of the log entry 1
// 2016-10-06T00:17:10.113242941Z stderr F The content of the log entry 2
func parseCRILog(log string, msg *logMessage) {
timeStamp, err := time.Parse(time.RFC3339Nano, strings.Fields(log)[0])
logMessage := strings.SplitN(log, " ", 4)
if len(log) < 4 {
err := errors.New("invalid CRI log")
framework.ExpectNoError(err, "failed to parse CRI log: %v", err)
}
timeStamp, err := time.Parse(time.RFC3339Nano, logMessage[0])
framework.ExpectNoError(err, "failed to parse timeStamp: %v", err)
stream := strings.Fields(log)[1]
// Skip the tag field.
logMessage := strings.Fields(log)[3:]
stream := logMessage[1]

msg.timestamp = timeStamp
msg.stream = streamType(stream)
msg.log = []byte(strings.Join(logMessage, " ") + "\n")
// Skip the tag field.
msg.log = []byte(logMessage[3] + "\n")
}

// parseLogLine parses log by row.
Expand Down