fugue / credstash

A little utility for managing credentials in the cloud
Apache License 2.0
2.06k stars 215 forks source link

Logging to file #271

Closed vrgurus closed 4 years ago

vrgurus commented 4 years ago

Writing log to file causing issue where file creation is not permitted. ( Specially when used in aws lambda)

https://github.com/fugue/credstash/blob/2dec65f1070f5c17d46024f40ce5b448ea1b5196/credstash.py#L83

erik-thompson-seattle commented 4 years ago

Affects AWS CodeDeploy agent as well as we cannot control the path creation.

Why not use a flag to control the creation like in the below example https://www.programcreek.com/python/example/472/logging.FileHandler

or a path override.

erincerys commented 4 years ago

This affects me within a Docker container on EC2.

root@ip-172-16-143-246:/usr/local/nagios/libexec# credstash -r us-west-2 get <key> <context>
Traceback (most recent call last):
  File "/usr/local/bin/credstash", line 7, in <module>
    from credstash import main
  File "/usr/local/bin/credstash.py", line 83, in <module>
    setup_logging(logging.WARNING, 'credstash.log')
  File "/usr/local/bin/credstash.py", line 73, in setup_logging
    if logger.hasHandlers():
AttributeError: 'Logger' object has no attribute 'hasHandlers'

Downgrading to 1.16.1 resolves this problem.

erik-thompson-seattle commented 4 years ago

Yes we pinned to 1.16.1 as well to work around the issue. as updating all code references to pass in a log file is not practical

erincerys commented 4 years ago

Agreed. I found this problem by updating several Docker container images which did not pin the version. Scripts running within them broke when attempting to retrieve secrets used for them to function. Minor version changes or arguably any newly added options to a stable application shouldn't break previously valid usage. In my case, I'll never use this feature, because my scripts capture stderr. I have no need to incur disk operations to do error handling.

jussi-ft commented 4 years ago

Ran into same issue with credstash-1.16.2. Downgraded with command pip install credstash==1.16.1 and credstash is operational again.

duttonw commented 4 years ago

Seems this commit introduced the problem. https://github.com/fugue/credstash/commit/aa43bfbe55d285eaab264c0b4bd75b19a3788b7e