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

Pinger timeout should return an error #70

Open
wbollock opened this issue Oct 12, 2023 · 4 comments
Open

Pinger timeout should return an error #70

wbollock opened this issue Oct 12, 2023 · 4 comments

Comments

@wbollock
Copy link

If the pinger reaches timeout, no error is returned from OnFinish() and it makes it seem like the probe finished successfully, even if nothing was returned from the ping job.

pro-bing/ping.go

Lines 538 to 539 in 0999adf

case <-timeout.C:
return nil

I believe this should return an error indicating the timeout was reached before the ping job finished fully. Happy to make the PR if this sounds good

wbollock added a commit to linode-obs/ping_exporter that referenced this issue Oct 12, 2023
OnFinish will return without error even if the prober timed out before
returning all requested pings. If we instead ensure we sent as many
pings as requested during OnFinish, that'll help cover this edge case.

Issue raised upstream: prometheus-community/pro-bing#70
@lllama
Copy link

lllama commented Jan 25, 2024

Adding a +1 for this. Given that an unreachable host will block on .Run() without a timeout, it would be great to have some way to determine whether the pinger timed out.

@fkr
Copy link

fkr commented Jan 25, 2024

indeed. Especially since one specifically has to set the timeout (which I initially did not do and wondered why my pinger go routine sometimes would not properly return).
Does it make sense to also set a timeout by default when the pinger is initialized?

@fuomag9
Copy link

fuomag9 commented Mar 3, 2024

indeed. Especially since one specifically has to set the timeout (which I initially did not do and wondered why my pinger go routine sometimes would not properly return). Does it make sense to also set a timeout by default when the pinger is initialized?

I tried running with pinger.Timeout = 1000 but the result is that it exits and returns like it responded to the ping (which is not true)

@jmkng
Copy link

jmkng commented Aug 23, 2024

I may not understand, but a RunWithContext function exists, I'm using that to check for a timeout.

ctx, _ := context.WithTimeout(context.Background(), deadline)
err = client.RunWithContext(ctx)
	if err != nil {
		if errors.Is(err, context.DeadlineExceeded) {
			// Timeout
		}
		...
	}

Does this not work for your situation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants