8000 Merge pull request #8625 from mook-as/moby/log-wait-for-ready · mook-as/rd@294dddc · GitHub
[go: up one dir, main page]

Skip to content

Commit 294dddc

Browse files
authored
Merge pull request rancher-sandbox#8625 from mook-as/moby/log-wait-for-ready
moby: Log errors on wait-for-ready failures
2 parents af44fea + 53aa204 commit 294dddc

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

pkg/rancher-desktop/backend/containerClient/mobyClient.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ export class MobyClient implements ContainerEngineClient {
6666

6767
async waitForReady(): Promise<void> {
6868
let successCount = 0;
69+
let failureCount = 0;
70+
let lastOutput = { stdout: '', stderr: '' };
6971

7072
// Wait for ten consecutive successes, clearing out successCount whenever we
7173
// hit an error. In the ideal case this is a ten-second delay in startup
@@ -74,10 +76,27 @@ export class MobyClient implements ContainerEngineClient {
7476
// fails to do so).
7577
while (successCount < 10) {
7678
try {
77-
await this.runClient(['system', ' CB1D info'], 'ignore');
79+
await this.runClient(['system', 'info'], 'pipe');
7880
successCount++;
81+
failureCount = 0;
7982
} catch (ex) {
8083
successCount = 0;
84+
failureCount++;
85+
// If we've been erroring for a while, log the output.
86+
if (failureCount > 10 && ex && typeof ex === 'object') {
87+
const output = { stdout: '', stderr: '' };
88+
89+
if ('stdout' in ex && typeof ex.stdout === 'string') {
90+
output.stdout = ex.stdout;
91+
}
92+
if ('stderr' in ex && typeof ex.stderr === 'string') {
93+
output.stderr = ex.stderr;
94+
}
95+
if (output.stdout !== lastOutput.stdout || output.stderr !== lastOutput.stderr) {
96+
console.error(`Failed to run docker system info after ${ failureCount } failures (will retry):`, output);
97+
lastOutput = output;
98+
}
99+
}
81100
}
82101
await util.promisify(setTimeout)(1_000);
83102
}

0 commit comments

Comments
 (0)
0