Skip to content

Commit 9e8e1c1

Browse files
committed
ctr: Sync code with containerd v1.6.23 ctr
Signed-off-by: Stefan Berger <[email protected]>
1 parent 7d2cca5 commit 9e8e1c1

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

.golangci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ run:
1717
- cmd/ctr/commands/images
1818
- cmd\\ctr\\commands\\run
1919
- cmd\\ctr\\commands\\images
20+
skip-files:
21+
- cmd/ctr/commands/commands.go
22+
- cmd\\ctr\\commands\\commands.go
2023

2124
linters-settings:
2225
depguard:

cmd/ctr/commands/commands.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import (
2424
"strings"
2525

2626
"github.com/containerd/containerd/defaults"
27+
"github.com/containerd/containerd/pkg/atomicfile"
28+
2729
"github.com/urfave/cli"
2830
)
2931

@@ -275,15 +277,14 @@ func WritePidFile(path string, pid int) error {
275277
if err != nil {
276278
return err
277279
}
278-
tempPath := filepath.Join(filepath.Dir(path), fmt.Sprintf(".%s", filepath.Base(path)))
279-
f, err := os.OpenFile(tempPath, os.O_RDWR|os.O_CREATE|os.O_EXCL|os.O_SYNC, 0666)
280+
f, err := atomicfile.New(path, 0o666)
280281
if err != nil {
281282
return err
282283
}
283284
_, err = fmt.Fprintf(f, "%d", pid)
284-
f.Close()
285285
if err != nil {
286+
f.Cancel()
286287
return err
287288
}
288-
return os.Rename(tempPath, path)
289+
return f.Close()
289290
}

cmd/ctr/commands/run/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ var Command = cli.Command{
130130
},
131131
}, append(platformRunFlags,
132132
append(append(append(commands.SnapshotterFlags, []cli.Flag{commands.SnapshotterLabels}...),
133-
commands.ContainerFlags...),flags.ImageDecryptionFlags...)...)...),
133+
commands.ContainerFlags...), flags.ImageDecryptionFlags...)...)...),
134134
Action: func(context *cli.Context) error {
135135
var (
136136
err error

0 commit comments

Comments
 (0)