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

cri: support io by streaming API #9965

Merged
merged 1 commit into from May 7, 2024
Merged

Conversation

abel-von
Copy link
Contributor

currently, CRI plugin only support container io by named pipes. but in some scenario named pipes may not work for some kind of sandboxes, for example, for VM based sandboxes, It is not easy to hotplug the named pipe into the vm. So for those kind of runtimes, they have to transfer io in some other way.
But if containerd support io streams by the streaming api, the shim process or the sandbox can serve the Streaming API of containerd, and containerd can create streams for the container stdios.

needs rebase after #9736

@k8s-ci-robot
Copy link

Hi @abel-von. 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.

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.

@abel-von abel-von closed this Mar 14, 2024
@abel-von abel-von reopened this Mar 14, 2024
@abel-von
Copy link
Contributor Author

abel-von commented Mar 14, 2024

The Usage of streaming io:
First, make sure you sandbox controller or shim implements Streaming API.
then add io_type of runtime in config.toml

[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.vmm]
  runtime_type = "io.containerd.vmm.v1"
  sandboxer = "vmm"
  io_type = "streaming"

Then containerd will connect to the sandbox endpoint(the same address to serve Task API), and create streaming client to transfer the io stream. the id of the stream will be the the in the form of "-stdin", "-stdout", or "-stderr", id is either container id or exec id.

and in the CreateTaskRequest the Stdin will be in the form of streaming:<address>?protocol=<grpc/ttrpc>&id=<id>-stdout. then the Task API Service can get the stream id and get the created stream from the Streaming API Service, and copy ios from container to the stream.

@fuweid
Copy link
Member

fuweid commented May 6, 2024

@abel-von please rebase thanks

@abel-von
Copy link
Contributor Author

abel-von commented May 7, 2024

@abel-von please rebase thanks

done

// if it is not set, the named pipe will be created for the container
// we can also set it to "streaming" to create a stream by streaming api,
// and use it as a channel to transfer the io stream
IOType string `toml:"io_type" json:"io_type"`
Copy link
Member

Choose a reason for hiding this comment

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

I think we should add validation for this.
Only allow streaming, named_pipe and ``.
It can be handled in the follow-up.

Copy link
Member

Choose a reason for hiding this comment

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

And update doc for cri-config as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

validation is done, will submit another pr to update the doc

core/transfer/streaming/reader.go Outdated Show resolved Hide resolved
internal/cri/server/container_create.go Show resolved Hide resolved
}

func openOutput(ctx context.Context, url string) (io.ReadCloser, error) {
ok := strings.Contains(url, "://")
Copy link
Member

Choose a reason for hiding this comment

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

Currently, CRI doesn't support log binary plugin.
We need revisit this part in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think as it is a url form, we can easily extend the log implementation.

Signed-off-by: Abel Feng <fshb1988@gmail.com>
@fuweid fuweid added this pull request to the merge queue May 7, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 7, 2024
@fuweid fuweid added this pull request to the merge queue May 7, 2024
Merged via the queue into containerd:main with commit 313fc12 May 7, 2024
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants