lablink_allocator_service.utils.log_tail¶
lablink_allocator_service.utils.log_tail
¶
Bounded reads of the allocator's own log file.
start.sh tees this container's entire stdout/stderr through rotatelogs
into LOG_DIR, and this module is the only way the allocator can show that
output: nothing mounts docker.sock, so it cannot run docker logs on
itself.
Flask-free on purpose -- the tailing and redaction logic is the part worth testing, and keeping it out of the route module lets it test against tmp_path with no app fixture.
Attributes¶
DEFAULT_MAX_LINES = 2000
module-attribute
¶
LOG_DIR = Path('/var/log/lablink')
module-attribute
¶
Functions:¶
read_allocator_log(log_dir=LOG_DIR, max_lines=DEFAULT_MAX_LINES)
¶
Last max_lines lines across the rotation set, cleaned and redacted.
Returns None when there is no log file to read at all -- the caller turns that into a user-facing explanation rather than an error.
Source code in packages/allocator/src/lablink_allocator_service/utils/log_tail.py
redact_secrets(text)
¶
Mask the values of secret-looking assignments, keeping the keys.