-
Notifications
You must be signed in to change notification settings - Fork 33
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
Create a way to get the log from the docker container. #147
Conversation
Coverage report.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks good. Two quick comments to look at.
superflore/docker.py
Outdated
cmd_string = self.get_command(tmp) | ||
if show_cmd: | ||
msg = "Running container with command string '%s'..." | ||
info(msg % self.get_command()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't regenerate the command here but use cmd_string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue with that is the fact that get_command()
without a log file will return the list, but, otherwise, shows a &&> /tmp/[tmp directory/log.txt
file.
I could perhaps just do a .replace
, but I don't think it's any more efficient at that point.
Or, if you want, I can just have it show the temporary log file mapping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to show the real values. If you mention the mounting right after that would allow people to debug easily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do
@@ -69,3 +69,17 @@ def test_pull(self): | |||
docker_instance.pull('allenh1', 'ros_gentoo_base') | |||
docker_instance.add_bash_command("echo Hello, Gentoo") | |||
docker_instance.run() | |||
|
|||
def test_get_command(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to add a test of the contents of the log output too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that's a good idea. I'll get that going right now, then!
@tfoote That great JSON error has resurfaced in the last test I added (because of the fact it has to run the container). I'm giving that one more go before I remove it from the CI tests. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Two quick comments left on the log path output.
superflore/docker.py
Outdated
cmd_string = self.get_command(tmp) | ||
if show_cmd: | ||
msg = "Running container with command string '%s'..." | ||
info(msg % self.get_command()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to show the real values. If you mention the mounting right after that would allow people to debug easily.
superflore/docker.py
Outdated
) | ||
ok("Docker container exited.") | ||
except docker.errors.ContainerError: | ||
err("Docker container exited with errors.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be good to state where the log file can be found for future reference here. In case someone wants to run it through grep or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was considering adding a --log-file
flag. I think I'll go ahead and do that. As of now, the file gets removed (since it's in a tempfile).
9eb04d8
to
1471d5e
Compare
2798ea6
to
30189c5
Compare
Ok, that should just about do it for this one!
You can now specify where to send the log.
|
…cture#147) * Added a `--verbose` flag * Added a `--log-file` argument to specify the name and path to store the log file.
This creates a logger mechanism for the docker container. We create a temporary directory using
TempfileManager
, then send thestderr
andstdout
streams into the file in append mode.This allows us to grab the output even when commands return an error code, which is more desirable than just grabbing the output of successful commands (imo).
ToDo: parameterize the verbosity, add tests.
connects to #146