libct: rm initWaiter

This initWaiter logic was introduced by commit 4ecff8d9, but since the logic of
/proc/self/exe was moved out of runc init in commit 0e9a335, this
seems unnecessary to have initWaiter.

Remove it.

This essentially reverts commit 4ecff8d9.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2024-10-11 16:29:29 -07:00
parent d82235c9d0
commit b5bdf592f2
3 changed files with 0 additions and 73 deletions
-44
View File
@@ -140,17 +140,12 @@ func (p *setnsProcess) start() (retErr error) {
return fmt.Errorf("error starting setns process: %w", err)
}
waitInit := initWaiter(p.comm.initSockParent)
defer func() {
if retErr != nil {
if newOom, err := p.manager.OOMKillCount(); err == nil && newOom != oom {
// Someone in this cgroup was killed, this _might_ be us.
retErr = fmt.Errorf("%w (possibly OOM-killed)", retErr)
}
werr := <-waitInit
if werr != nil {
logrus.WithError(werr).Warn()
}
err := ignoreTerminateErrors(p.terminate())
if err != nil {
logrus.WithError(err).Warn("unable to terminate setnsProcess")
@@ -163,10 +158,6 @@ func (p *setnsProcess) start() (retErr error) {
return fmt.Errorf("error copying bootstrap data to pipe: %w", err)
}
}
err = <-waitInit
if err != nil {
return err
}
if err := p.execSetns(); err != nil {
return fmt.Errorf("error executing setns process: %w", err)
}
@@ -536,7 +527,6 @@ func (p *initProcess) start() (retErr error) {
return fmt.Errorf("unable to start init: %w", err)
}
waitInit := initWaiter(p.comm.initSockParent)
defer func() {
if retErr != nil {
// Find out if init is killed by the kernel's OOM killer.
@@ -559,11 +549,6 @@ func (p *initProcess) start() (retErr error) {
}
}
werr := <-waitInit
if werr != nil {
logrus.WithError(werr).Warn()
}
// Terminate the process to ensure we can remove cgroups.
if err := ignoreTerminateErrors(p.terminate()); err != nil {
logrus.WithError(err).Warn("unable to terminate initProcess")
@@ -601,10 +586,6 @@ func (p *initProcess) start() (retErr error) {
if _, err := io.Copy(p.comm.initSockParent, p.bootstrapData); err != nil {
return fmt.Errorf("can't copy bootstrap data to pipe: %w", err)
}
err = <-waitInit
if err != nil {
return err
}
childPid, err := p.getChildPid()
if err != nil {
@@ -975,31 +956,6 @@ func (p *Process) InitializeIO(rootuid, rootgid int) (i *IO, err error) {
return i, nil
}
// initWaiter returns a channel to wait on for making sure
// runc init has finished the initial setup.
func initWaiter(r io.Reader) chan error {
ch := make(chan error, 1)
go func() {
defer close(ch)
inited := make([]byte, 1)
n, err := r.Read(inited)
if err == nil {
if n < 1 {
err = errors.New("short read")
} else if inited[0] != 0 {
err = fmt.Errorf("unexpected %d != 0", inited[0])
} else {
ch <- nil
return
}
}
ch <- fmt.Errorf("waiting for init preliminary setup: %w", err)
}()
return ch
}
func setIOPriority(ioprio *configs.IOPriority) error {
const ioprioWhoPgrp = 1