Skip to content

Commit b5bdf59

Browse files
committed
libct: rm initWaiter
This initWaiter logic was introduced by commit 4ecff8d, 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 4ecff8d. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent d82235c commit b5bdf59

File tree

3 files changed

+0
-73
lines changed

3 files changed

+0
-73
lines changed

libcontainer/nsenter/nsenter_test.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ func TestNsenterValidPaths(t *testing.T) {
5252
t.Fatal(err)
5353
}
5454

55-
initWaiter(t, parent)
56-
5755
if err := cmd.Wait(); err != nil {
5856
t.Fatalf("nsenter error: %v", err)
5957
}
@@ -94,7 +92,6 @@ func TestNsenterInvalidPaths(t *testing.T) {
9492
t.Fatal(err)
9593
}
9694

97-
initWaiter(t, parent)
9895
if err := cmd.Wait(); err == nil {
9996
t.Fatalf("nsenter exits with a zero exit status")
10097
}
@@ -133,7 +130,6 @@ func TestNsenterIncorrectPathType(t *testing.T) {
133130
t.Fatal(err)
134131
}
135132

136-
initWaiter(t, parent)
137133
if err := cmd.Wait(); err == nil {
138134
t.Fatalf("nsenter error: %v", err)
139135
}
@@ -177,8 +173,6 @@ func TestNsenterChildLogging(t *testing.T) {
177173
t.Fatal(err)
178174
}
179175

180-
initWaiter(t, parent)
181-
182176
getLogs(t, logread)
183177
if err := cmd.Wait(); err != nil {
184178
t.Fatalf("nsenter error: %v", err)
@@ -208,22 +202,6 @@ func newPipe(t *testing.T) (parent *os.File, child *os.File) {
208202
return
209203
}
210204

211-
// initWaiter reads back the initial \0 from runc init
212-
func initWaiter(t *testing.T, r io.Reader) {
213-
inited := make([]byte, 1)
214-
n, err := r.Read(inited)
215-
if err == nil {
216-
if n < 1 {
217-
err = errors.New("short read")
218-
} else if inited[0] != 0 {
219-
err = fmt.Errorf("unexpected %d != 0", inited[0])
220-
} else {
221-
return
222-
}
223-
}
224-
t.Fatalf("waiting for init preliminary setup: %v", err)
225-
}
226-
227205
func reapChildren(t *testing.T, parent *os.File) {
228206
t.Helper()
229207
decoder := json.NewDecoder(parent)

libcontainer/nsenter/nsexec.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -571,13 +571,6 @@ void nsexec(void)
571571
return;
572572
}
573573

574-
/*
575-
* Inform the parent we're past initial setup.
576-
* For the other side of this, see initWaiter.
577-
*/
578-
if (write(pipenum, "", 1) != 1)
579-
bail("could not inform the parent we are past initial setup");
580-
581574
write_log(DEBUG, "=> nsexec container setup");
582575

583576
/* Parse all of the netlink configuration. */

libcontainer/process_linux.go

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,12 @@ func (p *setnsProcess) start() (retErr error) {
140140
return fmt.Errorf("error starting setns process: %w", err)
141141
}
142142

143-
waitInit := initWaiter(p.comm.initSockParent)
144143
defer func() {
145144
if retErr != nil {
146145
if newOom, err := p.manager.OOMKillCount(); err == nil && newOom != oom {
147146
// Someone in this cgroup was killed, this _might_ be us.
148147
retErr = fmt.Errorf("%w (possibly OOM-killed)", retErr)
149148
}
150-
werr := <-waitInit
151-
if werr != nil {
152-
logrus.WithError(werr).Warn()
153-
}
154149
err := ignoreTerminateErrors(p.terminate())
155150
if err != nil {
156151
logrus.WithError(err).Warn("unable to terminate setnsProcess")
@@ -163,10 +158,6 @@ func (p *setnsProcess) start() (retErr error) {
163158
return fmt.Errorf("error copying bootstrap data to pipe: %w", err)
164159
}
165160
}
166-
err = <-waitInit
167-
if err != nil {
168-
return err
169-
}
170161
if err := p.execSetns(); err != nil {
171162
return fmt.Errorf("error executing setns process: %w", err)
172163
}
@@ -536,7 +527,6 @@ func (p *initProcess) start() (retErr error) {
536527
return fmt.Errorf("unable to start init: %w", err)
537528
}
538529

539-
waitInit := initWaiter(p.comm.initSockParent)
540530
defer func() {
541531
if retErr != nil {
542532
// Find out if init is killed by the kernel's OOM killer.
@@ -559,11 +549,6 @@ func (p *initProcess) start() (retErr error) {
559549
}
560550
}
561551

562-
werr := <-waitInit
563-
if werr != nil {
564-
logrus.WithError(werr).Warn()
565-
}
566-
567552
// Terminate the process to ensure we can remove cgroups.
568553
if err := ignoreTerminateErrors(p.terminate()); err != nil {
569554
logrus.WithError(err).Warn("unable to terminate initProcess")
@@ -601,10 +586,6 @@ func (p *initProcess) start() (retErr error) {
601586
if _, err := io.Copy(p.comm.initSockParent, p.bootstrapData); err != nil {
602587
return fmt.Errorf("can't copy bootstrap data to pipe: %w", err)
603588
}
604-
err = <-waitInit
605-
if err != nil {
606-
return err
607-
}
608589

609590
childPid, err := p.getChildPid()
610591
if err != nil {
@@ -975,31 +956,6 @@ func (p *Process) InitializeIO(rootuid, rootgid int) (i *IO, err error) {
975956
return i, nil
976957
}
977958

978-
// initWaiter returns a channel to wait on for making sure
979-
// runc init has finished the initial setup.
980-
func initWaiter(r io.Reader) chan error {
981-
ch := make(chan error, 1)
982-
go func() {
983-
defer close(ch)
984-
985-
inited := make([]byte, 1)
986-
n, err := r.Read(inited)
987-
if err == nil {
988-
if n < 1 {
989-
err = errors.New("short read")
990-
} else if inited[0] != 0 {
991-
err = fmt.Errorf("unexpected %d != 0", inited[0])
992-
} else {
993-
ch <- nil
994-
return
995-
}
996-
}
997-
ch <- fmt.Errorf("waiting for init preliminary setup: %w", err)
998-
}()
999-
1000-
return ch
1001-
}
1002-
1003959
func setIOPriority(ioprio *configs.IOPriority) error {
1004960
const ioprioWhoPgrp = 1
1005961

0 commit comments

Comments
 (0)