Skip to content

Commit e347eda

Browse files
committed
fix(compose): release the compose lock before streaming stats
compose stats held the global compose lock until it exited. Without --no-stream it runs until interrupted, so it blocked every other compose command in the meantime. Release the lock before streaming, as compose logs does (#3678). Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
1 parent 0700b23 commit e347eda

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎cmd/nerdctl/compose/compose_stats.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/containerd/nerdctl/v2/pkg/clientutil"
2727
"github.com/containerd/nerdctl/v2/pkg/cmd/compose"
2828
"github.com/containerd/nerdctl/v2/pkg/cmd/container"
29+
"github.com/containerd/nerdctl/v2/pkg/composer"
2930
"github.com/containerd/nerdctl/v2/pkg/containerutil"
3031
)
3132

@@ -108,6 +109,12 @@ func statsAction(cmd *cobra.Command, args []string) error {
108109
return nil
109110
}
110111

112+
// Like compose logs, release the compose lock before streaming. Stats don't need it, and holding
113+
// it until the command exits would block every other compose command in the meantime.
114+
if err := composer.Unlock(); err != nil {
115+
return err
116+
}
117+
111118
return container.Stats(ctx, client, containerIDs, types.ContainerStatsOptions{
112119
Stdout: cmd.OutOrStdout(),
113120
Stderr: cmd.ErrOrStderr(),

0 commit comments

Comments
 (0)