Skip to content

Conversation

@pengshanyu
Copy link
Collaborator

@pengshanyu pengshanyu commented Nov 10, 2025

When retrieving QM_PID and QM_FFI_PID, extract the last line of the output to enhance code robustness.
Resolve errors that occur when warning messages appear in the output. For example:

# podman exec -it qm bash -c "podman ps"
WARN[0000] The storage 'driver' option should be set in /etc/containers/storage.conf. A driver was picked automatically. 
WARN[0000] The storage 'driver' option should be set in /etc/containers/storage.conf. A driver was picked automatically. 
CONTAINER ID  IMAGE                                           COMMAND         CREATED      STATUS      PORTS       NAMES
3609c06fda3c  quay.io/centos-sig-automotive/ffi-tools:latest  sleep infinity  2 hours ago  Up 2 hours              ffi-qm

Summary by Sourcery

Enhancements:

  • Add tail -1 when parsing podman inspect outputs and /proc/*/oom_score_adj reads to skip warning lines and improve robustness

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 10, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Modify all retrieval steps for PIDs, statuses, and file contents to pipe through tail -1 before trimming control characters, ensuring only the last line of actual data is captured despite any preceding warnings.

File-Level Changes

Change Details Files
Enforce extraction of the last line in outputs before trimming to avoid preceding warning noise
  • Pipe podman inspect PID retrieval in get_pid_with_retries through tail -1
  • Use tail -1 on /proc/* file reads in get_oom_score_adj
  • Insert tail -1 into QM_FFI_STATUS inspection pipeline
  • Insert tail -1 into QM_FFI_PID inspection pipeline
tests/ffi/qm-oom-score-adj/test.sh

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@gemini-code-assist
Copy link

Summary of Changes

Hello @pengshanyu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the robustness of shell scripts by ensuring that command outputs are correctly parsed, specifically when retrieving process IDs (PIDs), container statuses, and OOM score adjustments. By filtering command output to only the last line, the changes prevent unexpected warning messages from interfering with subsequent script logic, making the scripts more resilient to variations in command-line tool behavior.

Highlights

  • Robust PID and Status Retrieval: Modified commands that retrieve QM_PID, QM_FFI_PID, and QM_FFI_STATUS to extract only the last line of their output. This prevents issues when podman or other commands emit warning messages before the actual desired output, ensuring that only the relevant data (like PIDs or container status) is captured.
  • OOM Score Adjustment Reading: Applied the same tail -1 logic when reading the oom_score_adj value from /proc/$pid/oom_score_adj. This ensures that any potential extraneous output from cat or similar commands does not interfere with reading the numerical value.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

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

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 aims to make shell commands more robust by taking the last line of output, which is a good goal. However, the current implementation might not work as expected if warnings are printed to stderr, and it relies on TTY behavior for podman exec. I've provided suggestions to use 2>&1 to explicitly redirect stderr to stdout, which is a more robust and standard way to handle this. This also allows removing -it flags and tr commands, making the code cleaner. I've also pointed out a case where tail -1 is not necessary.

@pengshanyu pengshanyu changed the title added: extract the last line of the output "qm-oom-score-adj" added: extract the last line of the output Nov 10, 2025
Copy link
Collaborator

@Yarboa Yarboa left a comment

Choose a reason for hiding this comment

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

Consider moving this
podman inspect "$container_name" --format '{{.State.Pid}}' 2>&1 | tail -1
To a method, with 2 args, ctr_name format,

It could save the fix in 3 places

@pengshanyu pengshanyu force-pushed the fix-qm-oom-score-adj-rhel10 branch from b1bf8e9 to 93b9534 Compare November 11, 2025 14:27
@pengshanyu
Copy link
Collaborator Author

Hi @Yarboa ,
Your suggestion is great. Thank you so much for the review.
Done.

@pengshanyu
Copy link
Collaborator Author

Hi @Yarboa , could you help to review it again, thanks.

@Yarboa
Copy link
Collaborator

Yarboa commented Nov 13, 2025

WARN[0000] The storage 'driver' option should be set in /etc/containers/storage.conf.

when did that happen, the warnings?
Maybe it is better to understand what is missing

@pengshanyu
Copy link
Collaborator Author

Sure, I ping you the details.

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.

2 participants