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

[RFC] Logs tty #296

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

[RFC] Logs tty #296

wants to merge 1 commit into from

Conversation

cswinter
Copy link
Contributor

PoC for fixing #295. Works well enough as a workaround for my use case, but the current implementation still has some issues which I would like to get feedback on how to best resolve:

  • The library user needs to correctly choose between logs_tty and logs, and choosing the wrong one will either produce additional garbage in stout from multiplexing headers or fail to return any input at all. The approach taken by the docker CLI is to run an inspect first to determine if the container uses tty: https://github.com/docker/cli/blob/86e1f04b5f115fb0b4bbd51e0e4a68233072d24b/cli/command/container/logs.go#L53. This would require an additional request, but imo worth it to allows to have a single method without any additional arguments that always returns the correct result.
  • The impl types returned by the different streams are not compatible, an alternative would be to return Box<dyn Stream<Item = _> + Unpin>. Overhead is probably pretty minimal compared to network IO.
  • Current implementation does a lot of unnecessary allocations which are probably easily avoidable for someone who knows more about Stream-munging than I do.

@cswinter
Copy link
Contributor Author

Oh one more issue, the logs_tty function now never terminates as long as the container is alive even when you don't set tail. Not sure how to correctly detect the end of the current output.

@matthiasbeyer
Copy link
Collaborator

Requested @softprops review here because I really don't know 🤷

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.

2 participants