diff --git a/runtime/v2/binary.go b/runtime/v2/binary.go index 51845bfee..5a62a86b6 100644 --- a/runtime/v2/binary.go +++ b/runtime/v2/binary.go @@ -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) { log.G(ctx).Info("cleaning up dead shim") - // Windows cannot delete the current working directory while an - // executable is in use with it. For the cleanup case we invoke with the - // default work dir and forward the bundle path on the cmdline. + // On Windows and FreeBSD, the current working directory of the shim should + // not be the bundle path during the delete operation. Instead, we invoke + // 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 - if gruntime.GOOS != "windows" { + if gruntime.GOOS != "windows" && gruntime.GOOS != "freebsd" { bundlePath = b.bundle.Path } @@ -160,6 +162,7 @@ func (b *binary) Delete(ctx context.Context) (*runtime.Exit, error) { cmd.Stdout = out cmd.Stderr = errb 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()) } s := errb.String() diff --git a/services/tasks/local_freebsd.go b/services/tasks/local_freebsd.go new file mode 100644 index 000000000..d206b8f25 --- /dev/null +++ b/services/tasks/local_freebsd.go @@ -0,0 +1,35 @@ +// +build freebsd + +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package tasks + +import ( + "github.com/containerd/containerd/plugin" + "github.com/containerd/containerd/runtime" +) + +var tasksServiceRequires = []plugin.Type{ + plugin.RuntimePluginV2, + plugin.MetadataPlugin, + plugin.TaskMonitorPlugin, +} + +// loadV1Runtimes on FreeBSD returns an empty map. There are no v1 runtimes +func loadV1Runtimes(ic *plugin.InitContext) (map[string]runtime.PlatformRuntime, error) { + return make(map[string]runtime.PlatformRuntime), nil +} diff --git a/services/tasks/local_unix.go b/services/tasks/local_unix.go index 3818e9282..2879df0c4 100644 --- a/services/tasks/local_unix.go +++ b/services/tasks/local_unix.go @@ -1,4 +1,4 @@ -// +build !windows +// +build !windows,!freebsd /* Copyright The containerd Authors.