Skip to content

Commit

Permalink
Fix sending packets to server by fixing zstd --adapt argument.
Browse files Browse the repository at this point in the history
  • Loading branch information
gnutix committed Nov 7, 2023
1 parent 05e2cb7 commit 8e139d1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Creating the Alfred node image is done using [Packer](https://www.packer.io/) in

### Dependencies

- bash
- docker
- tar
- zstd
2 changes: 1 addition & 1 deletion client/jobfile/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func evaluateTemplate(source string, dir string, options ReadOptions) (string, e
return strings.Split(s, "\n")
},
"shell": func(script string) string {
cmd := exec.Command("/bin/sh", "-c", script)
cmd := exec.Command("/bin/bash", "-euo", "pipefail", "-c", script)
cmd.Dir = dir
cmd.Stdin = os.Stdin
cmd.Stderr = os.Stderr
Expand Down
4 changes: 3 additions & 1 deletion client/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"io"
"os"
"os/exec"
"strings"

Expand Down Expand Up @@ -116,7 +117,8 @@ func sendImageToServer(cmd *cobra.Command, image string) error {
return nil
case proto.LoadImageResponse_CONTINUE:
// The image does not exist on the server, send it
cmd := exec.Command("/bin/sh", "-c", fmt.Sprintf("docker save '%s' | zstd --compress --adapt --min=5 --max=15", image))
cmd := exec.Command("/bin/bash", "-euo", "pipefail", "-c", fmt.Sprintf("docker save '%s' | zstd --compress --adapt=min=5,max=15", image))
cmd.Stderr = os.Stderr
reader := lo.Must(cmd.StdoutPipe())
if err := cmd.Start(); err != nil {
return fmt.Errorf("docker save: %w", err)
Expand Down
3 changes: 2 additions & 1 deletion provisioner/openstack/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,10 @@ func (n *Node) ensureNodeHasImage(image string) error {
}
defer session.Close()

saveCmd := exec.Command("/bin/sh", "-c", fmt.Sprintf("docker save '%s' | zstd --compress --adapt --min=5 --max=15", image))
saveCmd := exec.Command("/bin/bash", "-euo", "pipefail", "-c", fmt.Sprintf("docker save '%s' | zstd --compress --adapt=min=5,max=15", image))
saveOut := lo.Must(saveCmd.StdoutPipe())
session.Stdin = saveOut
session.Stderr = os.Stderr

if err := saveCmd.Start(); err != nil {
return fmt.Errorf("failed to start docker save: %w", err)
Expand Down
4 changes: 3 additions & 1 deletion server/server_load.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"os"
"os/exec"
"time"

Expand Down Expand Up @@ -54,8 +55,9 @@ func (s *server) LoadImage(srv proto.Alfred_LoadImageServer) (err error) {
}

// Main load loop
cmd := exec.Command("/bin/sh", "-c", "zstd --decompress | docker load")
cmd := exec.Command("/bin/bash", "-euo", "pipefail", "-c", "zstd --decompress | docker load")
cmd.WaitDelay = 10 * time.Second
cmd.Stderr = os.Stderr

writer := lo.Must(cmd.StdinPipe())
if err := cmd.Start(); err != nil {
Expand Down

0 comments on commit 8e139d1

Please sign in to comment.