Skip to content

Commit

Permalink
ctr: Sync code with containerd v1.6.23 ctr
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
  • Loading branch information
stefanberger committed Aug 15, 2023
1 parent 7d2cca5 commit 9e8e1c1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ run:
- cmd/ctr/commands/images
- cmd\\ctr\\commands\\run
- cmd\\ctr\\commands\\images
skip-files:
- cmd/ctr/commands/commands.go
- cmd\\ctr\\commands\\commands.go

linters-settings:
depguard:
Expand Down
9 changes: 5 additions & 4 deletions cmd/ctr/commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"strings"

"github.com/containerd/containerd/defaults"
"github.com/containerd/containerd/pkg/atomicfile"

"github.com/urfave/cli"
)

Expand Down Expand Up @@ -275,15 +277,14 @@ func WritePidFile(path string, pid int) error {
if err != nil {
return err
}
tempPath := filepath.Join(filepath.Dir(path), fmt.Sprintf(".%s", filepath.Base(path)))
f, err := os.OpenFile(tempPath, os.O_RDWR|os.O_CREATE|os.O_EXCL|os.O_SYNC, 0666)
f, err := atomicfile.New(path, 0o666)
if err != nil {
return err
}
_, err = fmt.Fprintf(f, "%d", pid)
f.Close()
if err != nil {
f.Cancel()
return err
}
return os.Rename(tempPath, path)
return f.Close()
}
2 changes: 1 addition & 1 deletion cmd/ctr/commands/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ var Command = cli.Command{
},
}, append(platformRunFlags,
append(append(append(commands.SnapshotterFlags, []cli.Flag{commands.SnapshotterLabels}...),
commands.ContainerFlags...),flags.ImageDecryptionFlags...)...)...),
commands.ContainerFlags...), flags.ImageDecryptionFlags...)...)...),
Action: func(context *cli.Context) error {
var (
err error
Expand Down

0 comments on commit 9e8e1c1

Please sign in to comment.