Skip to content
Draft
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,8 @@ hold it after the job is executed.
Residual content is fetched whether the job finishes successfully or not,
and even if some of the provided paths are missing.

By default artifacts are fetched and compressed using `xz`. If this is
unavailable use the `-tar-filter` flag specifying an option, eg `gzip`.

<a name="lxd"/>

Expand Down
6 changes: 6 additions & 0 deletions cmd/spread/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var (
restore = flag.Bool("restore", false, "Run only the restore scripts")
discard = flag.Bool("discard", false, "Discard reused servers without running")
artifacts = flag.String("artifacts", "", "Where to store task artifacts")
tarFilter = flag.String("tar-filter", "xz", "Which tar filter to use for artifacts xz|gzip|bz2")
seed = flag.Int64("seed", 0, "Seed for job order permutation")
repeat = flag.Int("repeat", 0, "Number of times to repeat each task")
garbageCollect = flag.Bool("gc", false, "Garbage collect backend resources when possible")
Expand Down Expand Up @@ -79,6 +80,10 @@ func run() error {
}
}

tarfilter, ok := spread.TarFilters[*tarFilter]
if !ok {
return fmt.Errorf("unknown tar-filter %q", *tarFilter)
}
options := &spread.Options{
Password: password,
Filter: filter,
Expand All @@ -93,6 +98,7 @@ func run() error {
Restore: *restore,
Discard: *discard,
Artifacts: *artifacts,
TarFilter: tarfilter,
Seed: *seed,
Repeat: *repeat,
GarbageCollect: *garbageCollect,
Expand Down
4 changes: 2 additions & 2 deletions spread/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ func (c *Client) SendTar(tar io.Reader, unpackDir string) error {
return nil
}

func (c *Client) RecvTar(packDir string, include []string, tar io.Writer) error {
func (c *Client) RecvTar(packDir string, include []string, tarFilter TarFilter, tar io.Writer) error {
session, err := c.sshc.NewSession()
if err != nil {
return err
Expand All @@ -657,7 +657,7 @@ func (c *Client) RecvTar(packDir string, include []string, tar io.Writer) error
var stderr safeBuffer
session.Stdout = tar
session.Stderr = &stderr
cmd := fmt.Sprintf(`%s/bin/tar -C %q -cJ --sort=name --ignore-failed-read -- %s`, c.sudo(), packDir, strings.Join(args, " "))
cmd := fmt.Sprintf(`%s/bin/tar -C %q -c%s --sort=name --ignore-failed-read -- %s`, c.sudo(), packDir, tarFilter, strings.Join(args, " "))
err = c.runCommand(session, cmd, nil, &stderr)
if err != nil {
return outputErr(stderr.Bytes(), err)
Expand Down
19 changes: 17 additions & 2 deletions spread/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ import (
"math/rand"
)

type TarFilter string

const (
XZ TarFilter = "J"
GZip TarFilter = "z"
Bzip2 TarFilter = "j"
)

var TarFilters map[string]TarFilter = map[string]TarFilter{
"xz": XZ,
"gzip": GZip,
"bz2": Bzip2,
}

type Options struct {
Password string
Filter Filter
Expand All @@ -32,6 +46,7 @@ type Options struct {
Resend bool
Discard bool
Artifacts string
TarFilter TarFilter
Seed int64
Repeat int
GarbageCollect bool
Expand Down Expand Up @@ -827,7 +842,7 @@ func (r *Runner) fetchArtifacts(client *Client, job *Job) error {
tarr, tarw := io.Pipe()

var stderr bytes.Buffer
cmd := exec.Command("tar", "xJ")
cmd := exec.Command("tar", "x"+string(r.options.TarFilter))
cmd.Dir = localDir
cmd.Stdin = tarr
cmd.Stderr = &stderr
Expand All @@ -839,7 +854,7 @@ func (r *Runner) fetchArtifacts(client *Client, job *Job) error {
printf("Fetching artifacts of %s...", job)

remoteDir := filepath.Join(r.project.RemotePath, job.Task.Name)
err = client.RecvTar(remoteDir, job.Task.Artifacts, tarw)
err = client.RecvTar(remoteDir, job.Task.Artifacts, r.options.TarFilter, tarw)
tarw.Close()
terr := cmd.Wait()

Expand Down