Skip to content

Commit

Permalink
test: add lock around executing helm binary
Browse files Browse the repository at this point in the history
Signed-off-by: Russell Centanni <russell.centanni@gmail.com>
  • Loading branch information
lizardruss committed Jan 12, 2024
1 parent 26edf30 commit bbee345
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion e2e/tests/ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ var _ = DevSpaceDescribe("ssh", func() {
framework.ExpectNoError(err)
})

ginkgo.It("devspace dev should NOT start an SSH service when disabled with a variable", ginkgo.FlakeAttempts(3), func(ctx context.Context) {
ginkgo.It("devspace dev should NOT start an SSH service when disabled with a variable", func(ctx context.Context) {
tempDir, err := framework.CopyToTempDir("tests/ssh/testdata/ssh-variable")
framework.ExpectNoError(err)
ginkgo.DeferCleanup(framework.CleanupTempDir, initialDir, tempDir)
Expand Down
5 changes: 5 additions & 0 deletions pkg/devspace/helm/generic/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"strings"
"sync"

"github.com/loft-sh/devspace/pkg/devspace/config/constants"
devspacecontext "github.com/loft-sh/devspace/pkg/devspace/context"
Expand Down Expand Up @@ -42,6 +43,7 @@ type client struct {
log log.Logger
extract extract.Extract
downloader downloader.Downloader
execLock sync.Mutex

helmPath string
}
Expand Down Expand Up @@ -80,8 +82,11 @@ func (c *client) Exec(ctx devspacecontext.Context, args []string) ([]byte, error
c.log.Debugf("Execute '%s %s' in directory %s", c.helmPath, strings.Join(args, " "), ctx.WorkingDir())
}

c.execLock.Lock()
defer c.execLock.Unlock()
result, err := command.Output(ctx.Context(), ctx.WorkingDir(), ctx.Environ(), c.helmPath, args...)
if err != nil {
c.log.Debugf("OUTPUT: %s", string(result))
return nil, fmt.Errorf("%s %v", string(result), err)
}

Expand Down

0 comments on commit bbee345

Please sign in to comment.