Skip to content

[ci] test: rl-insight monitor add ci#86

Draft
mengchengTang wants to merge 1 commit into
verl-project:mainfrom
mengchengTang:ci_test
Draft

[ci] test: rl-insight monitor add ci#86
mengchengTang wants to merge 1 commit into
verl-project:mainfrom
mengchengTang:ci_test

Conversation

@mengchengTang

@mengchengTang mengchengTang commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

monitor add ci

Checklist Before Starting

  • Search for similar PRs. Paste at least one query link here: ...
  • Format the PR title as [{modules}] {type}: {description} (This will be checked by the CI)
    • {modules} include:
      • monitor-api, monitor-cli, monitor-collector, monitor-server, monitor-config for online monitor changes
      • recipe for offline analysis changes, including pipeline, parser, visualizer, data checker, recipe config, examples, and sample data
      • doc, ci, perf, deployment, misc for cross-cutting changes
    • If this PR involves multiple modules, separate them with , like [recipe, ci] or [monitor-server, monitor-config]
    • {type} is in feat, fix, refactor, chore, test
    • If this PR breaks any API (CLI arguments, config, function signature, etc.), add [BREAKING] to the beginning of the title.
    • Example: [BREAKING][mstx, torch_profile] feat: support timeline parsing

Test

For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc.

API and Usage Example

Demonstrate how the API changes if any, and provide usage example(s) if possible.

# Add code snippet or script demonstrating how to use this

Design & Code Changes

Demonstrate the high-level design if this PR is complex, and list the specific changes.

Checklist Before Submitting

Important

Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request adds the "requests" dependency and introduces a comprehensive test suite for the "rl_insight" monitoring API, configuration loader, server commands, and end-to-end server lifecycle. The review feedback highlights critical improvements in "tests/monitor/test_server_lifecycle_e2e.py" to ensure robust parsing of "/proc/{pid}/stat" when process names contain spaces or parentheses, and to implement safer process termination logic that avoids calling "os.killpg" on non-group leaders or accidentally terminating the test runner's own process group.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +365 to +372
proc_stat = Path(f"/proc/{pid}/stat")
if proc_stat.exists():
try:
fields = proc_stat.read_text(encoding="utf-8").split()
except OSError:
return True
if len(fields) > 2 and fields[2] == "Z":
return False

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.

medium

Parsing /proc/{pid}/stat by simply splitting on whitespace can fail if the process name (enclosed in parentheses) contains spaces or parentheses. A more robust approach is to find the last closing parenthesis ) first, and then split the remaining string to extract the process state.

Suggested change
proc_stat = Path(f"/proc/{pid}/stat")
if proc_stat.exists():
try:
fields = proc_stat.read_text(encoding="utf-8").split()
except OSError:
return True
if len(fields) > 2 and fields[2] == "Z":
return False
proc_stat = Path(f"/proc/{pid}/stat")
if proc_stat.exists():
try:
stat_content = proc_stat.read_text(encoding="utf-8")
except OSError:
return True
rpar = stat_content.rfind(")")
if rpar != -1:
fields = stat_content[rpar + 1 :].split()
if fields and fields[0] == "Z":
return False

Comment on lines +380 to +386
try:
os.killpg(pid, signal.SIGTERM)
except OSError:
try:
os.kill(pid, signal.SIGTERM)
except OSError:
continue

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.

medium

Calling os.killpg(pid, ...) directly with a process ID that is not a process group leader is conceptually incorrect and will fail with ProcessLookupError. Furthermore, if we attempt to kill the process group, we must ensure we do not accidentally kill the test runner's own process group (which would abort the entire test suite). It is safer to kill the process itself first, and then only kill its process group if it is different from the current process group.

Suggested change
try:
os.killpg(pid, signal.SIGTERM)
except OSError:
try:
os.kill(pid, signal.SIGTERM)
except OSError:
continue
try:
os.kill(pid, signal.SIGTERM)
try:
pgid = os.getpgid(pid)
if pgid != os.getpgrp():
os.killpg(pgid, signal.SIGTERM)
except OSError:
pass
except OSError:
continue

Comment on lines +395 to +401
try:
os.killpg(pid, signal.SIGKILL)
except OSError:
try:
os.kill(pid, signal.SIGKILL)
except OSError:
pass

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.

medium

Apply the same safe termination logic for SIGKILL to avoid conceptually incorrect os.killpg calls and prevent accidentally killing the test runner's own process group.

Suggested change
try:
os.killpg(pid, signal.SIGKILL)
except OSError:
try:
os.kill(pid, signal.SIGKILL)
except OSError:
pass
try:
os.kill(pid, signal.SIGKILL)
try:
pgid = os.getpgid(pid)
if pgid != os.getpgrp():
os.killpg(pgid, signal.SIGKILL)
except OSError:
pass
except OSError:
pass

@tardis-key tardis-key marked this pull request as draft June 23, 2026 08:48
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.

1 participant