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

LIU-66: Download logs from all running NM as a tar archive. #46

Merged
merged 3 commits into from
Jul 19, 2021

Conversation

davepallot
Copy link
Contributor

No description provided.

@coveralls
Copy link

coveralls commented Jul 15, 2021

Coverage Status

Coverage increased (+0.05%) to 77.314% when pulling 59221e3 on liu-66 into 9d8ce20 on master.

Copy link
Contributor

@rtobar rtobar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing wrong here, I only noted small details and a potential improvement.

Comment on lines 64 to 68
if isinstance(res, bytes):
return res

if isinstance(res, bottle.HTTPResponse):
return res
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if isinstance(res, (bytes, bottle.HTTPResponse))

Comment on lines 27 to 34
import io
import os
import cgi
import functools
import json
import logging
import threading
import tarfile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more of a personal preference, but could we have imports alphasorted in general? It would be nicer to have this checked automatically by a tool instead of me telling it, we could do that at some point.


content = []
while True:
buffer = stream.read()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this stream.read() read all of the contents in one go? In which case there's no need for a while around it. I guess you wanted to do a buffered read here instead and accumulate into content?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because its a tcp stream there is no guarantee that a single read will get all the data unless there is code underneath this library that is accumulating?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ill leave it for now and we can review again.

break
content.append(buffer)

tar.addfile(info, io.BytesIO(initial_bytes=''.join(content).encode()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmmm.... now that I read this: wouldn't it be possible to simply pass stream as the input of addfile and forget about collecting in content? If that's possible then you'll save some unnecessary memory copying.

def getLogFile(self, sessionId):
fh = io.BytesIO()
with tarfile.open(fileobj=fh, mode='w:gz') as tar:
for node in self.getAllCMNodes():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a TODO here to point out that in the future we might want to fetch in this loop concurrently instead of sequentially.

@davepallot davepallot merged commit 84188b4 into master Jul 19, 2021
@awicenec awicenec deleted the liu-66 branch December 14, 2021 07:59
awicenec pushed a commit that referenced this pull request May 19, 2022
LIU-66: Download logs from all running NM as a tar archive.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants