-
Notifications
You must be signed in to change notification settings - Fork 3.8k
fix the task setting the runtime path #8208
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
Conversation
|
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 Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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 | ||
|
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
Lines 55 to 60 in 29e10a1
| 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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
|
@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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
Lines 55 to 70 in 29e10a1
| 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
8ee39db to
837c5ec
Compare
| return string(shimPath), nil | ||
| } | ||
|
|
||
| func copyShim(shimPath string) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, Thanks
1495c4d to
29e9850
Compare
|
failed tests are not related to pr, need to retest |
|
@estesp PTAL, Thanks |
Signed-off-by: Iceber Gu <[email protected]>
29e9850 to
a7be4f2
Compare
Signed-off-by: Iceber Gu <[email protected]>
a7be4f2 to
c89438e
Compare
fuweid
left a comment
There was a problem hiding this 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 | ||
|
|
There was a problem hiding this comment.
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 It looks useful to cherry-pick to release/1.6 and release/1.7 |
|
@Iceber please go ahead. Thanks |
fix: #8207
containerd/pkg/cri/server/container_start.go
Lines 124 to 126 in 5da7e2c
Although the runtime path is set in the cri server, the runtime path is not set to the
requestin the NewTaskAdd
TaskInfo.RuntimePathfield to prevent overwritingTaskInfo.runtime, directly overwriting TaskInfo.runtime may cause exceptions to otherNewTaskOpts