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

Abstract recvtty to a single function #1731

Closed
wants to merge 1 commit into from

Conversation

deitch
Copy link
Contributor

@deitch deitch commented Feb 22, 2018

Right now, to use a console socket to retrieve the file descriptor for the container's console when terminal: true, you need to figure out how to do it from reverse-engineering recvtty.go.

This PR creates a func in utils.go so a go client easily can do:

import 	"github.com/opencontainers/runc/libcontainer/utils"

	// Open a socket.
	c, err := utils.ConsoleSocket(path)

       // c is a Console. so it implements Reader, Writer, Closer
      c.Read() 
      c.Write() 
      c.Close()

It also changes recvtty.go to leverage it.

Open to suggestion of course.

Signed-off-by: Avi Deitcher <avi@deitcher.net>
@deitch
Copy link
Contributor Author

deitch commented Mar 14, 2018

Also discussed with @cyphar earlier.

@deitch
Copy link
Contributor Author

deitch commented May 7, 2018

@cyphar this also is ~2 months old, per our discussion back then. Please review?

@dqminh
Copy link
Contributor

dqminh commented Jun 23, 2018

Not sure if its necessary to extract this out because this may encourage people to pull in the utils lib instead of other more friendly way such as using a runc-bindings.

For example, there is https://godoc.org/github.com/containerd/go-runc#Socket to interact with the socket.

@deitch
Copy link
Contributor Author

deitch commented Jun 24, 2018

@dqminh it has been 4+ months since I opened it, so I cannot recall all the details about what I was after at the time, except that I had come across several apps that had to do a chunk of work to interact with it, essentially replicating what was in recvtty.go.

For example, there is https://godoc.org/github.com/containerd/go-runc#Socket to interact with the socket.

What would the moral equivalent of the above be using go-runc? How would I connect/read/write/close using that?

@dqminh
Copy link
Contributor

dqminh commented Jun 24, 2018

@deitch To use go-runc's Socket interface, it should roughly be:

socket, _ = runc.NewConsoleSocket(path)
console, _ = socket.ReceiveMaster()

console is https://godoc.org/github.com/containerd/console#Console which you can read/write/close/resize etc.

You can see some example of the usages in containerd https://github.com/containerd/containerd/blob/356b0d59646253bc040e8d6365418f20badd59eb/runtime/linux/proc/init.go#L213-L220

@deitch
Copy link
Contributor Author

deitch commented Jun 24, 2018

Oh that is nice. It essentially provides what I was trying to do here, then? If so, I think we can close this out.

@dqminh
Copy link
Contributor

dqminh commented Jun 24, 2018

@deitch indeed, its quite similar to the proposed api here. I'm going to close this. Thanks for the help !

@dqminh dqminh closed this Jun 24, 2018
@deitch deitch deleted the recvtty-lib branch June 25, 2018 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants