Skip to content

Commit 55ec44b

Browse files
upgrade to latest dependencies (#491)
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 <[email protected]>
1 parent 2ce8783 commit 55ec44b

File tree

8 files changed

+86
-16
lines changed

8 files changed

+86
-16
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ require (
1212
k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd
1313
knative.dev/hack v0.0.0-20210622141627-e28525d8d260
1414
knative.dev/hack/schema v0.0.0-20210622141627-e28525d8d260
15-
knative.dev/pkg v0.0.0-20210722223844-842df75f5c02
15+
knative.dev/pkg v0.0.0-20210731072840-64ab22bbaab9
1616
)

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,8 +1055,8 @@ knative.dev/hack v0.0.0-20210622141627-e28525d8d260 h1:f2eMtOubAOc/Q7JlvFPDKXiPl
10551055
knative.dev/hack v0.0.0-20210622141627-e28525d8d260/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
10561056
knative.dev/hack/schema v0.0.0-20210622141627-e28525d8d260 h1:YkMkZ7qdafyRHNIuKttYzEmM1ilKTGyEtPWeVLcLcDE=
10571057
knative.dev/hack/schema v0.0.0-20210622141627-e28525d8d260/go.mod h1:ffjwmdcrH5vN3mPhO8RrF2KfNnbHeCE2C60A+2cv3U0=
1058-
knative.dev/pkg v0.0.0-20210722223844-842df75f5c02 h1:I5G5tZx44cp6jCbZr2XLbuR5yWY8xV7nTxVTRDCT+Ug=
1059-
knative.dev/pkg v0.0.0-20210722223844-842df75f5c02/go.mod h1:NYZRIPU+Pv39VfbZV1BtMIe4kCavNle1udsPrvOLm+Y=
1058+
knative.dev/pkg v0.0.0-20210731072840-64ab22bbaab9 h1:eeRutJPRJ6tR7LVkeaD7H2BaKeKwadHaR66+Z1QRVcs=
1059+
knative.dev/pkg v0.0.0-20210731072840-64ab22bbaab9/go.mod h1:NYZRIPU+Pv39VfbZV1BtMIe4kCavNle1udsPrvOLm+Y=
10601060
pgregory.net/rapid v0.3.3/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU=
10611061
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
10621062
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=

pkg/client/injection/reconciler/samples/v1alpha1/addressableservice/reconciler.go

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/client/injection/reconciler/samples/v1alpha1/simpledeployment/reconciler.go

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,14 @@ func (g *reconcilerReconcilerGenerator) GenerateType(c *generator.Context, t *ty
210210
Package: "knative.dev/pkg/reconciler",
211211
Name: "DoObserveFinalizeKind",
212212
}),
213+
"controllerIsSkipKey": c.Universe.Function(types.Name{
214+
Package: "knative.dev/pkg/controller",
215+
Name: "IsSkipKey",
216+
}),
217+
"controllerIsRequeueKey": c.Universe.Function(types.Name{
218+
Package: "knative.dev/pkg/controller",
219+
Name: "IsRequeueKey",
220+
}),
213221
}
214222

215223
sw.Do(reconcilerInterfaceFactory, m)
@@ -517,8 +525,14 @@ func (r *reconcilerImpl) Reconcile(ctx {{.contextContext|raw}}, key string) erro
517525
return nil
518526
}
519527
520-
logger.Errorw("Returned an error", zap.Error(reconcileEvent))
521-
r.Recorder.Event(resource, {{.corev1EventTypeWarning|raw}}, "InternalError", reconcileEvent.Error())
528+
if {{ .controllerIsSkipKey|raw }}(reconcileEvent) {
529+
// This is a wrapped error, don't emit an event.
530+
} else if ok, _ := {{ .controllerIsRequeueKey|raw }}(reconcileEvent); ok {
531+
// This is a wrapped error, don't emit an event.
532+
} else {
533+
logger.Errorw("Returned an error", zap.Error(reconcileEvent))
534+
r.Recorder.Event(resource, {{.corev1EventTypeWarning|raw}}, "InternalError", reconcileEvent.Error())
535+
}
522536
return reconcileEvent
523537
}
524538

vendor/knative.dev/pkg/controller/controller.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,12 @@ func (c *Impl) handleErr(err error, key types.NamespacedName, startTime time.Tim
555555
c.workQueue.Forget(key)
556556
return
557557
}
558+
if ok, delay := IsRequeueKey(err); ok {
559+
c.workQueue.AddAfter(key, delay)
560+
c.logger.Debugf("Requeuing key %s (by request) after %v (depth: %d)", safeKey(key), delay, c.workQueue.Len())
561+
return
562+
}
563+
558564
c.logger.Errorw("Reconcile error", zap.Duration("duration", time.Since(startTime)), zap.Error(err))
559565

560566
// Re-queue the key if it's a transient error.
@@ -666,6 +672,49 @@ func (err permanentError) Unwrap() error {
666672
return err.e
667673
}
668674

675+
// NewRequeueImmediately returns a new instance of requeueKeyError.
676+
// Users can return this type of error to immediately requeue a key.
677+
func NewRequeueImmediately() error {
678+
return requeueKeyError{}
679+
}
680+
681+
// NewRequeueAfter returns a new instance of requeueKeyError.
682+
// Users can return this type of error to requeue a key after a delay.
683+
func NewRequeueAfter(dur time.Duration) error {
684+
return requeueKeyError{duration: dur}
685+
}
686+
687+
// requeueKeyError is an error that indicates the reconciler wants to reprocess
688+
// the key after a particular duration (possibly zero).
689+
// We should re-queue keys with the desired duration when this is returned by Reconcile.
690+
type requeueKeyError struct {
691+
duration time.Duration
692+
}
693+
694+
var _ error = requeueKeyError{}
695+
696+
// Error implements the Error() interface of error.
697+
func (err requeueKeyError) Error() string {
698+
return fmt.Sprintf("requeue after: %s", err.duration)
699+
}
700+
701+
// IsRequeueKey returns true if the given error is a requeueKeyError.
702+
func IsRequeueKey(err error) (bool, time.Duration) {
703+
rqe := requeueKeyError{}
704+
if errors.As(err, &rqe) {
705+
return true, rqe.duration
706+
}
707+
return false, 0
708+
}
709+
710+
// Is implements the Is() interface of error. It returns whether the target
711+
// error can be treated as equivalent to a requeueKeyError.
712+
func (requeueKeyError) Is(target error) bool {
713+
//nolint: errorlint // This check is actually fine.
714+
_, ok := target.(requeueKeyError)
715+
return ok
716+
}
717+
669718
// Informer is the group of methods that a type must implement to be passed to
670719
// StartInformers.
671720
type Informer interface {

vendor/knative.dev/pkg/webhook/webhook.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,13 @@ import (
2626
"time"
2727

2828
// Injection stuff
29-
kubeclient "knative.dev/pkg/client/injection/kube/client"
29+
3030
kubeinformerfactory "knative.dev/pkg/injection/clients/namespacedkube/informers/factory"
3131
"knative.dev/pkg/network/handlers"
3232

3333
"go.uber.org/zap"
3434
"golang.org/x/sync/errgroup"
3535
admissionv1 "k8s.io/api/admission/v1"
36-
"k8s.io/client-go/kubernetes"
3736
corelisters "k8s.io/client-go/listers/core/v1"
3837
"knative.dev/pkg/logging"
3938
"knative.dev/pkg/network"
@@ -78,7 +77,6 @@ const (
7877
// Webhook implements the external webhook for validation of
7978
// resources and configuration.
8079
type Webhook struct {
81-
Client kubernetes.Interface
8280
Options Options
8381
Logger *zap.SugaredLogger
8482

@@ -106,8 +104,6 @@ func New(
106104
}
107105
}()
108106

109-
client := kubeclient.Get(ctx)
110-
111107
// Injection is too aggressive for this case because by simply linking this
112108
// library we force consumers to have secret access. If we require that one
113109
// of the admission controllers' informers *also* require the secret
@@ -132,7 +128,6 @@ func New(
132128
syncCtx, cancel := context.WithCancel(context.Background())
133129

134130
webhook = &Webhook{
135-
Client: client,
136131
Options: *opts,
137132
secretlister: secretInformer.Lister(),
138133
Logger: logger,

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ knative.dev/hack/schema/commands
671671
knative.dev/hack/schema/docs
672672
knative.dev/hack/schema/registry
673673
knative.dev/hack/schema/schema
674-
# knative.dev/pkg v0.0.0-20210722223844-842df75f5c02
674+
# knative.dev/pkg v0.0.0-20210731072840-64ab22bbaab9
675675
## explicit
676676
knative.dev/pkg/apis
677677
knative.dev/pkg/apis/duck

0 commit comments

Comments
 (0)