← Back to issue list

Check for a running process should be more fine-grained

View original Github issue

Metadata

Project
craft-providers
Number
#468
Type
issue
State
open
Author
mr-cal
Labels
Type: Enhancement
Created
Updated
Closed
—

Current evaluation

Enhancement: the LXD launcher's creator-PID liveness check only tests Path('/proc/<pid>').exists(); suggested fix is to also verify /proc/<pid>/cmdline is a python process so PID reuse triggers immediate cleanup instead of a 60s wait. Still unimplemented.

Suggested action: keep open

Reason: The current code at craft_providers/lxd/launcher.py:688 still only does `if Path(f"/proc/{pid}").exists():`, so the coarse check described in the issue is still present and the enhancement is not implemented. The issue is maintainer-authored, labelled 'Type: Enhancement', and carries a concrete design proposal ('checking that /proc/<pid>/cmdline is a python process') plus explicit current/new behavior, and the single change site is small and already covered by unit tests (tests/unit/lxd/test_launcher.py:1407-1470). Main uncertainty: zero comments for 1038 days, and the heuristic needs decisions (what counts as 'python', handling unreadable /proc/<pid>/cmdline under hidepid/permissions) that may need maintainer input.

Evaluated by: mr-cal-bot

Impact: 28 Quick Win: 18 Complexity: 22 Confidence: 80 Actionability: 82

Issue body

### What needs to get done Improve the granularity of the check that checks if the process that launched an instance is still active. Currently, craft-providers will only check that the PID that created an instance exists. This could be improved by checking that `/proc/<pid>/cmdline` is a python process. Suggested by @syu-w in https://github.com/canonical/craft-providers/pull/464#discussion_r1408411018 ### Why it needs to get done If the PID that launched the instance is currently in-use by another process, it may add a 60 second delay before the instance is auto-cleaned. Consider a scenario where craft-providers created a base instance with pid 100, but the instance was not fully setup and pid 100 is now assigned to another active process (due to a reboot or the pid counter being reset). ### Current behavior 1. Craft-providers sees the base instance is not ready and pid 100 is active 2. Craft-providers waits for the instance to be ready. If it is not ready and the instance's timer hasn't changed in 60 seconds, then it auto-cleans the instance. ### New behavior 1. Craft-providers sees the base instance is not ready and that pid 100 is active but not a python process. 2. Craft-providers immediately auto-cleans the instance.

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha
Impact: 28
Quick Win: 18
Complexity: 22
Confidence: 80
Actionability: 82
keep open Enhancement: the LXD launcher's creator-PID liveness check only tests Path('/proc/<pid>').exists(); suggested fix is to also verify /proc/<pid>/cmdline is a python process so PID reuse triggers immediate cleanup instead of a 60s wait. Still unimplemented.
stealth/space-bunny-alpha
Impact: 40
Quick Win: 23
Complexity: 35
Confidence: 96
Actionability: 88
keep open LXD cleanup still treats any existing creator PID as active; validate /proc/<pid>/cmdline to detect PID reuse and avoid a 60-second wait.
stealth/space-bunny-alpha
Impact: 36
Quick Win: 24
Complexity: 28
Confidence: 97
Actionability: 92
keep open LXD base-instance readiness only checks whether the creator PID exists; a reused non-Python PID can cause an unnecessary 60-second wait. The requested /proc/<pid>/cmdline check remains unimplemented.
qwen3.6-35b-a3b-mtp-q6
Impact: 40
Quick Win: 28
Staleness: 85
Complexity: 30
Confidence: 75
Support Request: 10
close stale Enhancement to verify PID is a Python process via /proc/<pid>/cmdline instead of just checking PID existence, avoiding 60s delay on PID reuse. Open 1010 days with no comments or implementation.
qwen/qwen3.6-35b-a3b
Staleness: 85
Complexity: 20
Confidence: 80
Support Request: 0
needs triage Enhancement to improve PID reuse detection by checking process command line instead of just existence. Open for 2.5 years with no maintainer discussion, comments, or assignee.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 20
Confidence: 75
Support Request: 0
needs triage Enhancement to refine process existence checks in craft-providers by verifying the PID runs a Python process, preventing unnecessary auto-cleanup delays when PIDs are reused. Currently unassessed with no maintainer comments.

Update history

No update history recorded yet.

Related work

  • Related To: canonical/craft-providers#464 (confidence 90%)

    Issue body cites PR #464 discussion_r1408411018 (syu-w) as the origin of the suggestion; that PR landed as commit d5c194b 'fix(lxd): store and check PID when launching instances (#464)', which introduced the coarse /proc/<pid> check this issue refines.

Related issues

No related issues found above the similarity threshold.