Skip to content

Commit

Permalink
feat: copy back stdout and stderr on scene failure
Browse files Browse the repository at this point in the history
Signed-off-by: Jason C. Nucciarone <[email protected]>
  • Loading branch information
NucciTheBoss committed Jun 26, 2024
1 parent 23afc1d commit 431d81f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions internal/provider/lxd/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

lxd "github.com/canonical/lxd/client"
"github.com/canonical/lxd/shared/api"
"github.com/dsnet/golib/memfile"
"github.com/google/uuid"
"github.com/nuccitheboss/gambol/internal/storage"
)
Expand Down Expand Up @@ -166,11 +167,15 @@ func (p *Driver) ExecInstance(id string, script string) error {
return err
}

stdout := memfile.New([]byte(""))
execRequest := api.InstanceExecPost{
Command: []string{"bash", "/root/.gambol/run"},
RecordOutput: true,
Command: []string{"bash", "/root/.gambol/run"},
WaitForWS: true,
}
execArgs := lxd.InstanceExecArgs{
Stdout: stdout,
Stderr: stdout,
}
execArgs := lxd.InstanceExecArgs{}
op, err := p.server.ExecInstance(id, execRequest, &execArgs)
if err != nil {
return err
Expand All @@ -182,6 +187,8 @@ func (p *Driver) ExecInstance(id string, script string) error {
}

if returnCode := op.Get().Metadata["return"]; returnCode != float64(0) {
fmt.Println("error encountered during scene execution:")
fmt.Println(string(stdout.Bytes()))
return errors.New("scene failed")
}

Expand Down

0 comments on commit 431d81f

Please sign in to comment.