Skip to content

Commit 86c9290

Browse files
bkudiessCopilot
andcommitted
Retry timed-out WSL probes with partial output
Keep terminal WSL diagnostics fail-closed, but treat the command runner's explicit timeout signal as retryable under the existing exact-distro and absolute-deadline guards. Co-authored-by: Copilot App <[email protected]>
1 parent ff81c90 commit 86c9290

2 files changed

Lines changed: 54 additions & 7 deletions

File tree

‎src/OpenClaw.SetupEngine/SetupSteps.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,8 @@ private static FreshDistroProbeDisposition ClassifyReadinessProbe(
10591059
return FreshDistroProbeDisposition.Terminal;
10601060
}
10611061

1062-
if (string.IsNullOrWhiteSpace(combined) ||
1062+
if (probe.TimedOut ||
1063+
string.IsNullOrWhiteSpace(combined) ||
10631064
IsTransientFirstLaunchDiagnostic(combined))
10641065
{
10651066
terminalReason = "";

‎tests/OpenClaw.SetupEngine.Tests/SetupStepsTests.cs‎

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,46 @@ public async Task CreateWslInstance_RepeatedTimeoutsThenSuccessNeverRepeatsInsta
11501150
Assert.Single(commands.Calls, call => call.Arguments.Contains("--install"));
11511151
}
11521152

1153+
[Fact]
1154+
public async Task CreateWslInstance_TimedOutProbeWithPartialOutputRetries()
1155+
{
1156+
var installed = false;
1157+
var probeCalls = 0;
1158+
var clock = new AdvancingFreshDistroReadinessClock();
1159+
var commands = new FakeCommandRunner(args =>
1160+
{
1161+
if (args.SequenceEqual(["--list", "--quiet"]))
1162+
return Ok(installed ? "OpenClawGateway\n" : "");
1163+
if (args.Contains("--install"))
1164+
{
1165+
installed = true;
1166+
return Ok();
1167+
}
1168+
if (args.SequenceEqual(["--list", "--verbose"]))
1169+
return Ok(FreshDistroVerboseOutput);
1170+
if (IsFreshDistroRootProbe(args))
1171+
{
1172+
probeCalls++;
1173+
if (probeCalls == 1)
1174+
{
1175+
clock.Advance(TimeSpan.FromSeconds(30));
1176+
return TimedOut(stderr: "first launch produced partial diagnostic output");
1177+
}
1178+
1179+
return Ok(FreshDistroReadyOutput);
1180+
}
1181+
1182+
return Fail($"unexpected args: {string.Join(' ', args)}");
1183+
});
1184+
var ctx = CreateContext(commands: commands);
1185+
1186+
var result = await new CreateWslInstanceStep(clock).ExecuteAsync(ctx, CancellationToken.None);
1187+
1188+
Assert.True(result.IsSuccess, result.Message);
1189+
Assert.Equal(2, probeCalls);
1190+
Assert.Single(commands.Calls, call => call.Arguments.Contains("--install"));
1191+
}
1192+
11531193
[Fact]
11541194
public async Task CreateWslInstance_RegistrationTimeReducesPerAttemptProbeTimeout()
11551195
{
@@ -1324,8 +1364,10 @@ public async Task CreateWslInstance_DistroDisappearanceOrChangeFailsClosed(strin
13241364
call.Arguments.Contains("DifferentGateway", StringComparer.Ordinal));
13251365
}
13261366

1327-
[Fact]
1328-
public async Task CreateWslInstance_TerminalProbeErrorFailsWithoutRetry()
1367+
[Theory]
1368+
[InlineData(false)]
1369+
[InlineData(true)]
1370+
public async Task CreateWslInstance_TerminalProbeErrorFailsWithoutRetry(bool timedOut)
13291371
{
13301372
var installed = false;
13311373
var probeCalls = 0;
@@ -1343,9 +1385,13 @@ public async Task CreateWslInstance_TerminalProbeErrorFailsWithoutRetry()
13431385
if (IsFreshDistroRootProbe(args))
13441386
{
13451387
probeCalls++;
1346-
return Fail(
1388+
return new CommandResult(
1389+
-1,
1390+
"",
13471391
"Wsl/Service/CreateInstance/WSL_E_CORRUPT_DISTRO " +
1348-
string.Join(' ', Enumerable.Repeat("diagnostic", 100)));
1392+
string.Join(' ', Enumerable.Repeat("diagnostic", 100)),
1393+
TimeSpan.FromSeconds(30),
1394+
timedOut);
13491395
}
13501396
if (args.SequenceEqual(["--terminate", "OpenClawGateway"]) ||
13511397
args.SequenceEqual(["--unregister", "OpenClawGateway"]))
@@ -3731,8 +3777,8 @@ private static CommandResult Fail(string stderr = "")
37313777
private static CommandResult FailWithStdout(string stdout)
37323778
=> new(1, stdout, "", TimeSpan.Zero, TimedOut: false);
37333779

3734-
private static CommandResult TimedOut()
3735-
=> new(-1, "", "", TimeSpan.FromSeconds(30), TimedOut: true);
3780+
private static CommandResult TimedOut(string stdout = "", string stderr = "")
3781+
=> new(-1, stdout, stderr, TimeSpan.FromSeconds(30), TimedOut: true);
37363782

37373783
private static bool IsFreshDistroRootProbe(string[] arguments)
37383784
=> arguments.SequenceEqual(

0 commit comments

Comments
 (0)