Merge pull request #10412 from TinaMor/tinamor/dev
[Windows] Set stderr to empty string when using terminal on Windows
This commit is contained in:
commit
0262714edb
@ -252,20 +252,6 @@ func LogURI(uri *url.URL) Creator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TerminalLogURI provides the raw logging URI
|
|
||||||
// as well as sets the terminal option to true.
|
|
||||||
func TerminalLogURI(uri *url.URL) Creator {
|
|
||||||
return func(_ string) (IO, error) {
|
|
||||||
return &logURI{
|
|
||||||
config: Config{
|
|
||||||
Stdout: uri.String(),
|
|
||||||
Stderr: uri.String(),
|
|
||||||
Terminal: true,
|
|
||||||
},
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// BinaryIO forwards container STDOUT|STDERR directly to a logging binary
|
// BinaryIO forwards container STDOUT|STDERR directly to a logging binary
|
||||||
func BinaryIO(binary string, args map[string]string) Creator {
|
func BinaryIO(binary string, args map[string]string) Creator {
|
||||||
return func(_ string) (IO, error) {
|
return func(_ string) (IO, error) {
|
||||||
@ -284,26 +270,6 @@ func BinaryIO(binary string, args map[string]string) Creator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TerminalBinaryIO forwards container STDOUT|STDERR directly to a logging binary
|
|
||||||
// It also sets the terminal option to true
|
|
||||||
func TerminalBinaryIO(binary string, args map[string]string) Creator {
|
|
||||||
return func(_ string) (IO, error) {
|
|
||||||
uri, err := LogURIGenerator("binary", binary, args)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
res := uri.String()
|
|
||||||
return &logURI{
|
|
||||||
config: Config{
|
|
||||||
Stdout: res,
|
|
||||||
Stderr: res,
|
|
||||||
Terminal: true,
|
|
||||||
},
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// LogFile creates a file on disk that logs the task's STDOUT,STDERR.
|
// LogFile creates a file on disk that logs the task's STDOUT,STDERR.
|
||||||
// If the log file already exists, the logs will be appended to the file.
|
// If the log file already exists, the logs will be appended to the file.
|
||||||
func LogFile(path string) Creator {
|
func LogFile(path string) Creator {
|
||||||
|
@ -22,6 +22,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
@ -158,3 +159,37 @@ func NewDirectIO(ctx context.Context, fifos *FIFOSet) (*DirectIO, error) {
|
|||||||
},
|
},
|
||||||
}, err
|
}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TerminalLogURI provides the raw logging URI
|
||||||
|
// as well as sets the terminal option to true.
|
||||||
|
func TerminalLogURI(uri *url.URL) Creator {
|
||||||
|
return func(_ string) (IO, error) {
|
||||||
|
return &logURI{
|
||||||
|
config: Config{
|
||||||
|
Stdout: uri.String(),
|
||||||
|
Stderr: uri.String(),
|
||||||
|
Terminal: true,
|
||||||
|
},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TerminalBinaryIO forwards container STDOUT|STDERR directly to a logging binary
|
||||||
|
// It also sets the terminal option to true
|
||||||
|
func TerminalBinaryIO(binary string, args map[string]string) Creator {
|
||||||
|
return func(_ string) (IO, error) {
|
||||||
|
uri, err := LogURIGenerator("binary", binary, args)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
res := uri.String()
|
||||||
|
return &logURI{
|
||||||
|
config: Config{
|
||||||
|
Stdout: res,
|
||||||
|
Stderr: res,
|
||||||
|
Terminal: true,
|
||||||
|
},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -20,6 +20,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
winio "github.com/Microsoft/go-winio"
|
winio "github.com/Microsoft/go-winio"
|
||||||
"github.com/containerd/log"
|
"github.com/containerd/log"
|
||||||
@ -155,3 +156,42 @@ func NewDirectIOFromFIFOSet(ctx context.Context, stdin io.WriteCloser, stdout, s
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TerminalLogURI provides the raw logging URI
|
||||||
|
// as well as sets the terminal option to true.
|
||||||
|
func TerminalLogURI(uri *url.URL) Creator {
|
||||||
|
return func(_ string) (IO, error) {
|
||||||
|
return &logURI{
|
||||||
|
config: Config{
|
||||||
|
Terminal: true,
|
||||||
|
Stdout: uri.String(),
|
||||||
|
|
||||||
|
// Windows HCSShim requires that stderr is an empty string when using terminal.
|
||||||
|
// https://github.com/microsoft/hcsshim/blob/200feabd854da69f615a598ed6a1263ce9531676/cmd/containerd-shim-runhcs-v1/service_internal.go#L127
|
||||||
|
Stderr: "",
|
||||||
|
},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TerminalBinaryIO forwards container STDOUT|STDERR directly to a logging binary
|
||||||
|
// It also sets the terminal option to true
|
||||||
|
func TerminalBinaryIO(binary string, args map[string]string) Creator {
|
||||||
|
return func(_ string) (IO, error) {
|
||||||
|
uri, err := LogURIGenerator("binary", binary, args)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &logURI{
|
||||||
|
config: Config{
|
||||||
|
Terminal: true,
|
||||||
|
Stdout: uri.String(),
|
||||||
|
|
||||||
|
// Windows HCSShim requires that stderr is an empty string when using terminal.
|
||||||
|
// https://github.com/microsoft/hcsshim/blob/200feabd854da69f615a598ed6a1263ce9531676/cmd/containerd-shim-runhcs-v1/service_internal.go#L127
|
||||||
|
Stderr: "",
|
||||||
|
},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user