libc8d/remote: name task fifos after task ID

The ID of the task is known at the time that the FIFOs need to be
created (it's passed into the IO-creator callback, and is also the same
as the container ID) so there is no need to hardcode it to "init". Name
the FIFOs after the task ID to be consistent with the FIFO names of
exec'ed processes. Delete the now-unused InitProcessName constant so it
can never again be used in place of a task/process ID.

Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
Cory Snider 2023-01-30 14:20:40 -05:00
parent 719b08313f
commit 843fcc96f7
2 changed files with 4 additions and 7 deletions

View file

@ -213,9 +213,9 @@ func (c *container) Start(ctx context.Context, checkpointDir string, withStdin b
t, err = c.c8dCtr.NewTask(ctx,
func(id string) (cio.IO, error) {
fifos := newFIFOSet(bundle, libcontainerdtypes.InitProcessName, withStdin, spec.Process.Terminal)
fifos := newFIFOSet(bundle, id, withStdin, spec.Process.Terminal)
rio, err = c.createIO(fifos, libcontainerdtypes.InitProcessName, stdinCloseSync, attachStdio)
rio, err = c.createIO(fifos, stdinCloseSync, attachStdio)
return rio, err
},
taskOpts...,
@ -278,7 +278,7 @@ func (t *task) Exec(ctx context.Context, processID string, spec *specs.Process,
}()
p, err = t.Task.Exec(ctx, processID, spec, func(id string) (cio.IO, error) {
rio, err = t.ctr.createIO(fifos, processID, stdinCloseSync, attachStdio)
rio, err = t.ctr.createIO(fifos, stdinCloseSync, attachStdio)
return rio, err
})
if err != nil {
@ -489,7 +489,7 @@ func (c *container) Task(ctx context.Context) (libcontainerdtypes.Task, error) {
// createIO creates the io to be used by a process
// This needs to get a pointer to interface as upon closure the process may not have yet been registered
func (c *container) createIO(fifos *cio.FIFOSet, processID string, stdinCloseSync chan containerd.Process, attachStdio libcontainerdtypes.StdioCallback) (cio.IO, error) {
func (c *container) createIO(fifos *cio.FIFOSet, stdinCloseSync chan containerd.Process, attachStdio libcontainerdtypes.StdioCallback) (cio.IO, error) {
var (
io *cio.DirectIO
err error

View file

@ -99,6 +99,3 @@ type Task interface {
// StdioCallback is called to connect a container or process stdio.
type StdioCallback func(io *cio.DirectIO) (cio.IO, error)
// InitProcessName is the name given to the first process of a container
const InitProcessName = "init"