@@ -30,13 +30,11 @@ import (
3030 "github.com/containerd/platforms"
3131
3232 "github.com/containerd/nerdctl/v2/pkg/api/types"
33- "github.com/containerd/nerdctl/v2/pkg/clientutil"
3433 "github.com/containerd/nerdctl/v2/pkg/cmd/volume"
3534 "github.com/containerd/nerdctl/v2/pkg/composer"
3635 "github.com/containerd/nerdctl/v2/pkg/composer/serviceparser"
3736 "github.com/containerd/nerdctl/v2/pkg/imgutil"
3837 "github.com/containerd/nerdctl/v2/pkg/ipfs"
39- "github.com/containerd/nerdctl/v2/pkg/lockutil"
4038 "github.com/containerd/nerdctl/v2/pkg/netutil"
4139 "github.com/containerd/nerdctl/v2/pkg/referenceutil"
4240 "github.com/containerd/nerdctl/v2/pkg/signutil"
@@ -48,20 +46,7 @@ var locked *os.File
4846
4947// New returns a new *composer.Composer.
5048func New (client * containerd.Client , globalOptions types.GlobalCommandOptions , options composer.Options , stdout , stderr io.Writer ) (* composer.Composer , error ) {
51- // Compose right now cannot be made safe to use concurrently, as we shell out to nerdctl for multiple operations,
52- // preventing us from using the lock mechanisms from the API.
53- // This here imposes a global lock, effectively preventing multiple compose commands from being run in parallel and
54- // preventing some of the problems with concurrent execution.
55- // This should be removed once we have better, in-depth solutions to make this concurrency safe.
56- // Note that we do not close the lock explicitly. Instead, the lock will get released when the `locked` global
57- // variable will get collected and the file descriptor closed (eg: when the binary exits).
58- var err error
59- dataStore , err := clientutil .DataStore (globalOptions .DataRoot , globalOptions .Address )
60- if err != nil {
61- return nil , err
62- }
63- locked , err = lockutil .Lock (dataStore )
64- if err != nil {
49+ if err := composer .Lock (globalOptions .DataRoot , globalOptions .Address ); err != nil {
6550 return nil , err
6651 }
6752
0 commit comments