def clean_up_k8s_logs_from_job_output(logs: str) -> str:
    """Remove any log messages prepended to job output by k8s."""
    # This would ideally be handled inside RobustaJob.run_simple_job_spec, but the general
    # job output processing code does not assume JSON output, so identifying spurious text
    # would be problematic.
    # Note this code is not able to correctly handle log messages containing endlines. Doing
    # so would be impossible in some cases (like "{" following and endline) and/or
    # require meticulous parsing of k8s log messages.
    while logs and not logs.startswith("{"):
        # Assume every line not looking like JSON is log information added by k8s
        endline_pos = logs.find("\n")
        if endline_pos == -1:
            logs = ""
        else:
            logs = logs[endline_pos + 1 :]
    return logs
Remove any log messages prepended to job output by k8s.
playbooks/robusta_playbooks/popeye.py