Skip to content

Skip inaccessible processes in health check script detection - #5543

Merged
Xeicker merged 1 commit into
masterfrom
fix-health-check-access-denied
Oct 16, 2026
Merged

Xeicker merged 1 commit into
masterfrom
fix-health-check-access-denied

Conversation

@Xeicker

@Xeicker Xeicker commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

scripts_are_running() called process.cmdline() on every process without handling psutil errors. On Windows Server 2025, protected processes raise psutil.AccessDenied, which propagated out of the health check RequestHandler and made the server close the connection without sending a response. As a result, the MIG health check never succeeded and the instances were recreated by autohealing.

Skip processes whose command line cannot be read, matching the handling already done in terminate_processes_matching_cmd_line() in src/clusterfuzz/_internal/system/process_handler.py

scripts_are_running() called process.cmdline() on every process without
handling psutil errors. On Windows Server 2025, protected processes
raise psutil.AccessDenied, which propagated out of the health check
RequestHandler and made the server close the connection without sending
a response. As a result, the MIG health check never succeeded and the
instances were recreated by autohealing.

Skip processes whose command line cannot be read, matching the handling
already done in terminate_processes_matching_cmd_line().
@Xeicker
Xeicker requested a review from a team as a code owner October 15, 2026 22:10
@Xeicker
Xeicker requested a review from IvanBM18 October 15, 2026 22:10

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request improves the process handler's robustness by catching exceptions (such as AccessDenied, NoSuchProcess, and OSError) when retrieving a process's command line, ensuring that protected or inaccessible system processes are skipped rather than causing the health check to fail. A corresponding unit test was added to verify this behavior. Feedback on the changes points out a potential issue where a list is modified during iteration, which can lead to skipped elements, and suggests iterating over a copy of the list instead.

Comment thread src/clusterfuzz/_internal/system/process_handler.py

@g-ortuno g-ortuno left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm!

@g-ortuno g-ortuno added the ready for GOSST review Pull requests ready for GOSST team review label Oct 16, 2026

@IvanBM18 IvanBM18 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

try:
process_cmd_line = process.cmdline()
except (psutil.AccessDenied, psutil.NoSuchProcess, OSError):
# Some processes (e.g. protected system processes on Windows Server

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

NIT:
Can you add a debug level log so that we can later verify which processes were skipped?

@IvanBM18 IvanBM18 Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Note: We can now use DEBUG level logs, but for them to be visible one would have to start a bot with the env var: LOG_LEVEL = DEBUG so no worries here

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think we wouldn't have quite useful information in that log, because the exception occurs when trying to get the command line info. So we could see that something was skipped but not really know if that was relevant

@Xeicker
Xeicker merged commit fdef5cf into master Oct 16, 2026
15 checks passed
@Xeicker
Xeicker deleted the fix-health-check-access-denied branch October 16, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for GOSST review Pull requests ready for GOSST team review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants