freebsd: don't run shim delete in deleted dir
fork/exec can fail and log a warning like this in containerd's log: failed to clean up after shim disconnected error=": fork/exec /usr/local/bin/containerd-shim-[my-shim]: no such file or directory" id=test namespace=default Passing the bundle path on the command line allows the shim delete command to run successfully. Signed-off-by: Samuel Karp <me@samuelkarp.com>
This commit is contained in:
parent
1f4192daf4
commit
b431fe4fc0
@ -133,11 +133,13 @@ func (b *binary) Start(ctx context.Context, opts *types.Any, onClose func()) (_
|
|||||||
func (b *binary) Delete(ctx context.Context) (*runtime.Exit, error) {
|
func (b *binary) Delete(ctx context.Context) (*runtime.Exit, error) {
|
||||||
log.G(ctx).Info("cleaning up dead shim")
|
log.G(ctx).Info("cleaning up dead shim")
|
||||||
|
|
||||||
// Windows cannot delete the current working directory while an
|
// On Windows and FreeBSD, the current working directory of the shim should
|
||||||
// executable is in use with it. For the cleanup case we invoke with the
|
// not be the bundle path during the delete operation. Instead, we invoke
|
||||||
// default work dir and forward the bundle path on the cmdline.
|
// with the default work dir and forward the bundle path on the cmdline.
|
||||||
|
// Windows cannot delete the current working directory while an executable
|
||||||
|
// is in use with it. On FreeBSD, fork/exec can fail.
|
||||||
var bundlePath string
|
var bundlePath string
|
||||||
if gruntime.GOOS != "windows" {
|
if gruntime.GOOS != "windows" && gruntime.GOOS != "freebsd" {
|
||||||
bundlePath = b.bundle.Path
|
bundlePath = b.bundle.Path
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,6 +162,7 @@ func (b *binary) Delete(ctx context.Context) (*runtime.Exit, error) {
|
|||||||
cmd.Stdout = out
|
cmd.Stdout = out
|
||||||
cmd.Stderr = errb
|
cmd.Stderr = errb
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
|
log.G(ctx).WithField("cmd", cmd).WithError(err).Error("failed to delete")
|
||||||
return nil, errors.Wrapf(err, "%s", errb.String())
|
return nil, errors.Wrapf(err, "%s", errb.String())
|
||||||
}
|
}
|
||||||
s := errb.String()
|
s := errb.String()
|
||||||
|
Loading…
Reference in New Issue
Block a user