Skip to content

Implement --stop-timeout in wslc create|run and support -1 (infinite) timeouts#40919

Open
OneBlue wants to merge 12 commits into
masterfrom
user/oneblue/stop-timeout-fix
Open

Implement --stop-timeout in wslc create|run and support -1 (infinite) timeouts#40919
OneBlue wants to merge 12 commits into
masterfrom
user/oneblue/stop-timeout-fix

Conversation

@OneBlue

@OneBlue OneBlue commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Summary of the Pull Request

This change adds support for --stop-timeout and -1 timeouts (no timeout)

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Copilot AI review requested due to automatic review settings June 25, 2026 22:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for --stop-timeout in wslc container create/run, including -1 to represent “no timeout”, and plumbs the value through WSLC’s container options, Docker API request/inspect schemas, and the CLI argument layer. It also adds unit/e2e coverage plus localized strings and help text for the new argument.

Changes:

  • Add --stop-timeout argument handling for wslc container create|run, validation, and help text updates.
  • Plumb stop-timeout through WSLC container options into Docker create/stop requests and surface it in inspect output.
  • Add unit tests and e2e tests covering valid/invalid stop-timeout values (including -1).

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/windows/WSLCTests.cpp Adds API-level tests for stop timeout behavior and inspect wiring.
test/windows/wslc/e2e/WSLCE2EContainerRunTests.cpp Adds container run e2e tests + help output expectation for --stop-timeout.
test/windows/wslc/e2e/WSLCE2EContainerCreateTests.cpp Adds container create e2e tests + help output expectation for --stop-timeout.
src/windows/wslcsession/WSLCContainer.cpp Validates/forwards stop timeout on create/stop and maps inspect StopTimeout.
src/windows/wslcsession/DockerHTTPClient.h Updates StopContainer signature to accept signed timeout.
src/windows/wslcsession/DockerHTTPClient.cpp Sends signed t= query parameter for stop timeout.
src/windows/wslc/tasks/ContainerTasks.cpp Parses --stop-timeout into container options.
src/windows/wslc/services/ContainerService.cpp Applies parsed stop timeout to WSLCContainerLauncher.
src/windows/wslc/services/ContainerModel.h Adds StopTimeout to ContainerOptions; updates stop default sentinel usage.
src/windows/wslc/commands/ContainerRunCommand.cpp Registers --stop-timeout as a supported run argument.
src/windows/wslc/commands/ContainerCreateCommand.cpp Registers --stop-timeout as a supported create argument.
src/windows/wslc/arguments/ArgumentValidation.cpp Adds integer validation for the stop-timeout argument.
src/windows/wslc/arguments/ArgumentDefinitions.h Defines the stop-timeout argument and localized description hook.
src/windows/service/inc/wslc.idl Introduces stop-timeout constants and adds StopTimeout to WSLCContainerOptions.
src/windows/inc/wslc_schema.h Extends WSLC inspect schema to include StopTimeout.
src/windows/inc/docker_schema.h Extends Docker create/inspect schema to include StopTimeout (and StopSignal in inspect config).
src/windows/common/WSLCContainerLauncher.h Adds stop-timeout setter/state with default sentinel.
src/windows/common/WSLCContainerLauncher.cpp Populates WSLCContainerOptions.StopTimeout from launcher state.
src/windows/common/APICompat.cpp Ensures compat conversion sets StopTimeout to default sentinel.
localization/strings/en-US/Resources.resw Adds localized strings for invalid stop-timeout and CLI arg description.

Comment thread test/windows/WSLCTests.cpp Outdated
Comment thread src/windows/service/inc/wslc.idl
Comment thread src/windows/service/inc/wslc.idl Outdated
Copilot AI review requested due to automatic review settings June 26, 2026 22:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.

Comment thread src/windows/wslcsession/WSLCContainer.cpp
Comment thread test/windows/WSLCTests.cpp
Comment thread test/windows/wslc/e2e/WSLCE2EContainerStopTests.cpp
@OneBlue OneBlue marked this pull request as ready for review June 27, 2026 00:18
@OneBlue OneBlue requested a review from a team as a code owner June 27, 2026 00:18
Copilot AI review requested due to automatic review settings June 27, 2026 00:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 8 comments.

auto container = launcher.Launch(*m_defaultSession);

auto inspect = container.Inspect();
VERIFY_ARE_EQUAL(inspect.Config.StopTimeout.value_or(0), WSLC_STOP_TIMEOUT_NONE);
auto container = launcher.Create(*m_defaultSession);

auto inspect = container.Inspect();
VERIFY_ARE_EQUAL(inspect.Config.StopTimeout.value_or(-1), 0);
auto container = launcher.Launch(*m_defaultSession);

auto inspect = container.Inspect();
VERIFY_ARE_EQUAL(inspect.Config.StopTimeout.value_or(0), 1);
// Wait for at least 2 seconds for the stop to complete to prove that the default 1 second timeout was correctly overriden.
auto waitResult = WaitForSingleObject(stopThread.native_handle(), 2000);

VERIFY_ARE_EQUAL(waitResult, WAIT_TIMEOUT);
Comment on lines +1435 to +1438
ValidateStopTimeout(containerOptions.StopTimeout);

THROW_HR_IF(E_INVALIDARG, containerOptions.StopTimeout == WSLC_STOP_TIMEOUT_DEFAULT);
request.StopTimeout = static_cast<int>(containerOptions.StopTimeout);
Comment on lines +1022 to +1024
const auto inspect = InspectContainer(WslcContainerName);
VERIFY_IS_FALSE(inspect.Config.StopTimeout.has_value());
}
Comment on lines +773 to +775
const auto inspect = InspectContainer(WslcContainerName);
VERIFY_IS_FALSE(inspect.Config.StopTimeout.has_value());
}
Comment on lines 238 to 240
}

WSLC_TEST_METHOD(WSLCE2E_Container_Stop_ValidTimeoutNegativeOne)
{
// Run a container in the background
auto result = RunWslc(std::format(L"container run -d --name {} {} sleep infinity", WslcContainerName, DebianImage.NameAndTag()));
result.Verify({.Stderr = L"", .ExitCode = 0});
const auto containerId = result.GetStdoutOneLine();
VERIFY_IS_FALSE(containerId.empty());

// Verify container is running
VerifyContainerIsListed(containerId, L"running");

// -1 is a valid timeout value
result = RunWslc(std::format(L"container stop {} -t -1", containerId));
result.Verify({.Stderr = L"", .ExitCode = 0});

// Verify the container is no longer running
VerifyContainerIsListed(containerId, L"exited");
}

private:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants