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

Return error status from --test if any of the input plugins produced an error #6279

Merged
merged 1 commit into from
Aug 16, 2019

Conversation

fhriley
Copy link
Contributor

@fhriley fhriley commented Aug 16, 2019

A couple notes:

  1. I added a separate --test-status option to telegraf to implement this. I did this to maintain backwards compatibility in case anyone is depending on the current behavior of always returning 0.

  2. The exec plugin was always returning no error. I fixed this plugin since we are using it. It is possible other plugins are also not correctly returning any errors.

closes: #6278

Required for all PRs:

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

@fhriley fhriley changed the title Test status Fix issue #6278 Aug 16, 2019
@danielnelson
Copy link
Contributor

Thanks for opening a pull request, I have a few high level ideas:

I don't think we need to add a new cli flag, if there are any errors during test we can return 1.

For plugins like exec with multiple commands, or plugins that connect to multiple remote services, we don't actually want to fish the error out and instead use the AddError function on the accumulator. This prevents multiple logging and keeps us from needing lists of errors. What we should do in Test() is call NErrors.Get() and if it is greater than 0 return an error.

@danielnelson danielnelson added the fix pr to fix corresponding bug label Aug 16, 2019
@fhriley
Copy link
Contributor Author

fhriley commented Aug 16, 2019

Updated based on your comments.

@danielnelson danielnelson modified the milestones: 1.12.0, 1.11.5 Aug 16, 2019
@danielnelson danielnelson merged commit a079e2d into influxdata:master Aug 16, 2019
danielnelson pushed a commit that referenced this pull request Aug 16, 2019
@danielnelson danielnelson changed the title Fix issue #6278 Return error status from --test if any of the input plugins produced an error Aug 26, 2019
bitcharmer pushed a commit to bitcharmer/telegraf that referenced this pull request Oct 18, 2019
athoune pushed a commit to bearstech/telegraf that referenced this pull request Apr 17, 2020
idohalevi pushed a commit to idohalevi/telegraf that referenced this pull request Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix pr to fix corresponding bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--test does not return a correct status
2 participants