Adds containerd-shim-runhcs verbose logging support
Revendors to Microsoft/hcsshim v0.7.5 that added support for logging all runhcs.exe commands via Windows named pipes. This now launches all runhcs.exe commands and forwards debug logging to the containerd-shim-runhcs log when with --debug. Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
This commit is contained in:
		
							
								
								
									
										17
									
								
								vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										17
									
								
								vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -6,6 +6,8 @@ import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"os"
 | 
			
		||||
	"os/exec"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"sync"
 | 
			
		||||
 | 
			
		||||
	"github.com/containerd/go-runc"
 | 
			
		||||
@@ -21,7 +23,8 @@ const (
 | 
			
		||||
	// JSON is the JSON formatted log output.
 | 
			
		||||
	JSON Format = "json"
 | 
			
		||||
 | 
			
		||||
	command = "runhcs"
 | 
			
		||||
	command        = "runhcs"
 | 
			
		||||
	safePipePrefix = `\\.\pipe\ProtectedPrefix\Administrators\`
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var bytesBufferPool = sync.Pool{
 | 
			
		||||
@@ -43,7 +46,7 @@ func putBuf(b *bytes.Buffer) {
 | 
			
		||||
type Runhcs struct {
 | 
			
		||||
	// Debug enables debug output for logging.
 | 
			
		||||
	Debug bool
 | 
			
		||||
	// Log sets the log file path where internal debug information is written.
 | 
			
		||||
	// Log sets the log file path or named pipe (e.g. \\.\pipe\ProtectedPrefix\Administrators\runhcs-log) where internal debug information is written.
 | 
			
		||||
	Log string
 | 
			
		||||
	// LogFormat sets the format used by logs.
 | 
			
		||||
	LogFormat Format
 | 
			
		||||
@@ -59,8 +62,14 @@ func (r *Runhcs) args() []string {
 | 
			
		||||
		out = append(out, "--debug")
 | 
			
		||||
	}
 | 
			
		||||
	if r.Log != "" {
 | 
			
		||||
		// TODO: JTERRY75 - Should we do abs here?
 | 
			
		||||
		out = append(out, "--log", r.Log)
 | 
			
		||||
		if strings.HasPrefix(r.Log, safePipePrefix) {
 | 
			
		||||
			out = append(out, "--log", r.Log)
 | 
			
		||||
		} else {
 | 
			
		||||
			abs, err := filepath.Abs(r.Log)
 | 
			
		||||
			if err == nil {
 | 
			
		||||
				out = append(out, "--log", abs)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if r.LogFormat != none {
 | 
			
		||||
		out = append(out, "--log-format", string(r.LogFormat))
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										29
									
								
								vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_create.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										29
									
								
								vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_create.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -4,6 +4,7 @@ import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	runc "github.com/containerd/go-runc"
 | 
			
		||||
)
 | 
			
		||||
@@ -13,9 +14,9 @@ type CreateOpts struct {
 | 
			
		||||
	runc.IO
 | 
			
		||||
	// PidFile is the path to the file to write the process id to.
 | 
			
		||||
	PidFile string
 | 
			
		||||
	// ShimLog is the path to the log file for the launched shim process.
 | 
			
		||||
	// ShimLog is the path to the log file or named pipe (e.g. \\.\pipe\ProtectedPrefix\Administrators\runhcs-<container-id>-shim-log) for the launched shim process.
 | 
			
		||||
	ShimLog string
 | 
			
		||||
	// VMLog is the path to the log file for the launched VM shim process.
 | 
			
		||||
	// VMLog is the path to the log file or named pipe (e.g. \\.\pipe\ProtectedPrefix\Administrators\runhcs-<container-id>-vm-log) for the launched VM shim process.
 | 
			
		||||
	VMLog string
 | 
			
		||||
	// VMConsole is the path to the pipe for the VM's console (e.g. \\.\pipe\debugpipe)
 | 
			
		||||
	VMConsole string
 | 
			
		||||
@@ -31,18 +32,26 @@ func (opt *CreateOpts) args() ([]string, error) {
 | 
			
		||||
		out = append(out, "--pid-file", abs)
 | 
			
		||||
	}
 | 
			
		||||
	if opt.ShimLog != "" {
 | 
			
		||||
		abs, err := filepath.Abs(opt.ShimLog)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		if strings.HasPrefix(opt.ShimLog, safePipePrefix) {
 | 
			
		||||
			out = append(out, "--shim-log", opt.ShimLog)
 | 
			
		||||
		} else {
 | 
			
		||||
			abs, err := filepath.Abs(opt.ShimLog)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				return nil, err
 | 
			
		||||
			}
 | 
			
		||||
			out = append(out, "--shim-log", abs)
 | 
			
		||||
		}
 | 
			
		||||
		out = append(out, "--shim-log", abs)
 | 
			
		||||
	}
 | 
			
		||||
	if opt.VMLog != "" {
 | 
			
		||||
		abs, err := filepath.Abs(opt.VMLog)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		if strings.HasPrefix(opt.VMLog, safePipePrefix) {
 | 
			
		||||
			out = append(out, "--vm-log", opt.VMLog)
 | 
			
		||||
		} else {
 | 
			
		||||
			abs, err := filepath.Abs(opt.VMLog)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				return nil, err
 | 
			
		||||
			}
 | 
			
		||||
			out = append(out, "--vm-log", abs)
 | 
			
		||||
		}
 | 
			
		||||
		out = append(out, "--vm-log", abs)
 | 
			
		||||
	}
 | 
			
		||||
	if opt.VMConsole != "" {
 | 
			
		||||
		out = append(out, "--vm-console", opt.VMConsole)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										15
									
								
								vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_exec.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_exec.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -4,6 +4,7 @@ import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"github.com/containerd/go-runc"
 | 
			
		||||
)
 | 
			
		||||
@@ -15,7 +16,7 @@ type ExecOpts struct {
 | 
			
		||||
	Detach bool
 | 
			
		||||
	// PidFile is the path to the file to write the process id to.
 | 
			
		||||
	PidFile string
 | 
			
		||||
	// ShimLog is the path to the log file for the launched shim process.
 | 
			
		||||
	// ShimLog is the path to the log file or named pipe (e.g. \\.\pipe\ProtectedPrefix\Administrators\runhcs-<container-id>-<exec-id>-log) for the launched shim process.
 | 
			
		||||
	ShimLog string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -32,11 +33,15 @@ func (opt *ExecOpts) args() ([]string, error) {
 | 
			
		||||
		out = append(out, "--pid-file", abs)
 | 
			
		||||
	}
 | 
			
		||||
	if opt.ShimLog != "" {
 | 
			
		||||
		abs, err := filepath.Abs(opt.ShimLog)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		if strings.HasPrefix(opt.ShimLog, safePipePrefix) {
 | 
			
		||||
			out = append(out, "--shim-log", opt.ShimLog)
 | 
			
		||||
		} else {
 | 
			
		||||
			abs, err := filepath.Abs(opt.ShimLog)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				return nil, err
 | 
			
		||||
			}
 | 
			
		||||
			out = append(out, "--shim-log", abs)
 | 
			
		||||
		}
 | 
			
		||||
		out = append(out, "--shim-log", abs)
 | 
			
		||||
	}
 | 
			
		||||
	return out, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/hnsendpoint.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/Microsoft/hcsshim/hnsendpoint.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -6,6 +6,8 @@ import (
 | 
			
		||||
 | 
			
		||||
// HNSEndpoint represents a network endpoint in HNS
 | 
			
		||||
type HNSEndpoint = hns.HNSEndpoint
 | 
			
		||||
// Namespace represents a Compartment.
 | 
			
		||||
type Namespace = hns.Namespace
 | 
			
		||||
 | 
			
		||||
//SystemType represents the type of the system on which actions are done
 | 
			
		||||
type SystemType string
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user