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

Steampipe returns 0 exit code when a plugin fails to do "something" #3044

Closed
captainfalcon23 opened this issue Jan 30, 2023 · 3 comments · Fixed by #3046
Closed

Steampipe returns 0 exit code when a plugin fails to do "something" #3044

captainfalcon23 opened this issue Jan 30, 2023 · 3 comments · Fixed by #3046
Assignees
Labels
bug Something isn't working

Comments

@captainfalcon23
Copy link

Describe the bug
Similar to #842. I use shell scripts to wrap up steampipe queries for reporting, and run them via CI/CD pipeline. The issue I am facing is, if a steampipe plugin e.g. AWS reports an error, the exit code from steampipe query is 0. This gives a false sense that the query completed successfully. I would expect that if any part of the query (or it's plugins fail) it should return a non-zero exit code. A use case for example is, a misconfiguration in aws.spc and an assume-role operation fails.

Steampipe version (steampipe -v)
steampipe version 0.17.4

To reproduce
Install AWS plugin
Add some dummy config to aws.spec
Try and do a query against AWS
Observe the error similar to below (I am running on my local machine here):

Error: rpc error: code = DeadlineExceeded desc = operation error STS: GetCallerIdentity, failed to sign request: failed to retrieve credentials: failed to refresh cached credentials, no EC2 IMDS role found, operation error ec2imds: GetMetadata, canceled, context deadline exceeded (SQLSTATE HV000)

Observe the exit code is 0:

[host ~]$ echo $?
0

Expected behavior
A non-zero exit code is returned

@captainfalcon23 captainfalcon23 added the bug Something isn't working label Jan 30, 2023
@e-gineer
Copy link
Contributor

Thanks for raising this @captainfalcon23 .... I can see the value in a non-zero exit code for a query error. I'll let @kaidaguerre comment on that part specifically.

BTW ... we have a large set of changes to the AWS plugin to help reduce IDMS throttling (among other things) that should help avoid this particular error ... Would appreciate your testing & feedback if you want to try building the branch - https://github.com/turbot/steampipe-plugin-aws/tree/creds-region-cache-refactor

@pskrbasu
Copy link
Contributor

pskrbasu commented Jan 30, 2023

@captainfalcon23 Thank you for bringing it to our attention. Yes, returning a non-zero exit code does feel right if any part of the query fails or if the plugin returns an error while streaming the rows.

We will patch it in our next release.

Thanks

@captainfalcon23
Copy link
Author

Thanks both and many thanks for a prompt reply :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants