Commit 73688457 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Merge branch 'fix-issue-249' into 'master'

Gather gitlab-zip-cat/metadata stderr and log output in the current context

Closes #249

See merge request gitlab-org/gitlab-workhorse!498
parents 2cbc8edf f579dd47
---
title: Gather gitlab-zip-cat/metadata stderr and log output in the current context
merge_request: 498
author: Georges-Etienne Legendre
type: fixed
......@@ -11,6 +11,7 @@ import (
"syscall"
"github.com/prometheus/client_golang/prometheus"
"gitlab.com/gitlab-org/labkit/log"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/api"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/filestore"
......@@ -53,7 +54,7 @@ func (a *artifactsUploadProcessor) generateMetadataFromZip(ctx context.Context,
}
zipMd := exec.CommandContext(ctx, "gitlab-zip-metadata", fileName)
zipMd.Stderr = os.Stderr
zipMd.Stderr = log.ContextLogger(ctx).Writer()
zipMd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
zipMd.Stdout = metaWriter
......
......@@ -2,6 +2,7 @@ package artifacts
import (
"bufio"
"context"
"fmt"
"io"
"mime"
......@@ -43,7 +44,7 @@ func (e *entry) Inject(w http.ResponseWriter, r *http.Request, sendData string)
return
}
err := unpackFileFromZip(params.Archive, params.Entry, w.Header(), w)
err := unpackFileFromZip(r.Context(), params.Archive, params.Entry, w.Header(), w)
if os.IsNotExist(err) {
http.NotFound(w, r)
......@@ -60,7 +61,7 @@ func detectFileContentType(fileName string) string {
return contentType
}
func unpackFileFromZip(archivePath, encodedFilename string, headers http.Header, output io.Writer) error {
func unpackFileFromZip(ctx context.Context, archivePath, encodedFilename string, headers http.Header, output io.Writer) error {
fileName, err := zipartifacts.DecodeFileEntry(encodedFilename)
if err != nil {
return err
......@@ -71,7 +72,7 @@ func unpackFileFromZip(archivePath, encodedFilename string, headers http.Header,
"ARCHIVE_PATH="+archivePath,
"ENCODED_FILE_NAME="+encodedFilename,
)
catFile.Stderr = os.Stderr
catFile.Stderr = log.ContextLogger(ctx).Writer()
catFile.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
stdout, err := catFile.StdoutPipe()
if err != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment