Skip to content

Conversation

@Iceber
Copy link
Member

@Iceber Iceber commented Mar 6, 2023

fix: #8207

if ociRuntime.Path != "" {
taskOpts = append(taskOpts, containerd.WithRuntimePath(ociRuntime.Path))
}

Although the runtime path is set in the cri server, the runtime path is not set to the request in the NewTask

Add TaskInfo.RuntimePath field to prevent overwriting TaskInfo.runtime, directly overwriting TaskInfo.runtime may cause exceptions to other NewTaskOpts

@k8s-ci-robot
Copy link

Hi @Iceber. Thanks for your PR.

I'm waiting for a containerd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

// RuntimePath is an absolute path that can be used to overwrite path
// to a shim runtime binary.
RuntimePath string

Copy link
Member

Choose a reason for hiding this comment

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

runtime field is now unused? Do we need to keep both?

Copy link
Member Author

@Iceber Iceber Mar 8, 2023

Choose a reason for hiding this comment

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

The runtime field will be set to container.Runtime.Name, which will be used for TaskOpts such as WithNoPivotRoot to determine the runtime,it should not be changed

func WithNoPivotRoot(_ context.Context, _ *Client, ti *TaskInfo) error {
if CheckRuntime(ti.Runtime(), "io.containerd.runc") {
if ti.Options == nil {
ti.Options = &options.Options{}
}
opts, ok := ti.Options.(*options.Options)

Copy link
Member

Choose a reason for hiding this comment

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

Could you add comment lines to explain that?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added some comments to the runtime field

Copy link
Member

Choose a reason for hiding this comment

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

The problem is that the client doesn't use the services/tasks/v1.CreateTaskRequest.RuntimePath.

Container info has field named by Runtime.Name. It's consistency with keeping both. RuntimePath is more like override option.

@Iceber
Copy link
Member Author

Iceber commented Mar 14, 2023

@AkihiroSuda @dmcgowan PTAL, Is there anything that needs to be modified?

func WithRuntimePath(absRuntimePath string) NewTaskOpts {
return func(ctx context.Context, client *Client, info *TaskInfo) error {
info.runtime = absRuntimePath
info.RuntimePath = absRuntimePath
Copy link
Member

Choose a reason for hiding this comment

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

Is this a breaking change?

Copy link
Member Author

@Iceber Iceber Mar 14, 2023

Choose a reason for hiding this comment

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

This is not a breaking change.

In the past if the user used WithRuntimePath alone then the runtime path would not take effect.

And if the user uses WithRuntimePath + other NewTaskOpts (e.g. WithNoPivotRoot), then the wrong runtime options are generated and the task creation fails

WithNoPivotRoot and other NewTaskOpts generate the runtime options based on runtime.
For io.containerd.runc.* runtime, if runtime changes to runtime path, the generated option type is not *options.Options

func WithNoPivotRoot(_ context.Context, _ *Client, ti *TaskInfo) error {
if CheckRuntime(ti.Runtime(), "io.containerd.runc") {
if ti.Options == nil {
ti.Options = &options.Options{}
}
opts, ok := ti.Options.(*options.Options)
if !ok {
return errors.New("invalid v2 shim create options format")
}
opts.NoPivotRoot = true
} else {
if ti.Options == nil {
ti.Options = &runctypes.CreateOptions{
NoPivotRoot: true,
}
return nil

})
}
}
request.RuntimePath = info.RuntimePath
Copy link
Member

Choose a reason for hiding this comment

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

Can we have a test?

Copy link
Member Author

@Iceber Iceber Mar 14, 2023

Choose a reason for hiding this comment

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

I added a test, on linux it is green, but on windows it cannot find the shim binary.
https://github.com/containerd/containerd/actions/runs/4414423604/jobs/7736233010#step:16:37

    container_test.go:269: failed to start shim: start failed: : exec: "C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\shim1680046787": file does not exist: unknown

Added .exe suffix after the file name, no more errors reported.

Copy link
Member Author

Choose a reason for hiding this comment

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

@AkihiroSuda It's green on windows and linux, PTAL

@Iceber Iceber force-pushed the fix_runtime_path branch 6 times, most recently from 8ee39db to 837c5ec Compare March 14, 2023 12:58
return string(shimPath), nil
}

func copyShim(shimPath string) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated, Thanks

@Iceber Iceber force-pushed the fix_runtime_path branch 2 times, most recently from 1495c4d to 29e9850 Compare March 15, 2023 06:36
@Iceber
Copy link
Member Author

Iceber commented Mar 15, 2023

failed tests are not related to pr, need to retest

@Iceber Iceber requested a review from mxpv March 17, 2023 03:05
@Iceber
Copy link
Member Author

Iceber commented Mar 21, 2023

@estesp PTAL, Thanks

@Iceber Iceber force-pushed the fix_runtime_path branch from 29e9850 to a7be4f2 Compare March 29, 2023 03:35
@Iceber Iceber force-pushed the fix_runtime_path branch from a7be4f2 to c89438e Compare March 29, 2023 03:55
Copy link
Member

@fuweid fuweid left a comment

Choose a reason for hiding this comment

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

LGTM

// RuntimePath is an absolute path that can be used to overwrite path
// to a shim runtime binary.
RuntimePath string

Copy link
Member

Choose a reason for hiding this comment

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

The problem is that the client doesn't use the services/tasks/v1.CreateTaskRequest.RuntimePath.

Container info has field named by Runtime.Name. It's consistency with keeping both. RuntimePath is more like override option.

@fuweid fuweid merged commit 988ee8f into containerd:main Mar 31, 2023
@Iceber
Copy link
Member Author

Iceber commented Mar 31, 2023

@fuweid It looks useful to cherry-pick to release/1.6 and release/1.7

@fuweid
Copy link
Member

fuweid commented Mar 31, 2023

@Iceber please go ahead. Thanks

@fuweid fuweid added cherry-pick/1.6.x cherry-pick/1.7.x Change to be cherry picked to release/1.7 branch labels Mar 31, 2023
@dmcgowan dmcgowan added cherry-picked/1.7.x PR commits are cherry-picked into release/1.7 branch cherry-picked/1.6.x PR commits are cherry-picked into release/1.6 branch and removed cherry-pick/1.7.x Change to be cherry picked to release/1.7 branch cherry-pick/1.6.x labels May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-picked/1.6.x PR commits are cherry-picked into release/1.6 branch cherry-picked/1.7.x PR commits are cherry-picked into release/1.7 branch needs-ok-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The configured runtime path for cri is not working

6 participants