Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Conversation

@avagin
Copy link
Contributor

@avagin avagin commented Dec 15, 2014

This series allows to start an init process in a new CT. In this version CT isn't created actually. This will be done in future patches.

I need to get answers on a few questions to continue this work.

  1. StartProcess() starts a process inside the container.
    If the container isn't started yet, this function will create a process in a new set of namespaces.
    If the container is running, a new process will be created in the set of namespaces which belong to the container.
    If all processes in the CT have died, this function will create a process in a new set of namespaces ().
    If all those statements are true, it looks strange that we don't want to know when a new container is created and when a process is executed in an existing container.
  2. How to follow container's state? We return PID-s of processes to users, so we can't call the waitpid() syscall for them. Are we going to monitor cgroup file system events or something like this?
  3. Are we going to support containers without pidns? In this case State.Init Pid looks meaningless.
  4. Are we going to support "permanent" containers? A "permanent" container is a container which can live without processes. For example the ip utility creates such containers "ip netns add test". In this case /proc/pid/ns/* files should be bind-mounted to somewhere and these links are used for setns().

@vmarmol
Copy link
Contributor

vmarmol commented Dec 15, 2014

Answering your questions:

  1. The factory has a Create() this creates everything in the container that is not tied to the init process (e.g.: cgroup, root directory, most namespaces). The first call to container's StartProcess() should do all the process specific setup (e.g.: userns, pidns). Subsequent StartProcess() just start a process in the existing container. If the init dies, then the container is empty and a subsequent StartProcess() re-starts the state tied to the init process.
  2. You can call RunState which in turn may query the cgroups to find out if the container still exists. Is this what you meant?
  3. We may share pid ns with another container. In these cases InitPid may be empty.
  4. Yes, all containers will be permanent as per (1).

@crosbymichael in case he doesn't agree with any of the above. But I believe we have from what we've spoken about before.

factory.go Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

this shouldn't need to be in the public API no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it should. When CT is created, a new process is forked in a new set of namespaces and this process must call execve() immediately. So an user of libcontainer has to create a program which will be executed in a new set of namespaces and call StartInitialization(). For example "nsexec init" will call this method.

Copy link
Contributor

Choose a reason for hiding this comment

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

(I'm fine as is for the sake of progress, but:) shouldn't the library handle this? As in, I want to run "echo hello" in my container. Shouldn't the library to the fork/exec/sync and then re-exec my "echo hello"?

@vmarmol
Copy link
Contributor

vmarmol commented Dec 15, 2014

You'll need to sign your commits since Travis is complaining.

Signed-off-by: Andrew Vagin <[email protected]>
After forking a new processes in a new container, we need to call exec()
and tune namespaces.

Signed-off-by: Andrew Vagin <[email protected]>
@vmarmol
Copy link
Contributor

vmarmol commented Dec 16, 2014

LGTM, please sign your commits and we can merge. Thanks for the patch! It is smaller and simpler than I thought it'd need to be.

@avagin
Copy link
Contributor Author

avagin commented Dec 16, 2014

@vmarmol I have signed my commits. Thanks.

@vmarmol
Copy link
Contributor

vmarmol commented Dec 16, 2014

The CI is complaining that some files are not gofmt'ed mind running it through that? This LGTM, we're just waiting on having the CI go green.

Here is a first step to implement a new API. Currently the init
processes is executed without namespaces and cgroups.

Signed-off-by: Andrew Vagin <[email protected]>
@avagin avagin force-pushed the api-linux branch 2 times, most recently from 6da6033 to 44024d0 Compare December 17, 2014 20:58
@vmarmol
Copy link
Contributor

vmarmol commented Dec 18, 2014

Thanks @avagin! LGTM, merging.

vmarmol added a commit that referenced this pull request Dec 18, 2014
Prepare ground for moving on new API
@vmarmol vmarmol merged commit c44e63a into docker-archive:api Dec 18, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants