@@ -30,13 +30,11 @@ import (
30
30
"github.com/containerd/platforms"
31
31
32
32
"github.com/containerd/nerdctl/v2/pkg/api/types"
33
- "github.com/containerd/nerdctl/v2/pkg/clientutil"
34
33
"github.com/containerd/nerdctl/v2/pkg/cmd/volume"
35
34
"github.com/containerd/nerdctl/v2/pkg/composer"
36
35
"github.com/containerd/nerdctl/v2/pkg/composer/serviceparser"
37
36
"github.com/containerd/nerdctl/v2/pkg/imgutil"
38
37
"github.com/containerd/nerdctl/v2/pkg/ipfs"
39
- "github.com/containerd/nerdctl/v2/pkg/lockutil"
40
38
"github.com/containerd/nerdctl/v2/pkg/netutil"
41
39
"github.com/containerd/nerdctl/v2/pkg/referenceutil"
42
40
"github.com/containerd/nerdctl/v2/pkg/signutil"
@@ -48,20 +46,7 @@ var locked *os.File
48
46
49
47
// New returns a new *composer.Composer.
50
48
func 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 {
65
50
return nil , err
66
51
}
67
52
0 commit comments