Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13.4-stable] Enhance memory-monitor with improved logging, cleanup, and task handling #4365

Conversation

OhmSpectator
Copy link
Member

It's a backport of #4357

Simplify the process of extracting PIDs from a cgroup. Instead of using
a temporary file and filtering tasks to find unique PIDs based on TIDs,
the script now directly reads the `cgroup.procs` file to retrieve the
PIDs. This approach reduces complexity, removes the need for
intermediate processing, and improves the efficiency of PID retrieval.
The redundant temporary task list creation has been removed to
streamline the code.

Signed-off-by: Nikolay Martyanov <[email protected]>
(cherry picked from commit 0a6aedf)
This update moves the file cleanup process to an exit handler to ensure
it runs even if the script encounters an error. By trapping the cleanup
function, the script reliably archives old files, deletes temporary
files, and maintains the total archive size below 100 MB. This change
addresses a previous issue where errors could lead to leftover files not
being removed, enhancing the overall reliability and resource
management.

Signed-off-by: Nikolay Martyanov <[email protected]>
(cherry picked from commit e71af37)
Add functionality to capture and log the last 10 lines of the handler
script output when it exits with a non-zero status. This ensures that
relevant log information is sent to syslog, making it accessible to log
aggregation tools for better visibility.

* Introduced `get_tail()` to extract the last n lines of a log file.
* Updated the script handler logic to send the last 10 lines to syslog
  upon failure.

This enhancement improves error diagnosis by ensuring failed handler
output is readily available in centralized logging systems.

Signed-off-by: Nikolay Martyanov <[email protected]>
(cherry picked from commit d65d6a0)
Copy link
Contributor

@eriknordmark eriknordmark left a comment

Choose a reason for hiding this comment

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

LGTM

@OhmSpectator OhmSpectator merged commit 99f3f9e into lf-edge:13.4-stable Oct 17, 2024
39 checks passed
@OhmSpectator OhmSpectator deleted the backport/13.4/improve-memory-monitor-clean-ups branch October 17, 2024 08:22
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