fix: Windows runner cancellation delays due to LXC script execution
Fixes issue where Windows runners experience delays in job cancellation and pickup of new jobs after cancellation. The problem occurred when Windows runners with LXC platform configuration attempted to execute Linux shell scripts during cleanup, causing failures and blocking the runner. Changes: - Add runtime OS detection in stopHostEnvironment() - Skip LXC script execution on Windows platforms - Implement Windows-specific cleanup using os.RemoveAll() - Ensure graceful error handling to prevent runner blocking - Preserve all existing LXC functionality on Linux/Unix systems The fix prevents "fork/exec stop-lxc.sh: directory name is invalid" errors and allows Windows runners to pick up new jobs immediately after cancellation, matching Linux/FreeBSD runner behavior. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
ea961a70c3
commit
2841253d05
1 changed files with 24 additions and 0 deletions
|
|
@ -260,6 +260,12 @@ func (rc *RunContext) stopHostEnvironment(ctx context.Context) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Skip LXC script execution on Windows - LXC is not supported on Windows
|
||||
if runtime.GOOS == "windows" {
|
||||
logger.Debugf("Skipping LXC cleanup on Windows")
|
||||
return rc.performWindowsHostCleanup(ctx)
|
||||
}
|
||||
|
||||
var stopScript bytes.Buffer
|
||||
if err := stopTemplate.Execute(&stopScript, struct {
|
||||
Name string
|
||||
|
|
@ -281,6 +287,24 @@ func (rc *RunContext) stopHostEnvironment(ctx context.Context) error {
|
|||
)(ctx)
|
||||
}
|
||||
|
||||
func (rc *RunContext) performWindowsHostCleanup(ctx context.Context) error {
|
||||
logger := common.Logger(ctx)
|
||||
|
||||
// Clean up the container root directory
|
||||
if rc.JobContainer != nil {
|
||||
root := rc.JobContainer.GetRoot()
|
||||
if root != "" {
|
||||
logger.Debugf("Cleaning up Windows host directory: %s", root)
|
||||
if err := os.RemoveAll(root); err != nil {
|
||||
logger.Debugf("Failed to remove directory %s: %v", root, err)
|
||||
// Don't fail cleanup if directory removal fails - this prevents blocking
|
||||
// the runner from picking up new jobs due to file system issues
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rc *RunContext) startHostEnvironment() common.Executor {
|
||||
return func(ctx context.Context) error {
|
||||
logger := common.Logger(ctx)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue