forked from kubernetes-sigs/aws-load-balancer-controller
/
errors.go
63 lines (51 loc) · 1.88 KB
/
errors.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package runtime
import (
"fmt"
"time"
)
// NewRequeueNeeded constructs new RequeueError to
// instruct controller-runtime to requeue the processing item without been logged as error.
func NewRequeueNeeded(reason string) *RequeueNeeded {
return &RequeueNeeded{
reason: reason,
}
}
// NewRequeueNeededAfter constructs new RequeueNeededAfter to
// instruct controller-runtime to requeue the processing item after specified duration without been logged as error.
func NewRequeueNeededAfter(reason string, duration time.Duration) *RequeueNeededAfter {
return &RequeueNeededAfter{
reason: reason,
duration: duration,
}
}
var _ error = &RequeueNeeded{}
// An error to instruct controller-runtime to requeue the processing item without been logged as error.
// This should be used when a "error condition" occurrence is sort of expected and can be resolved by retry.
// e.g. a dependency haven't been fulfilled yet.
type RequeueNeeded struct {
reason string
}
func (e *RequeueNeeded) Reason() string {
return e.reason
}
func (e *RequeueNeeded) Error() string {
return fmt.Sprintf("requeue needed: %v", e.reason)
}
var _ error = &RequeueNeededAfter{}
// An error to instruct controller-runtime to requeue the processing item after specified duration without been logged as error.
// This should be used when a "error condition" occurrence is sort of expected and can be resolved by retry.
// e.g. a dependency haven't been fulfilled yet, and expected it to be fulfilled after duration.
// Note: use this with care,a simple wait might suits your use case better.
type RequeueNeededAfter struct {
reason string
duration time.Duration
}
func (e *RequeueNeededAfter) Reason() string {
return e.reason
}
func (e *RequeueNeededAfter) Duration() time.Duration {
return e.duration
}
func (e *RequeueNeededAfter) Error() string {
return fmt.Sprintf("requeue needed after %v: %v", e.duration, e.reason)
}