fix(libstack): add a different timeout for WaitForStatus BE-11376 (#119)

release/2.24
andres-portainer 2 weeks ago committed by GitHub
parent 5a451b2035
commit b2eb4388fd

@ -8,6 +8,7 @@ import (
"path/filepath" "path/filepath"
"slices" "slices"
"strings" "strings"
"sync"
"github.com/portainer/portainer/pkg/libstack" "github.com/portainer/portainer/pkg/libstack"
@ -21,6 +22,8 @@ import (
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
) )
var mu sync.Mutex
func withCli( func withCli(
ctx context.Context, ctx context.Context,
options libstack.Options, options libstack.Options,
@ -47,9 +50,12 @@ func withCli(
opts.ConfigDir = tempDir opts.ConfigDir = tempDir
mu.Lock()
if err := cli.Initialize(opts); err != nil { if err := cli.Initialize(opts); err != nil {
mu.Unlock()
return fmt.Errorf("unable to initialize the Docker client: %w", err) return fmt.Errorf("unable to initialize the Docker client: %w", err)
} }
mu.Unlock()
defer cli.Client().Close() defer cli.Client().Close()
for _, r := range options.Registries { for _, r := range options.Registries {

@ -130,7 +130,11 @@ func (c *ComposeDeployer) WaitForStatus(ctx context.Context, name string, status
if err := withComposeService(ctx, nil, libstack.Options{ProjectName: name}, func(composeService api.Service, project *types.Project) error { if err := withComposeService(ctx, nil, libstack.Options{ProjectName: name}, func(composeService api.Service, project *types.Project) error {
var err error var err error
containerSummaries, err = composeService.Ps(ctx, name, api.PsOptions{All: true})
psCtx, cancelFunc := context.WithTimeout(context.Background(), time.Minute)
defer cancelFunc()
containerSummaries, err = composeService.Ps(psCtx, name, api.PsOptions{All: true})
return err return err
}); err != nil { }); err != nil {

Loading…
Cancel
Save