Conversation
PR SummaryMedium Risk Overview Reviewed by Cursor Bugbot for commit e9e7190. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6dc71b4644
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| logger.L().Info(ctx, "fc process is in the D state after we call SIGKILL", logger.WithSandboxID(p.files.SandboxID)) | ||
| } | ||
|
|
||
| logger.L().Info(ctx, "sent SIGKILL to fc process", logger.WithSandboxID(p.files.SandboxID), zap.String("state", state)) |
There was a problem hiding this comment.
I would guess that getProcessState() will most commonly return error because process was killed and reaped and it no longer exists (kill syscall returns when signal was delivered). Therefore I would expect state equal to "" in most cases. I would suggest to change it to something like this:
state, err := getProcessState(ctx, p.cmd.Process.Pid)
if err != nil {
// undecided what exactly to do here, because `err` is mostly a good sign here original `Warn()` is a bit misleading.
} else {
logger.L().Info(ctx, "sent SIGKILL to fc process", logger.WithSandboxID(p.files.SandboxID), zap.String("state", state))
}There was a problem hiding this comment.
I don't like getProcessState() function. Calling extra process for one letter from /proc/<pid>/stat file is overkill. gopsutils has StatusWithContext() but it maps Linux letters to strings https://github.com/shirou/gopsutil/blob/c2a1624b9f3ed0b38ad67134b93397142ed67a23/process/process.go#L609
arkamar
left a comment
There was a problem hiding this comment.
It is probably ok to leave it as it is, but I dropped the comment for the record. The chance, that the process will exit literally right after the timer event should be close to zero.
| // captured above is 10s stale and no longer useful here. | ||
| status, stateErr := getProcessStatus(p.cmd.Process.Pid) | ||
| if stateErr != nil && !errors.Is(stateErr, process.ErrorProcessNotRunning) { | ||
| logger.L().Warn(ctx, "failed to get fc process status before SIGKILL", zap.Error(stateErr), logger.WithSandboxID(p.files.SandboxID)) |
There was a problem hiding this comment.
Should we return here? The kill will fail as well, because the process is not running anymore.
Log the process state even if in another state than
D