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

Log retrieval #197

Open
jennydaman opened this issue Feb 18, 2022 · 1 comment
Open

Log retrieval #197

jennydaman opened this issue Feb 18, 2022 · 1 comment

Comments

@jennydaman
Copy link
Collaborator

jennydaman commented Feb 18, 2022

Log retrieval is problematic for two reasons:

Single Stream instead of stdout/stderr

In CUBE, pfcon, and pman, there is no distinction between stdout and stderr. Either the two output streams are joined, or one is disregarded.

Buffering full logs instead of streaming

def get_job_logs(self, job: J) -> str:

Internally, the AbstractManager interface does not support streaming (or chunking/pagination) of large logs. Plugin instances which produce a lot of output will cause pman to hang and time out when attempting to retrieve the logs.

Also, the AbstractManager interface is changed: get_job_logs returns typing.AnyStr which more accuately describes the data type of a container's logs. The encoding is handled in pman/services.py instead, an improvement over a previous hotfix b41cefb.

openshiftmgr.py is not fixed because I think it should be rewritten from the ground-up.

@jennydaman
Copy link
Collaborator Author

jennydaman commented Mar 9, 2022

Moreover, output is not necessarily UTF-8 string data. Non-UTF-8 data printed to terminal causes This wasn't handled:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.8/dist-packages/flask_restful/__init__.py", line 467, in wrapper
    resp = resource(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/flask/views.py", line 89, in view
    return self.dispatch_request(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/flask_restful/__init__.py", line 582, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/home/localuser/pman/pman/resources.py", line 164, in get
    job_logs = self.compute_mgr.get_job_logs(job)
  File "/home/localuser/pman/pman/swarmmgr.py", line 59, in get_job_logs
    return ''.join([l.decode() for l in job.logs(stdout=True, stderr=True)])
  File "/home/localuser/pman/pman/swarmmgr.py", line 59, in <listcomp>
    return ''.join([l.decode() for l in job.logs(stdout=True, stderr=True)])
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 0: unexpected end of data

Now fixed: b41cefb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant