jorgebastida / jorgebastida/awslogs

piping "get" to head caused "IOError: [Errno 32] Broken pipe"

Open
#152 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
5k
Forks
342
PR merge metrics
No merged PRs in 30d

Description

When I issue command `awslogs get /log/group log-stream -s TIME | head`, this error is raised.
Piping to head with option that equal to or longer than std-out of "awslogs get" doesn't cause error.

```bash
================================================================================
You've found a bug! Please, raise an issue attaching the following traceback
https://github.com/jorgebastida/awslogs/issues/new
--------------------------------------------------------------------------------
Version: 0.8.0
Python: 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609]
boto3 version: 1.4.4
Platform: Linux-4.4.0-91-generic-x86_64-with-Ubuntu-16.04-xenial
Config: {'output_timestamp_enabled': False, 'output_group_enabled': True, 'end': None, 'log_group_name': '/prod/var/log/messages', 'log_stream_name': '172.20.4.11', 'aws_region': None, 'watch': False, 'aws_access_key_id': 'SENSITIVE', 'start': '2017/8/30T18:00JST', 'aws_profile': 'SENSITIVE', 'filter_pattern': None, 'aws_secret_access_key': 'SENSITIVE', 'output_ingestion_time_enabled': False, 'query': None, 'func': 'list_logs', 'aws_session_token': 'SENSITIVE', 'color_enabled': True, 'output_stream_enabled': True}
Args: ['/usr/local/bin/awslogs', 'get', '/prod/var/log/messages', '172.20.4.11', '-s2017/8/30T18:00JST']

Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/awslogs/bin.py", line 172, in main
getattr(logs, options.func)()
File "/usr/local/lib/python2.7/dist-packages/awslogs/core.py", line 187, in list_logs
consumer()
File "/usr/local/lib/python2.7/dist-packages/awslogs/core.py", line 185, in consumer
sys.stdout.flush()
IOError: [Errno 32] Broken pipe
================================================================================
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in awslogs/core.py at the consumer function and the sys.stdout.flush() call reported in the traceback. Reproduce the issue with awslogs get piped to head, then verify that the command exits without displaying the broken-pipe traceback when the downstream pipe closes early.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.