-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Jenkins: "aws logs tail ${log_group} --follow" stdout is stuck #7234
Comments
Hi @orlovw, thanks for reaching out and sorry to hear that you're having trouble. It looks like you're installing CLI v2 via pip which we do not officially support, unfortunately. Here's our official documentation on how to install/updates AWS CLI: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html. Also I was able to successfully use Please let me know if you have any other questions! |
@aBurmeseDev I will try to install it not using pip tomorrow and test again, also have you tried to run it inside Jenkins? It's the most important part here, because Jenkins works really weird with some commands stdout. |
@aBurmeseDev I did following steps on my laptop to 100% about my testing, I'm using MacOS
Checking installation
3.1 Running
3.2 Running my Lambda
4.1 I have installed Jenkins locally:
Got to 127.0.0.1:8080 and configured it as default as possible
4.3 Started it and after it started lambda, waatching for new logs, but
Logs are not shown |
Thank you for sharing this detailed step-by-step workflow @orlovw. Based on what you're describing this sounds like a problem that may be unique to Jenkins, as it returned the logs until Jenkins get installed. Have you tried reaching out to Jenkins support regarding the |
@aBurmeseDev I will reach out Jenkins support, but can you confirm from your side that you have the same behaviour, I don't want to be alone with my problem and want to know that you were able to reproduce it/understand it as me Thanks :') |
As far as reproducing goes with AWS CLI commands
This issue will auto-close in couple days but if you have further issue with AWS CLI, please feel free to open a new issue. Thank you! |
@aBurmeseDev Update on issue, I've tried to play around with it a little bit more. The interesting thing is if your logs hit limit of default Python buffer size of if you want I can close that issue and propose new improvment to make stdout bufer configurable. 🤔 P.S. Found similar issues for other commands as well: P.S.S working on POC to prove that issue in buffer |
Finally!! found workaround, it took ~1w to found, I'm quite tired right now tbh 💀 TL;DR;
Linux
More detailed explanation:We know that issue appears only on Jenkins, but why? As you might know Jenkins runs
To prove it let's take a look at processes we have during Jenkins sh run:
Looking into code: Line 368 in 1423cca
It's used only to ensure should we colorise output or not, but that's not the only thing TTY changes. Also if we are running inside TTY means that should not cache neither stdout neither stdin. Why? Because caching stdin or stdout may result in infinite waiting for input parameters for stdin and delayed output for stdout. We understood that awscli thinks we are running in non-TTY (non-human readable console), so caching is OK thing to do. It increases performance a lot. But it's not we want to achive in Jenkins - we need to trick awscli, so it will think we are running into TTY. The first issue on StackOverflow: https://stackoverflow.com/questions/1401002/how-to-trick-an-application-into-thinking-its-stdout-is-a-terminal-not-a-pipe brings us to response, now stdout in real-time + as a bonus it's now colorized! cool! 😎 👨🎨 P.S I don't think it's the best workaround in the world, even more I think AWS cli must have option like |
|
Hi I believe this issue needs to be re-opened, we have the same problem when trying to pipe the output of aws logs tail to a formatter. The buffer is causing us massive headaches. PYTHONUNBUFFERED does not seem to be respected as well :/ @aBurmeseDev any advice here? Specifically we try: And |
Describe the bug
I have state machine, which is monitored in loop in Jenkins. Meanwhile I want to watch logs in Cloudwatch, using:
But it's just doesn't have any output. Without follow it works fine, looks like it's buffering issue, because I haven't found
sys.stdout.flush()
invoked in code normally, it's used only while facing errors.But I can see output using
my guess it's beacuse using
--debug
stdout is redirected to stderr, and last one is not bufferedAlso using other tools I also can tail logs without any problems:
What have I tried:
PYTHONUNBUFFERED=1
- no effectstdbuf -o 0
stdbuf -o L
since=0s
and many other cli flagsExpected Behavior
I can see logs in my Jenkins job
Current Behavior
I can see logs in my Jenkins job only with
--debug
flagReproduction Steps
Create Jenkins job, add stage with
tail --follow
commandPossible Solution
Add
sys.stdout.flush()
to code as an cli option, or respectPYTHONUNBUFFERED
env variableAdditional Information/Context
It's really weird, I killed 3 days to debug already 🤯
I haven't tried
aws logs tail --follow
with other CI/CD tools, but I guess it might have the same problemCLI version used
aws-cli/2.7.27
Environment details (OS name and version, etc.)
Python/3.9.11 Linux/5.10.102-99.473.amzn2.x86_64 exe/x86_64.amzn.2 prompt/off
The text was updated successfully, but these errors were encountered: