mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-21 07:36:40 +00:00
fix(network-topology): harden with edge-case fixes, logging, and test coverage (#583)
* fix(network-topology): harden with edge-case fixes, logging, and test coverage Fixes stale data on node switch (topology now refreshes when active node changes), adds manual refresh button to toolbar, and guards against containers with empty Names arrays by falling back to a 12-char short ID. Adds operational and diagnostic logging around topology fetches, and introduces 25 unit tests covering happy paths, system network filtering, stack resolution, container deduplication, edge cases, and error handling. * docs: refresh screenshots
This commit is contained in:
@@ -438,6 +438,8 @@ class DockerController {
|
||||
knownStackNames: string[],
|
||||
includeSystem: boolean,
|
||||
): Promise<TopologyNetwork[]> {
|
||||
const debug = isDebugEnabled();
|
||||
const t0 = debug ? Date.now() : 0;
|
||||
const knownSet = new Set(knownStackNames);
|
||||
|
||||
const [rawNetworks, rawContainers, projectToStack] = await Promise.all([
|
||||
@@ -505,7 +507,7 @@ class DockerController {
|
||||
|
||||
topology.containers.push({
|
||||
id: c.Id,
|
||||
name: (c.Names?.[0] ?? '').replace(/^\//, ''),
|
||||
name: (c.Names?.[0] ?? '').replace(/^\//, '') || (c.Id ?? '').substring(0, 12),
|
||||
ip: netInfo.IPAddress ?? '',
|
||||
state: c.State ?? 'unknown',
|
||||
image: c.Image ?? '',
|
||||
@@ -514,7 +516,20 @@ class DockerController {
|
||||
}
|
||||
}
|
||||
|
||||
return Array.from(networkMap.values());
|
||||
const result = Array.from(networkMap.values());
|
||||
|
||||
if (debug) {
|
||||
const totalContainers = result.reduce((sum, n) => sum + n.containers.length, 0);
|
||||
console.debug('[Resources:debug] Topology built', {
|
||||
ms: Date.now() - t0,
|
||||
networks: result.length,
|
||||
containers: totalContainers,
|
||||
systemFiltered: !includeSystem,
|
||||
stacksKnown: knownStackNames.length,
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Resolves a Docker Compose project label to a known Sencho stack name, or null. */
|
||||
|
||||
Reference in New Issue
Block a user