Skip to content

Commit

Permalink
Add LocalDumps regkey by default to collect user-mode process dumps l…
Browse files Browse the repository at this point in the history
…ocally
  • Loading branch information
Kirtana Ashok authored and kiashok committed Aug 2, 2023
1 parent fa3b77d commit 26c891c
Showing 1 changed file with 49 additions and 2 deletions.
51 changes: 49 additions & 2 deletions internal/hcsoci/hcsdoc_wcow.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,14 @@ func createWindowsContainerDocument(ctx context.Context, coi *createOptionsInter
}

if specDumpPath, ok := coi.Spec.Annotations[annotations.ContainerProcessDumpLocation]; ok {
// If a process dump path was specified at pod creation time for a hypervisor isolated pod, then
// If a process dump path was specified at pod creation time, then
// use this value. If one was specified on the container creation document then override with this
// instead. Unlike Linux, Windows containers can set the dump path on a per container basis.
dumpPath = specDumpPath
}

fmt.Println("DumpPath:", dumpPath)

// Servercore images block on signaling and wait until the target process
// is terminated to return to its caller. By default, servercore waits for
// 5 seconds (default value of 'WaitToKillServiceTimeout') before sending
Expand All @@ -415,7 +417,43 @@ func createWindowsContainerDocument(ctx context.Context, coi *createOptionsInter
},
}

if dumpPath != "" {
// LocalDumps reg key enables collection of user-mode dumps and stores them locally.
// DumpFolder specifies the write location for dumps
// DumpCount specifies the max dump files in the DumpFolder
// DumpType specifies if the dump should be a mini dump/full dump or custom dump
// If process dump path was not specified at pod creation time, the default
// dump path is set to C:\CrashDumps
if dumpPath == "" {
registryAdd = append(registryAdd, []hcsschema.RegistryValue{
{
Key: &hcsschema.RegistryKey{
Hive: "Software",
Name: "Microsoft\\Windows\\Windows Error Reporting\\LocalDumps",
},
Name: "DumpFolder",
StringValue: "C:\\CrashDumps",
Type_: "String",
},
{
Key: &hcsschema.RegistryKey{
Hive: "Software",
Name: "Microsoft\\Windows\\Windows Error Reporting\\LocalDumps",
},
Name: "DumpCount",
DWordValue: 10,
Type_: "DWord",
},
{
Key: &hcsschema.RegistryKey{
Hive: "Software",
Name: "Microsoft\\Windows\\Windows Error Reporting\\LocalDumps",
},
Name: "DumpType",
DWordValue: 2,
Type_: "DWord",
},
}...)
} else {
dumpType, err := parseDumpType(coi.Spec.Annotations)
if err != nil {
return nil, nil, err
Expand All @@ -433,6 +471,15 @@ func createWindowsContainerDocument(ctx context.Context, coi *createOptionsInter
StringValue: dumpPath,
Type_: "String",
},
{
Key: &hcsschema.RegistryKey{
Hive: "Software",
Name: "Microsoft\\Windows\\Windows Error Reporting\\LocalDumps",
},
Name: "DumpCount",
DWordValue: 10,
Type_: "DWord",
},
{
Key: &hcsschema.RegistryKey{
Hive: "Software",
Expand Down

0 comments on commit 26c891c

Please sign in to comment.