Skip to content

Commit

Permalink
Add a janky way of running a WPR trace to capture some HCS calls
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaunLawrie committed Jun 1, 2022
1 parent 994485e commit 1dccc3d
Show file tree
Hide file tree
Showing 3 changed files with 312 additions and 25 deletions.
50 changes: 48 additions & 2 deletions Data/HnsDatasource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ public class HnsDatasource
public string ExportDataSnapshot { get; private set; }

public TreeNode RoutesNode { get; private set; }
public TreeNode ContainerdNode { get; private set; }
public TreeNode ActivitiesNode { get; private set; }
public TreeNode OrphansNode { get; private set; }

public HnsDatasource()
{
NumberOfStepsLoaded = 0;
NumberOfStepsTotal = 20;
NumberOfStepsTotal = 21;
LoadingState = "Initialised";
SummaryOutput = "No data";
ExportDataSnapshot = "{}";
RoutesNode = new TreeNode();
ContainerdNode = new TreeNode();
ActivitiesNode = new TreeNode();
OrphansNode = new TreeNode();
}
Expand All @@ -48,6 +50,7 @@ public void Reset()
SummaryOutput = "No data";
ExportDataSnapshot = "{}";
RoutesNode = new TreeNode();
ContainerdNode = new TreeNode();
ActivitiesNode = new TreeNode();
OrphansNode = new TreeNode();
}
Expand Down Expand Up @@ -91,6 +94,44 @@ public void Load()
Tag = hostRouteList
};

UpdateLoadingState("Getting containerd config...");
var config = "C:\\Program Files\\containerd\\config.toml";
var log = "C:\\ProgramData\\containerd\\root\\panic.log";
if (File.Exists(config) || File.Exists(log))
{
ContainerdNode = new TreeNode
{
Text = "ContainerD",
Tag = "ContainerD config and logging"
};

if(File.Exists(config))
{
using (var fileStream = new FileStream(config, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var textReader = new StreamReader(fileStream))
{
ContainerdNode.Nodes.Add(new TreeNode
{
Text = "Config",
Tag = textReader.ReadToEnd()
});
}
}

if (File.Exists(log))
{
using (var fileStream = new FileStream(log, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var textReader = new StreamReader(fileStream))
{
ContainerdNode.Nodes.Add(new TreeNode
{
Text = "Logging",
Tag = string.Join("\n\n", textReader.ReadToEnd().Split('\n'))
});
}
}
}

ActivitiesNode = new TreeNode
{
Text = "Activities",
Expand Down Expand Up @@ -129,7 +170,11 @@ public void Load()
orphanedCompute = ActivitiesNode.Nodes.InsertChildrenWithMatchingParentReference(orphanedCompute, endpointData, "Id", "ID", "SharedContainers", "Container", "Owner");

UpdateLoadingState("Building orphan tree...");
OrphansNode = new TreeNode("Orphaned Data");
OrphansNode = new TreeNode
{
Text = "Orphaned Data",
Tag = "Data that can't easily be mapped to a node in the HNS activity list"
};
OrphansNode.Nodes.InsertChildren(orphanedNamesaces, "ID", "Namespace", "ID");
OrphansNode.Nodes.InsertChildren(orphanedActivities, "ID", "Activities", "Allocators.Tag");
OrphansNode.Nodes.InsertChildren(orphanedNetworks, "ID", "Network", "Name");
Expand All @@ -154,6 +199,7 @@ public void Load()
{
allData.Add("Routes", routeJsonElement);
}
// not exporting config cbf
ExportDataSnapshot = JsonSerializer.Serialize(allData);
UpdateLoadingState("Done");
}
Expand Down
73 changes: 54 additions & 19 deletions SummaryForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1dccc3d

Please sign in to comment.