Skip to content

Commit

Permalink
catch if fetching logs fails
Browse files Browse the repository at this point in the history
  • Loading branch information
mms-gianni committed Aug 11, 2023
1 parent ab0e58c commit b17c00c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/kubero.ts
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,13 @@ export class Kubero {
if (pod.metadata?.name?.startsWith(appName)) {
for (const container of pod.spec?.containers || []) {
console.log('getting logs for '+pod.metadata.name+' '+container.name);
await this.kubectl.log.log(namespace, pod.metadata.name, container.name, logStream, {follow: false, tailLines: 80, pretty: false, timestamps: true})
try {
await this.kubectl.log.log(namespace, pod.metadata.name, container.name, logStream, {follow: false, tailLines: 80, pretty: false, timestamps: true})
} catch (error) {
console.log("error getting logs for "+pod.metadata.name+" "+container.name);
return loglines;
}


// sleep for 1 second to wait for all logs to be collected
await new Promise(r => setTimeout(r, 1000));
Expand Down

0 comments on commit b17c00c

Please sign in to comment.