Skip to content

Commit 84bebdd

Browse files
authored
Merge pull request #2379 from dmcgowan/fix-direct-io-terminal-setting
Fix creation of DirectIO overwriting fifo config
2 parents b867977 + 6b9be1b commit 84bebdd

File tree

3 files changed

+10
-32
lines changed

3 files changed

+10
-32
lines changed

cio/io_unix.go

-10
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,8 @@ func openFifos(ctx context.Context, fifos *FIFOSet) (pipes, error) {
141141
// NewDirectIO returns an IO implementation that exposes the IO streams as io.ReadCloser
142142
// and io.WriteCloser.
143143
func NewDirectIO(ctx context.Context, fifos *FIFOSet) (*DirectIO, error) {
144-
return newDirectIO(ctx, fifos, false)
145-
}
146-
147-
// NewDirectIOWithTerminal returns an IO implementation that exposes the streams with terminal enabled
148-
func NewDirectIOWithTerminal(ctx context.Context, fifos *FIFOSet) (*DirectIO, error) {
149-
return newDirectIO(ctx, fifos, true)
150-
}
151-
152-
func newDirectIO(ctx context.Context, fifos *FIFOSet, terminal bool) (*DirectIO, error) {
153144
ctx, cancel := context.WithCancel(ctx)
154145
pipes, err := openFifos(ctx, fifos)
155-
fifos.Config.Terminal = terminal
156146
return &DirectIO{
157147
pipes: pipes,
158148
cio: cio{

container_checkpoint_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func TestCheckpointRestorePTY(t *testing.T) {
6060
}
6161
defer container.Delete(ctx, WithSnapshotCleanup)
6262

63-
direct, err := newDirectIOWithTerminal(ctx)
63+
direct, err := newDirectIO(ctx, true)
6464
if err != nil {
6565
t.Fatal(err)
6666
}
@@ -92,7 +92,7 @@ func TestCheckpointRestorePTY(t *testing.T) {
9292
t.Fatal(err)
9393
}
9494
direct.Delete()
95-
direct, err = newDirectIOWithTerminal(ctx)
95+
direct, err = newDirectIO(ctx, true)
9696
if err != nil {
9797
t.Fatal(err)
9898
}

container_linux_test.go

+8-20
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ func TestContainerPTY(t *testing.T) {
281281
}
282282
defer container.Delete(ctx, WithSnapshotCleanup)
283283

284-
direct, err := newDirectIOWithTerminal(ctx)
284+
direct, err := newDirectIO(ctx, true)
285285
if err != nil {
286286
t.Fatal(err)
287287
}
@@ -360,7 +360,7 @@ func TestContainerAttach(t *testing.T) {
360360

361361
expected := "hello" + newLine
362362

363-
direct, err := newDirectIOStandard(ctx)
363+
direct, err := newDirectIO(ctx, false)
364364
if err != nil {
365365
t.Fatal(err)
366366
}
@@ -429,24 +429,12 @@ func TestContainerAttach(t *testing.T) {
429429
}
430430
}
431431

432-
func newDirectIOStandard(ctx context.Context) (*directIO, error) {
433-
return newDirectIO(ctx, false)
434-
}
435-
436-
func newDirectIOWithTerminal(ctx context.Context) (*directIO, error) {
437-
return newDirectIO(ctx, true)
438-
}
439-
440432
func newDirectIO(ctx context.Context, terminal bool) (*directIO, error) {
441-
fifos, err := cio.NewFIFOSetInDir("", "", false)
433+
fifos, err := cio.NewFIFOSetInDir("", "", terminal)
442434
if err != nil {
443435
return nil, err
444436
}
445-
f := cio.NewDirectIO
446-
if terminal {
447-
f = cio.NewDirectIOWithTerminal
448-
}
449-
dio, err := f(ctx, fifos)
437+
dio, err := cio.NewDirectIO(ctx, fifos)
450438
if err != nil {
451439
return nil, err
452440
}
@@ -508,7 +496,7 @@ func TestContainerUsername(t *testing.T) {
508496
if err != nil {
509497
t.Fatal(err)
510498
}
511-
direct, err := newDirectIOStandard(ctx)
499+
direct, err := newDirectIO(ctx, false)
512500
if err != nil {
513501
t.Fatal(err)
514502
}
@@ -583,7 +571,7 @@ func testContainerUser(t *testing.T, userstr, expectedOutput string) {
583571
if err != nil {
584572
t.Fatal(err)
585573
}
586-
direct, err := newDirectIOStandard(ctx)
574+
direct, err := newDirectIO(ctx, false)
587575
if err != nil {
588576
t.Fatal(err)
589577
}
@@ -668,7 +656,7 @@ func TestContainerAttachProcess(t *testing.T) {
668656
expected := "hello" + newLine
669657

670658
// creating IO early for easy resource cleanup
671-
direct, err := newDirectIOStandard(ctx)
659+
direct, err := newDirectIO(ctx, false)
672660
if err != nil {
673661
t.Fatal(err)
674662
}
@@ -775,7 +763,7 @@ func TestContainerUserID(t *testing.T) {
775763
if err != nil {
776764
t.Fatal(err)
777765
}
778-
direct, err := newDirectIOStandard(ctx)
766+
direct, err := newDirectIO(ctx, false)
779767
if err != nil {
780768
t.Fatal(err)
781769
}

0 commit comments

Comments
 (0)