Skip to content

Commit

Permalink
Various tests for oom score, now out-commented
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Nilsson committed Oct 28, 2024
1 parent 17f1b0a commit f58d93c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion PILOTVERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.9.2.2
3.9.2.6
2 changes: 1 addition & 1 deletion pilot/util/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
RELEASE = '3' # released number should be fixed at 3 for Pilot 3
VERSION = '9' # version number is '1' for first release, '0' until then, increased for bigger updates
REVISION = '2' # revision number should be reset to '0' for every new version release, increased for small updates
BUILD = '2' # build number should be reset to '1' for every new development cycle
BUILD = '6' # build number should be reset to '1' for every new development cycle

SUCCESS = 0
FAILURE = 1
Expand Down
35 changes: 26 additions & 9 deletions pilot/util/monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,22 +205,39 @@ def display_oom_info(payload_pid):
:param payload_pid: payload pid (int).
"""
#fname = f"/proc/{payload_pid}/oom_score_adj"
fname = f"/proc/{payload_pid}/oom_score"
payload_score = get_score(payload_pid) if payload_pid else 'UNKNOWN'
pilot_score = get_score(os.getpid())

#cmd = "whoami"
#_, stdout, _ = execute(cmd)
#ogger.debug(f"stdout = {stdout}")
#cmd = f"ls -l {fname}"
#_, stdout, _ = execute(cmd)
#ogger.debug(f"stdout = {stdout}")

if isinstance(pilot_score, str) and pilot_score == 'UNKNOWN':
logger.warning(f'could not get oom_score for pilot process: {pilot_score}')
else:
#relative_payload_score = "1"
relative_payload_score = "1"
write_to_oom_score_adj(payload_pid, relative_payload_score)
logger.info(f'oom_score(pilot) = {pilot_score}, oom_score(payload) = {payload_score} (attempted writing relative score 1 to {fname})')


# write the payload oom_score to the oom_score_adj file
#try:
# write_file(path=fname, contents=relative_payload_score)
#except Exception as e: # FileHandlingFailure
# logger.warning(f'could not write oom_score to file: {e}')
def write_to_oom_score_adj(pid, value):
"""Writes the specified value to the oom_score_adj file for the given PID.
#logger.info(f'oom_score(pilot) = {pilot_score}, oom_score(payload) = {payload_score} (attempted writing relative score 1 to {fname})')
logger.info(f'oom_score(pilot) = {pilot_score}, oom_score(payload) = {payload_score}')
Args:
pid: The PID of the process.
value: The value to write to the oom_score_adj file.
"""

command = f"echo {value} > /proc/{pid}/oom_score_adj"
try:
subprocess.check_call(command, shell=True)
logger.info(f"successfully wrote {value} to /proc/{pid}/oom_score_adj")
except subprocess.CalledProcessError as e:
logger.warning(f"error writing to /proc/{pid}/oom_score_adj: {e}")


def get_score(pid) -> str:
Expand Down

0 comments on commit f58d93c

Please sign in to comment.