Commit f579dd47 authored by Georges-Etienne Legendre's avatar Georges-Etienne Legendre Committed by Jacob Vosmaer

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

parent 2cbc8edf
---
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 ( ...@@ -11,6 +11,7 @@ import (
"syscall" "syscall"
"github.com/prometheus/client_golang/prometheus" "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/api"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/filestore" "gitlab.com/gitlab-org/gitlab-workhorse/internal/filestore"
...@@ -53,7 +54,7 @@ func (a *artifactsUploadProcessor) generateMetadataFromZip(ctx context.Context, ...@@ -53,7 +54,7 @@ func (a *artifactsUploadProcessor) generateMetadataFromZip(ctx context.Context,
} }
zipMd := exec.CommandContext(ctx, "gitlab-zip-metadata", fileName) 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.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
zipMd.Stdout = metaWriter zipMd.Stdout = metaWriter
......
...@@ -2,6 +2,7 @@ package artifacts ...@@ -2,6 +2,7 @@ package artifacts
import ( import (
"bufio" "bufio"
"context"
"fmt" "fmt"
"io" "io"
"mime" "mime"
...@@ -43,7 +44,7 @@ func (e *entry) Inject(w http.ResponseWriter, r *http.Request, sendData string) ...@@ -43,7 +44,7 @@ func (e *entry) Inject(w http.ResponseWriter, r *http.Request, sendData string)
return 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) { if os.IsNotExist(err) {
http.NotFound(w, r) http.NotFound(w, r)
...@@ -60,7 +61,7 @@ func detectFileContentType(fileName string) string { ...@@ -60,7 +61,7 @@ func detectFileContentType(fileName string) string {
return contentType 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) fileName, err := zipartifacts.DecodeFileEntry(encodedFilename)
if err != nil { if err != nil {
return err return err
...@@ -71,7 +72,7 @@ func unpackFileFromZip(archivePath, encodedFilename string, headers http.Header, ...@@ -71,7 +72,7 @@ func unpackFileFromZip(archivePath, encodedFilename string, headers http.Header,
"ARCHIVE_PATH="+archivePath, "ARCHIVE_PATH="+archivePath,
"ENCODED_FILE_NAME="+encodedFilename, "ENCODED_FILE_NAME="+encodedFilename,
) )
catFile.Stderr = os.Stderr catFile.Stderr = log.ContextLogger(ctx).Writer()
catFile.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} catFile.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
stdout, err := catFile.StdoutPipe() stdout, err := catFile.StdoutPipe()
if err != nil { 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