mirror of https://github.com/knative/caching.git
upgrade to latest dependencies (#505)
bumping knative.dev/pkg 842df75...64ab22b: > 64ab22b k8s-service-trailing-slash-fix (# 2178) > c367a9d Drop Client as it is only used in tests (# 2203) > bb4aaf0 Ignore special errors in codegen for events (# 2202) > 3826bb2 Add a new mechanism for requeuing a key. (# 2201) > 889b567 Update community files (# 2199) Signed-off-by: Knative Automation <automation@knative.team>
This commit is contained in:
parent
6796375191
commit
6947bb32bc
2
go.mod
2
go.mod
|
@ -19,5 +19,5 @@ require (
|
|||
k8s.io/code-generator v0.20.7
|
||||
k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd
|
||||
knative.dev/hack v0.0.0-20210622141627-e28525d8d260
|
||||
knative.dev/pkg v0.0.0-20210722223844-842df75f5c02
|
||||
knative.dev/pkg v0.0.0-20210731072840-64ab22bbaab9
|
||||
)
|
||||
|
|
4
go.sum
4
go.sum
|
@ -1057,8 +1057,8 @@ k8s.io/utils v0.0.0-20201110183641-67b214c5f920 h1:CbnUZsM497iRC5QMVkHwyl8s2tB3g
|
|||
k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
knative.dev/hack v0.0.0-20210622141627-e28525d8d260 h1:f2eMtOubAOc/Q7JlvFPDKXiPlJVK+VpX2Cot8hRzCgQ=
|
||||
knative.dev/hack v0.0.0-20210622141627-e28525d8d260/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
|
||||
knative.dev/pkg v0.0.0-20210722223844-842df75f5c02 h1:I5G5tZx44cp6jCbZr2XLbuR5yWY8xV7nTxVTRDCT+Ug=
|
||||
knative.dev/pkg v0.0.0-20210722223844-842df75f5c02/go.mod h1:NYZRIPU+Pv39VfbZV1BtMIe4kCavNle1udsPrvOLm+Y=
|
||||
knative.dev/pkg v0.0.0-20210731072840-64ab22bbaab9 h1:eeRutJPRJ6tR7LVkeaD7H2BaKeKwadHaR66+Z1QRVcs=
|
||||
knative.dev/pkg v0.0.0-20210731072840-64ab22bbaab9/go.mod h1:NYZRIPU+Pv39VfbZV1BtMIe4kCavNle1udsPrvOLm+Y=
|
||||
pgregory.net/rapid v0.3.3/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU=
|
||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
||||
|
|
|
@ -305,8 +305,14 @@ func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
logger.Errorw("Returned an error", zap.Error(reconcileEvent))
|
||||
r.Recorder.Event(resource, v1.EventTypeWarning, "InternalError", reconcileEvent.Error())
|
||||
if controller.IsSkipKey(reconcileEvent) {
|
||||
// This is a wrapped error, don't emit an event.
|
||||
} else if ok, _ := controller.IsRequeueKey(reconcileEvent); ok {
|
||||
// This is a wrapped error, don't emit an event.
|
||||
} else {
|
||||
logger.Errorw("Returned an error", zap.Error(reconcileEvent))
|
||||
r.Recorder.Event(resource, v1.EventTypeWarning, "InternalError", reconcileEvent.Error())
|
||||
}
|
||||
return reconcileEvent
|
||||
}
|
||||
|
||||
|
|
|
@ -210,6 +210,14 @@ func (g *reconcilerReconcilerGenerator) GenerateType(c *generator.Context, t *ty
|
|||
Package: "knative.dev/pkg/reconciler",
|
||||
Name: "DoObserveFinalizeKind",
|
||||
}),
|
||||
"controllerIsSkipKey": c.Universe.Function(types.Name{
|
||||
Package: "knative.dev/pkg/controller",
|
||||
Name: "IsSkipKey",
|
||||
}),
|
||||
"controllerIsRequeueKey": c.Universe.Function(types.Name{
|
||||
Package: "knative.dev/pkg/controller",
|
||||
Name: "IsRequeueKey",
|
||||
}),
|
||||
}
|
||||
|
||||
sw.Do(reconcilerInterfaceFactory, m)
|
||||
|
@ -517,8 +525,14 @@ func (r *reconcilerImpl) Reconcile(ctx {{.contextContext|raw}}, key string) erro
|
|||
return nil
|
||||
}
|
||||
|
||||
logger.Errorw("Returned an error", zap.Error(reconcileEvent))
|
||||
r.Recorder.Event(resource, {{.corev1EventTypeWarning|raw}}, "InternalError", reconcileEvent.Error())
|
||||
if {{ .controllerIsSkipKey|raw }}(reconcileEvent) {
|
||||
// This is a wrapped error, don't emit an event.
|
||||
} else if ok, _ := {{ .controllerIsRequeueKey|raw }}(reconcileEvent); ok {
|
||||
// This is a wrapped error, don't emit an event.
|
||||
} else {
|
||||
logger.Errorw("Returned an error", zap.Error(reconcileEvent))
|
||||
r.Recorder.Event(resource, {{.corev1EventTypeWarning|raw}}, "InternalError", reconcileEvent.Error())
|
||||
}
|
||||
return reconcileEvent
|
||||
}
|
||||
|
||||
|
|
|
@ -555,6 +555,12 @@ func (c *Impl) handleErr(err error, key types.NamespacedName, startTime time.Tim
|
|||
c.workQueue.Forget(key)
|
||||
return
|
||||
}
|
||||
if ok, delay := IsRequeueKey(err); ok {
|
||||
c.workQueue.AddAfter(key, delay)
|
||||
c.logger.Debugf("Requeuing key %s (by request) after %v (depth: %d)", safeKey(key), delay, c.workQueue.Len())
|
||||
return
|
||||
}
|
||||
|
||||
c.logger.Errorw("Reconcile error", zap.Duration("duration", time.Since(startTime)), zap.Error(err))
|
||||
|
||||
// Re-queue the key if it's a transient error.
|
||||
|
@ -666,6 +672,49 @@ func (err permanentError) Unwrap() error {
|
|||
return err.e
|
||||
}
|
||||
|
||||
// NewRequeueImmediately returns a new instance of requeueKeyError.
|
||||
// Users can return this type of error to immediately requeue a key.
|
||||
func NewRequeueImmediately() error {
|
||||
return requeueKeyError{}
|
||||
}
|
||||
|
||||
// NewRequeueAfter returns a new instance of requeueKeyError.
|
||||
// Users can return this type of error to requeue a key after a delay.
|
||||
func NewRequeueAfter(dur time.Duration) error {
|
||||
return requeueKeyError{duration: dur}
|
||||
}
|
||||
|
||||
// requeueKeyError is an error that indicates the reconciler wants to reprocess
|
||||
// the key after a particular duration (possibly zero).
|
||||
// We should re-queue keys with the desired duration when this is returned by Reconcile.
|
||||
type requeueKeyError struct {
|
||||
duration time.Duration
|
||||
}
|
||||
|
||||
var _ error = requeueKeyError{}
|
||||
|
||||
// Error implements the Error() interface of error.
|
||||
func (err requeueKeyError) Error() string {
|
||||
return fmt.Sprintf("requeue after: %s", err.duration)
|
||||
}
|
||||
|
||||
// IsRequeueKey returns true if the given error is a requeueKeyError.
|
||||
func IsRequeueKey(err error) (bool, time.Duration) {
|
||||
rqe := requeueKeyError{}
|
||||
if errors.As(err, &rqe) {
|
||||
return true, rqe.duration
|
||||
}
|
||||
return false, 0
|
||||
}
|
||||
|
||||
// Is implements the Is() interface of error. It returns whether the target
|
||||
// error can be treated as equivalent to a requeueKeyError.
|
||||
func (requeueKeyError) Is(target error) bool {
|
||||
//nolint: errorlint // This check is actually fine.
|
||||
_, ok := target.(requeueKeyError)
|
||||
return ok
|
||||
}
|
||||
|
||||
// Informer is the group of methods that a type must implement to be passed to
|
||||
// StartInformers.
|
||||
type Informer interface {
|
||||
|
|
|
@ -578,7 +578,7 @@ k8s.io/utils/trace
|
|||
# knative.dev/hack v0.0.0-20210622141627-e28525d8d260
|
||||
## explicit
|
||||
knative.dev/hack
|
||||
# knative.dev/pkg v0.0.0-20210722223844-842df75f5c02
|
||||
# knative.dev/pkg v0.0.0-20210731072840-64ab22bbaab9
|
||||
## explicit
|
||||
knative.dev/pkg/apis
|
||||
knative.dev/pkg/apis/duck
|
||||
|
|
Loading…
Reference in New Issue