fix: preserve runtime rss fallback when process table misses roots
This commit is contained in:
parent
f0797e2c12
commit
58dfac8377
2 changed files with 14 additions and 16 deletions
|
|
@ -26033,7 +26033,6 @@ export class TeamProvisioningService {
|
||||||
const childrenByParent = this.buildRuntimeProcessChildrenByParent(normalizedProcessRows);
|
const childrenByParent = this.buildRuntimeProcessChildrenByParent(normalizedProcessRows);
|
||||||
const rowByPid = new Map(normalizedProcessRows.map((row) => [row.pid, row]));
|
const rowByPid = new Map(normalizedProcessRows.map((row) => [row.pid, row]));
|
||||||
const missingRootPids: number[] = [];
|
const missingRootPids: number[] = [];
|
||||||
let hasMatchedRootPid = false;
|
|
||||||
for (const rootPid of uniqueRoots) {
|
for (const rootPid of uniqueRoots) {
|
||||||
const pids: number[] = [];
|
const pids: number[] = [];
|
||||||
let truncated = false;
|
let truncated = false;
|
||||||
|
|
@ -26047,7 +26046,6 @@ export class TeamProvisioningService {
|
||||||
usageTreesByRootPid.set(rootPid, { pids: [], truncated: false });
|
usageTreesByRootPid.set(rootPid, { pids: [], truncated: false });
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
hasMatchedRootPid = true;
|
|
||||||
const rootProcessSource = rootProcessRow?.runtimeTelemetrySource;
|
const rootProcessSource = rootProcessRow?.runtimeTelemetrySource;
|
||||||
const addPid = (pid: number): boolean => {
|
const addPid = (pid: number): boolean => {
|
||||||
if (pids.includes(pid)) {
|
if (pids.includes(pid)) {
|
||||||
|
|
@ -26106,15 +26104,13 @@ export class TeamProvisioningService {
|
||||||
usageTreesByRootPid.set(rootPid, { pids, truncated });
|
usageTreesByRootPid.set(rootPid, { pids, truncated });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasMatchedRootPid) {
|
for (const rootPid of missingRootPids) {
|
||||||
for (const rootPid of missingRootPids) {
|
if (scheduledPids.size >= TeamProvisioningService.MAX_RUNTIME_USAGE_PIDS_PER_SNAPSHOT) {
|
||||||
if (scheduledPids.size >= TeamProvisioningService.MAX_RUNTIME_USAGE_PIDS_PER_SNAPSHOT) {
|
usageTreesByRootPid.set(rootPid, { pids: [], truncated: true });
|
||||||
usageTreesByRootPid.set(rootPid, { pids: [], truncated: true });
|
continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
scheduledPids.add(rootPid);
|
|
||||||
usageTreesByRootPid.set(rootPid, { pids: [rootPid], truncated: false });
|
|
||||||
}
|
}
|
||||||
|
scheduledPids.add(rootPid);
|
||||||
|
usageTreesByRootPid.set(rootPid, { pids: [rootPid], truncated: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
return usageTreesByRootPid;
|
return usageTreesByRootPid;
|
||||||
|
|
|
||||||
|
|
@ -3657,7 +3657,7 @@ describe('TeamProvisioningService', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not fall back to pidusage for root pids missing from an available process table', async () => {
|
it('falls back to pidusage for root pids missing from an otherwise available process table', async () => {
|
||||||
const svc = new TeamProvisioningService();
|
const svc = new TeamProvisioningService();
|
||||||
(svc as any).configReader = {
|
(svc as any).configReader = {
|
||||||
getConfig: vi.fn(async () => ({
|
getConfig: vi.fn(async () => ({
|
||||||
|
|
@ -3705,20 +3705,22 @@ describe('TeamProvisioningService', () => {
|
||||||
rssBytes: 12_000_000,
|
rssBytes: 12_000_000,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
vi.mocked(pidusage).mockResolvedValueOnce({
|
||||||
|
'111': createPidusageStat(111, 123_000_000),
|
||||||
|
'222': createPidusageStat(222, 456_000_000),
|
||||||
|
});
|
||||||
|
|
||||||
const snapshot = await svc.getTeamAgentRuntimeSnapshot('runtime-team');
|
const snapshot = await svc.getTeamAgentRuntimeSnapshot('runtime-team');
|
||||||
|
|
||||||
expect(pidusage).not.toHaveBeenCalled();
|
expect(pidusage).toHaveBeenCalledWith([111, 222], EXPECTED_RUNTIME_PIDUSAGE_OPTIONS);
|
||||||
expect(snapshot.members['team-lead']).toMatchObject({
|
expect(snapshot.members['team-lead']).toMatchObject({
|
||||||
pid: 111,
|
pid: 111,
|
||||||
|
rssBytes: 123_000_000,
|
||||||
});
|
});
|
||||||
expect(snapshot.members['team-lead'].cpuPercent).toBeUndefined();
|
|
||||||
expect(snapshot.members['team-lead'].rssBytes).toBeUndefined();
|
|
||||||
expect(snapshot.members.alice).toMatchObject({
|
expect(snapshot.members.alice).toMatchObject({
|
||||||
pid: 222,
|
pid: 222,
|
||||||
|
rssBytes: 456_000_000,
|
||||||
});
|
});
|
||||||
expect(snapshot.members.alice.cpuPercent).toBeUndefined();
|
|
||||||
expect(snapshot.members.alice.rssBytes).toBeUndefined();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('captures CPU and memory history on runtime snapshots', async () => {
|
it('captures CPU and memory history on runtime snapshots', async () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue