Skip to content

Conversation

twz123
Copy link
Member

@twz123 twz123 commented Oct 2, 2025

Description

This simplifies the component code quite a bit, and removes the PowerShell dependency. This way, containerd on Windows is no different than on Linux, modulo the following:

  • There are no signals on Windows, so the SIGHUP trick that tells containerd to reload its configuration won't work. In this case, fall back to a full stop/start cycle.

  • There's a bug in containerd 1.x on Windows that prevents it from properly responding to Ctrl+C and Ctrl+Break events. Apply the 2.x one-liner patch to the 1.x codebase so the Supervisor can stop it.

  • On Windows, containerd requires the special SeAssignPrimaryTokenPrivilege, which allows processes to logon any user without knowing the password. This privilege is not granted to administrator accounts, it is only granted to the built-in SYSTEM and LOCAL SERVICE accounts. Since containerd will inherit k0s's privileges, it can only function properly if k0s itself has this privilege. Therefore, k0s must be run as a service. Consequently, running a k0s worker in a terminal with a standard administrator account will result in containerd throwing permission errors when running containers. This is an acceptable trade-off IMO, as any real setup will involve using Windows services anyway. For quick manual testing, dealing with the container errors is acceptable.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

  • Manual test
  • Auto test added

Checklist

  • My code follows the style guidelines of this project
  • My commit messages are signed-off
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

twz123 added 4 commits October 2, 2025 17:51
Otherwise, the process might not terminate gracefully. Moreover, this is
in fact something worth checking.

Also fix some log statements around this.

Signed-off-by: Tom Wieczorek <twieczorek@mirantis.com>
Don't try to reattach to the parent console after sending the Ctrl+Break
event. The only reason this was done was the assumption that it would be
required for capturing stderr in k0s. Turns out that this is not true.
Since k0s installs pipes as the child process's stdout/stderr, they
remain valid even after detaching from the console.

Signed-off-by: Tom Wieczorek <twieczorek@mirantis.com>
Sending a direct Ctrl+Break event might fail if k0s itself is not
attached to a console. This is usually the case when running as a
service. Fall back to the termination helper in this case.

Signed-off-by: Tom Wieczorek <twieczorek@mirantis.com>
This simplifies the component code quite a bit, and removes the
PowerShell dependency. This way, containerd on Windows is no different
than on Linux, modulo the following:

- There are no signals on Windows, so the SIGHUP trick that tells
  containerd to reload its configuration won't work. In this case, fall
  back to a full stop/start cycle.

- There's a bug in containerd 1.x on Windows that prevents it from
  properly responding to Ctrl+C and Ctrl+Break events. Apply the 2.x
  one-liner patch to the 1.x codebase so the Supervisor can stop it.

- On Windows, containerd requires the special
  SeAssignPrimaryTokenPrivilege, which allows processes to logon any
  user without knowing the password. This privilege is not granted to
  administrator accounts, it is only granted to the built-in SYSTEM
  and LOCAL SERVICE accounts. Since containerd will inherit k0s's
  privileges, it can only function properly if k0s itself has this
  privilege. Therefore, k0s must be run as a service. Consequently,
  running a k0s worker in a terminal with a standard administrator
  account will result in containerd throwing permission errors when
  running containers. This is an acceptable trade-off IMO, as any real
  setup will involve using Windows services anyway. For quick manual
  testing, dealing with the container errors is acceptable.

Signed-off-by: Tom Wieczorek <twieczorek@mirantis.com>
@twz123 twz123 force-pushed the supervise-containerd branch from 248ed8e to 8cef60d Compare October 2, 2025 15:53
@twz123 twz123 marked this pull request as ready for review October 2, 2025 16:49
@twz123 twz123 requested review from a team as code owners October 2, 2025 16:49
@twz123 twz123 force-pushed the supervise-containerd branch from 8cef60d to 2f9e4a3 Compare October 3, 2025 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant