-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
feat(agent): Add support for input probing #16333
base: master
Are you sure you want to change the base?
feat(agent): Add support for input probing #16333
Conversation
Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip. 📦 Click here to get additional PR build artifactsArtifact URLs |
startup_error_behavior = "probe"
): Add support for input probing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @LandonTClipp for the PR! Some minor comments in the code, the most important one is to call Stop
if probing fails to not leak connections or the like.
agent/agent.go
Outdated
log.Printf("I! [agent] Failed to probe %s, shutting down plugin: %s", input.LogName(), err) | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you must call Stop
for the input as it successfully passed the Start
stage...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call! Done.
models/running_input_test.go
Outdated
func TestRunningInputProbing(t *testing.T) { | ||
probeErr := errors.New("probing error") | ||
for _, tt := range []struct { | ||
name string | ||
input telegraf.Input | ||
startupErrorBehavior string | ||
expectedError bool | ||
}{ | ||
{ | ||
name: "non-probing plugin with probe value set", | ||
input: &mockInput{}, | ||
startupErrorBehavior: "probe", | ||
expectedError: false, | ||
}, | ||
{ | ||
name: "non-probing plugin with probe value not set", | ||
input: &mockInput{}, | ||
startupErrorBehavior: "ignore", | ||
expectedError: false, | ||
}, | ||
{ | ||
name: "probing plugin with probe value set", | ||
input: &mockProbingInput{probeErr}, | ||
startupErrorBehavior: "probe", | ||
expectedError: true, | ||
}, | ||
{ | ||
name: "probing plugin with probe value not set", | ||
input: &mockProbingInput{probeErr}, | ||
startupErrorBehavior: "ignore", | ||
expectedError: false, | ||
}, | ||
} { | ||
t.Run(tt.name, func(t *testing.T) { | ||
ri := NewRunningInput(tt.input, &InputConfig{ | ||
Name: "TestRunningInput", | ||
StartupErrorBehavior: tt.startupErrorBehavior, | ||
}) | ||
ri.log = testutil.Logger{} | ||
err := ri.Probe() | ||
if tt.expectedError { | ||
assert.Error(t, err) | ||
} else { | ||
assert.NoError(t, err) | ||
} | ||
}) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please split the test into one where the tests are expected to pass and one where the tests are expected to fail. Furthermore, you must use the require
package instead of assert
!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
plugin.go
Outdated
// ProbePlugin is an interface that all input/output plugins need to | ||
// implement in order to support the `probe` value of `startup_error_behavior`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// ProbePlugin is an interface that all input/output plugins need to | |
// implement in order to support the `probe` value of `startup_error_behavior`. | |
// ProbePlugin is an interface that all input/output plugins need to | |
// implement in order to support the `probe` value of `startup_error_behavior` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You want to delete the period? 🤷🏻 Done.
agent/agent.go
Outdated
// Probe failures are not fatal to Telegraf itself, so simply skip | ||
// adding the input. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Probe failures are not fatal to Telegraf itself, so simply skip | |
// adding the input. | |
// Probe failures are none-fatal to the agent but should only remove the plugin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Blocked on #16364. |
I'm not sure this resolves #15915 as it doesn't add a |
You're right, I changed the verbiage. |
Summary
This PR adds support in
RunningInput
and theAgent
to call an input plugin'sProbe
method if it exists and if the plugin has been configured for probing.Checklist
Related issues
related to #15915
replaces #16028
derived from #16305