Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a special-cased runtime handler for dockershim #78323

Merged
merged 1 commit into from May 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/kubelet/dockershim/docker_sandbox.go
Expand Up @@ -96,7 +96,7 @@ func (ds *dockerService) RunPodSandbox(ctx context.Context, r *runtimeapi.RunPod
}

// Step 2: Create the sandbox container.
if r.GetRuntimeHandler() != "" {
if r.GetRuntimeHandler() != "" && r.GetRuntimeHandler() != runtimeName {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if r.GetRuntimeHandler() != "" && r.GetRuntimeHandler() != runtimeName {
runtimeHandlerEmpty := r.GetRuntimeHandler() == ""
runtimeHandlerIsDocker := r.GetRuntimeHandler() == runtimeName
if !runtimeHandlerEmpty && !runtimeHandlerIsDocker {

small nit, but could this be slightly more readable with a descriptive variable name?

return nil, fmt.Errorf("RuntimeHandler %q not supported", r.GetRuntimeHandler())
}
createConfig, err := ds.makeSandboxDockerConfig(config, image)
Expand Down
10 changes: 8 additions & 2 deletions test/e2e/common/runtimeclass.go
Expand Up @@ -38,6 +38,9 @@ const (
// PreconfiguredRuntimeHandler is the name of the runtime handler that is expected to be
// preconfigured in the test environment.
PreconfiguredRuntimeHandler = "test-handler"
// DockerRuntimeHandler is a hardcoded runtime handler that is accepted by dockershim, and
// treated equivalently to a nil runtime handler.
DockerRuntimeHandler = "docker"
)

var _ = Describe("[sig-node] RuntimeClass", func() {
Expand All @@ -59,9 +62,12 @@ var _ = Describe("[sig-node] RuntimeClass", func() {
// This test requires that the PreconfiguredRuntimeHandler has already been set up on nodes.
It("should run a Pod requesting a RuntimeClass with a configured handler [NodeFeature:RuntimeHandler]", func() {
// The built-in docker runtime does not support configuring runtime handlers.
framework.SkipIfContainerRuntimeIs("docker")
handler := PreconfiguredRuntimeHandler
if framework.TestContext.ContainerRuntime == "docker" {
handler = DockerRuntimeHandler
}

rcName := createRuntimeClass(f, "preconfigured-handler", PreconfiguredRuntimeHandler)
rcName := createRuntimeClass(f, "preconfigured-handler", handler)
pod := createRuntimeClassPod(f, rcName)
expectPodSuccess(f, pod)
})
Expand Down