Merge pull request #13889 from samuelkarp/hcsshim-scrub-logs-1.7

[release/1.7] Use ScrubLogs by default on Windows
This commit is contained in:
Maksym Pavlenko
2026-08-05 11:05:05 -07:00
committed by GitHub
2 changed files with 19 additions and 1 deletions

View File

@@ -38,6 +38,10 @@ var platformRunFlags = []cli.Flag{
Name: "isolated",
Usage: "Run the container with vm isolation",
},
&cli.BoolFlag{
Name: "scrub-logs",
Usage: "Scrub sensitive information from the shim logs (Windows only)",
},
}
// NewContainer creates a new container
@@ -172,9 +176,13 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
runtime := context.String("runtime")
var runtimeOpts interface{}
if runtime == "io.containerd.runhcs.v1" {
runtimeOpts = &options.Options{
opts := &options.Options{
Debug: context.GlobalBool("debug"),
}
if context.IsSet("scrub-logs") {
opts.ScrubLogs = context.Bool("scrub-logs")
}
runtimeOpts = opts
}
cOpts = append(cOpts, containerd.WithRuntime(runtime, runtimeOpts))

View File

@@ -42,6 +42,13 @@ func DefaultConfig() PluginConfig {
"runhcs-wcow-process": {
Type: "io.containerd.runhcs.v1",
ContainerAnnotations: []string{"io.microsoft.container.*"},
// Full set of Windows shim options:
// https://pkg.go.dev/github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options#Options
Options: map[string]interface{}{
// ScrubLogs enables removing environment variables and other potentially sensitive information
// from logs
"ScrubLogs": true,
},
},
"runhcs-wcow-hypervisor": {
Type: "io.containerd.runhcs.v1",
@@ -50,6 +57,9 @@ func DefaultConfig() PluginConfig {
// Full set of Windows shim options:
// https://pkg.go.dev/github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options#Options
Options: map[string]interface{}{
// ScrubLogs enables removing environment variables and other potentially sensitive information
// from logs
"ScrubLogs": true,
// SandboxIsolation specifies the isolation level of the sandbox.
// PROCESS (0) and HYPERVISOR (1) are the valid options.
"SandboxIsolation": 1,