Skip to content

Commit

Permalink
Allow UEPs to create log files
Browse files Browse the repository at this point in the history
If a log file exists, then `os.open` was opening the file as expected.  But I
forgot to include the `O_CREAT` flag so new endpoints would fail to start when
the log file would fail to open.  Whoops!

Luckily we caught this before the recent log changes were released; no
changelog necessary.
  • Loading branch information
khk-globus committed Sep 25, 2024
1 parent 57680b4 commit cf8e73e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,8 @@ def cmd_start_endpoint(
exit_code += 1

log.debug("Convey credentials; redirect stdout, stderr (to '%s')", ep_log)
log_fd = os.open(ep_log, os.O_WRONLY | os.O_APPEND | os.O_SYNC, mode=0o200)
log_fd_flags = os.O_CREAT | os.O_WRONLY | os.O_APPEND | os.O_SYNC
log_fd = os.open(ep_log, log_fd_flags, mode=0o200)
with os.fdopen(log_fd, "w") as log_f:
if os.dup2(log_f.fileno(), 1) != 1:
raise OSError(f"Unable to redirect stdout to {ep_log}")
Expand Down
3 changes: 2 additions & 1 deletion compute_endpoint/tests/unit/test_endpointmanager_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1958,7 +1958,8 @@ def test_redirect_stdstreams_to_user_log(
mock_os.O_WRONLY = 0x1
mock_os.O_APPEND = 0x2
mock_os.O_SYNC = 0x4
exp_flags = mock_os.O_WRONLY | mock_os.O_APPEND | mock_os.O_SYNC
mock_os.O_CREAT = 0x8
exp_flags = mock_os.O_CREAT | mock_os.O_WRONLY | mock_os.O_APPEND | mock_os.O_SYNC

uep_name = command_payload["kwargs"]["name"]
uep_dir = mock_ensure_compute_dir() / uep_name
Expand Down

0 comments on commit cf8e73e

Please sign in to comment.