Skip to content

Commit 0d2a1cf

Browse files
committed
chore: ensure snyk-monitor pod logs are printed
Do not assume which pod is the snyk-monitor one and try to find it by name instead of picking the first one from a list of pods.
1 parent 2ea4288 commit 0d2a1cf

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

test/setup/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,15 @@ async function dumpLogs(): Promise<void> {
178178
console.log('not dumping logs because', logDir, 'does not exist');
179179
return;
180180
}
181-
const podNames = await kubectl.getPodNames('snyk-monitor');
182-
const logs = await kubectl.getPodLogs(podNames[0], 'snyk-monitor');
181+
182+
const podNames = await kubectl.getPodNames('snyk-monitor').catch(() => []);
183+
const snykMonitorPod = podNames.find((name) => name.startsWith('snyk-monitor'));
184+
if (snykMonitorPod === undefined) {
185+
console.log('not dumping logs because snyk-monitor pod does not exist');
186+
return;
187+
}
188+
189+
const logs = await kubectl.getPodLogs(snykMonitorPod, 'snyk-monitor');
183190
const logPath = `${logDir}/kubernetes-monitor.log`;
184191
console.log('dumping logs to', logPath);
185192
fs.writeFileSync(logPath, logs);

0 commit comments

Comments
 (0)