-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
common.go
29 lines (24 loc) · 941 Bytes
/
common.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.
//nolint:revive // TODO(APL) Fix revive linter
package common
import (
"os/exec"
"time"
"github.com/DataDog/datadog-agent/pkg/collector/check"
)
const DefaultRetryDuration = 5 * time.Second
const DefaultRetries = 3
// common.retryExitError converts `exec.ExitError`s to `check.RetryableError`s, so that checks using this
// are retried.
// embed checks must use this from their `Run` method when exit errors need to be retried.
func RetryExitError(err error) error { //nolint Used only on some architectures
switch err.(type) {
case *exec.ExitError: // error type returned when the process exits with non-zero status
return check.RetryableError{Err: err}
default:
return err
}
}