Skip to content

Commit

Permalink
test/framework fix docker pod log collector
Browse files Browse the repository at this point in the history
When using ExecContainerInput to create the tarball, the same buffer
got used for stdout and stderr. This broke the tarball which resulted
in not extracting the files.
  • Loading branch information
chrischdi committed May 10, 2023
1 parent 1f15346 commit b474354
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion test/framework/docker_logcollector.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package framework

import (
"bytes"
"context"
"fmt"
"os"
Expand Down Expand Up @@ -106,8 +107,10 @@ func (k DockerLogCollector) collectLogsFromNode(ctx context.Context, outputPath

defer os.Remove(tempfileName)

var execErr string
execConfig := container.ExecContainerInput{
OutputBuffer: f,
ErrorBuffer: bytes.NewBufferString(execErr),
}
err = containerRuntime.ExecContainer(
ctx,
Expand All @@ -116,7 +119,7 @@ func (k DockerLogCollector) collectLogsFromNode(ctx context.Context, outputPath
"tar", "--hard-dereference", "--dereference", "--directory", containerDir, "--create", "--file", "-", ".",
)
if err != nil {
return err
return errors.Wrapf(err, execErr)
}

err = os.MkdirAll(outputDir, os.ModePerm)
Expand Down

0 comments on commit b474354

Please sign in to comment.