Skip to content

Commit

Permalink
Ensure tar stream completes
Browse files Browse the repository at this point in the history
  • Loading branch information
smarterclayton committed Oct 18, 2015
1 parent ae8068a commit 25df5f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/build/strategies/sti/sti.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"path/filepath"
"regexp"
"strings"
"sync"

"github.com/golang/glog"
"github.com/openshift/source-to-image/pkg/api"
Expand Down Expand Up @@ -407,6 +408,8 @@ func (b *STI) Execute(command string, config *api.Config) error {
}

if !config.LayeredBuild {
wg := sync.WaitGroup{}
wg.Add(1)
uploadDir := filepath.Join(config.WorkingDir, "upload")

// TODO: be able to pass a stream directly to the Docker build to avoid the double temp hit
Expand All @@ -418,11 +421,13 @@ func (b *STI) Execute(command string, config *api.Config) error {
if r := recover(); r != nil {
glog.Errorf("recovered panic: %#v", r)
}
wg.Done()
}()
err = b.tar.CreateTarStream(uploadDir, false, w)
}()

opts.Stdin = r
defer wg.Wait()
}

go func(reader io.Reader) {
Expand Down
1 change: 1 addition & 0 deletions pkg/tar/tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func (t *stiTar) shouldExclude(path string) bool {
// CreateTarStream creates a tar stream on the given writer from
// the given directory while excluding files that match the given
// exclusion pattern.
// TODO: this should encapsulate the goroutine that generates the stream.
func (t *stiTar) CreateTarStream(dir string, includeDirInPath bool, writer io.Writer) error {
tarWriter := tar.NewWriter(writer)
defer tarWriter.Close()
Expand Down

0 comments on commit 25df5f4

Please sign in to comment.