mirror of
https://github.com/containerd/containerd.git
synced 2026-11-06 13:27:16 +00:00
A runtime handler can name its shim binary with runtime_path. The task service replaces the runtime name with that path and the podsandbox controller passes it to the pause task, but the shim sandboxer never saw it: CRI stored only the runtime type in the sandbox record and the shim controller started the binary resolved from that type. Add a RuntimePath create option to the sandbox controller, have the shim controller start that binary when it is set (the shim manager already accepts an absolute path in place of a runtime name), and pass it from CRI. The gRPC proxy cannot carry it, since ControllerCreateRequest has no field for it, so a remote sandboxer logs a warning instead. Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
43 lines
1.4 KiB
Go
43 lines
1.4 KiB
Go
/*
|
|
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 sandbox
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/containerd/errdefs"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestWithRuntimePath(t *testing.T) {
|
|
var opts CreateOptions
|
|
require.NoError(t, WithRuntimePath("")(&opts))
|
|
assert.Empty(t, opts.RuntimePath, "an empty path keeps the runtime name")
|
|
|
|
// An absolute path of this platform (a leading slash is not absolute on
|
|
// Windows).
|
|
abs := filepath.Join(t.TempDir(), "containerd-shim-example-v1")
|
|
require.NoError(t, WithRuntimePath(abs)(&opts))
|
|
assert.Equal(t, abs, opts.RuntimePath)
|
|
|
|
err := WithRuntimePath("containerd-shim-example-v1")(&opts)
|
|
require.Error(t, err, "a relative path would be taken for a runtime name")
|
|
assert.True(t, errdefs.IsInvalidArgument(err))
|
|
}
|