Browse Source

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>
Cory Snider 2 years ago
parent
commit
843fcc96f7
2 changed files with 4 additions and 7 deletions
  1. 4 4
      libcontainerd/remote/client.go
  2. 0 3
      libcontainerd/types/types.go

+ 4 - 4
libcontainerd/remote/client.go

@@ -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

+ 0 - 3
libcontainerd/types/types.go

@@ -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"