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

Fix remote api logs #7522

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 1 addition & 9 deletions pkg/api/handlers/compat/containers_logs.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package compat

import (
"encoding/binary"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -104,7 +103,6 @@ func LogsFromContainer(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)

var frame strings.Builder
header := make([]byte, 8)
for line := range logChannel {
if _, found := r.URL.Query()["until"]; found {
if line.Time.After(until) {
Expand All @@ -119,12 +117,10 @@ func LogsFromContainer(w http.ResponseWriter, r *http.Request) {
if !query.Stdout {
continue
}
header[0] = 1
case "stderr":
if !query.Stderr {
continue
}
header[0] = 2
default:
// Logging and moving on is the best we can do here. We may have already sent
// a Status and Content-Type to client therefore we can no longer report an error.
Expand All @@ -136,12 +132,8 @@ func LogsFromContainer(w http.ResponseWriter, r *http.Request) {
frame.WriteString(line.Time.Format(time.RFC3339))
frame.WriteString(" ")
}
frame.WriteString(line.Msg)
frame.WriteString(line.Msg + "\n")

binary.BigEndian.PutUint32(header[4:], uint32(frame.Len()))
if _, err := w.Write(header[0:8]); err != nil {
log.Errorf("unable to write log output header: %q", err)
}
if _, err := io.WriteString(w, frame.String()); err != nil {
log.Errorf("unable to write frame string: %q", err)
}
Expand Down