summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Hawkins <[email protected]>2023-07-14 11:01:32 -0400
committerWill Hawkins <[email protected]>2023-07-14 11:05:44 -0400
commit0a4cc0474df9854851a95e1b283468d6d62344b8 (patch)
tree362af09620017f5f4700359847eabf008aa83451
parentf2b7e719543408650fef7e3290f77962654453a9 (diff)
Suppress non-error of cancelled context causing probe send to fail
It is not an error (per se) for a probe not to be able to be sent when the context of its execution is cancelled. Log the error when debugging only. Signed-off-by: Will Hawkins <[email protected]>
-rw-r--r--probe/probe.go18
-rw-r--r--rpm/rpm.go15
2 files changed, 32 insertions, 1 deletions
diff --git a/probe/probe.go b/probe/probe.go
index fa19411..3939076 100644
--- a/probe/probe.go
+++ b/probe/probe.go
@@ -108,6 +108,15 @@ func Probe(
probe_resp, err := client.Do(probe_req)
if err != nil {
+ if debug.IsDebug(debugging.Level) {
+ fmt.Printf(
+ "(%s) (%s Probe %v) An error occurred during http.Do: %v\n",
+ debugging.Prefix,
+ probeType.Value(),
+ probeId,
+ err,
+ )
+ }
return nil, err
}
@@ -119,6 +128,15 @@ func Probe(
// TODO: Make this interruptable somehow by using _ctx_.
_, err = io.ReadAll(probe_resp.Body)
if err != nil {
+ if debug.IsDebug(debugging.Level) {
+ fmt.Printf(
+ "(%s) (%s Probe %v) An error occurred during io.ReadAll: %v\n",
+ debugging.Prefix,
+ probeType.Value(),
+ probeId,
+ err,
+ )
+ }
return nil, err
}
time_after_probe := time.Now()
diff --git a/rpm/rpm.go b/rpm/rpm.go
index 0f51461..ff483ff 100644
--- a/rpm/rpm.go
+++ b/rpm/rpm.go
@@ -249,13 +249,26 @@ func ResponsivenessProber[BucketType utilities.Number](
(*selfProbeConnection).Client(),
selfProbeConfiguration.URL,
selfProbeConfiguration.Host,
- probeDirection,
utilities.Conditional(probeDirection == lgc.LGC_DOWN, probe.SelfDown, probe.SelfUp),
probeCount,
captureExtendedStats,
debugging,
)
if err != nil {
+ // We may see an error here because the prober context was cancelled
+ // and requests were attempting to be sent. This situation is not an
+ // error (per se) so we will not log it as such.
+
+ if proberCtx.Err() != nil {
+ if debug.IsDebug(debugging.Level) {
+ fmt.Printf(
+ "(%s) Failed to send a probe (id: %v) because the prober context was cancelled.\n",
+ debugging.Prefix,
+ probeCount,
+ )
+ }
+ return
+ }
fmt.Printf(
"(%s) There was an error sending a self probe with Id %d: %v\n",
debugging.Prefix,