From c21d8f7b7125e0fd4faab6894b22fdeeb0ecd5e0 Mon Sep 17 00:00:00 2001 From: Yongxuan Zhang Date: Thu, 23 Feb 2023 22:25:31 +0000 Subject: [PATCH] [release-0.44.x] picking up latest changes in knative 1.8 knative.dev/pkg was recently updated to include a performance fix which helped reduced the CPU usage by 61% and memory usage by 44% for huge pipelines. This PR is updating the tekton controllers to include that fix such that Pipelines 0.44.x can take advantage of this performance improvement. The same fix was cherry picked in knative.dev/pkg 1.9. Tekton pipeline was updated to use knative 1.9 post 0.45 in PR tektoncd#6062. We have another PR tektoncd#6194 open to update pipeline controllers in the main branch. Signed-off-by: Yongxuan Zhang yongxuanzhang@google.com --- go.mod | 2 +- go.sum | 4 ++-- pkg/client/clientset/versioned/fake/register.go | 14 +++++++------- pkg/client/clientset/versioned/scheme/register.go | 14 +++++++------- .../clientset/versioned/fake/register.go | 14 +++++++------- .../clientset/versioned/scheme/register.go | 14 +++++++------- .../resource/clientset/versioned/fake/register.go | 14 +++++++------- .../clientset/versioned/scheme/register.go | 14 +++++++------- .../generators/reconciler_reconciler.go | 14 ++++++++++---- vendor/modules.txt | 2 +- 10 files changed, 56 insertions(+), 50 deletions(-) diff --git a/go.mod b/go.mod index 4e9cda0f20d..75a12df9ea4 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,7 @@ require ( k8s.io/code-generator v0.25.4 k8s.io/klog v1.0.0 k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 - knative.dev/pkg v0.0.0-20221123011842-b78020c16606 + knative.dev/pkg v0.0.0-20230221152827-2d84369c105d sigs.k8s.io/yaml v1.3.0 ) diff --git a/go.sum b/go.sum index d2472e9b126..4c21cb80ee8 100644 --- a/go.sum +++ b/go.sum @@ -1792,8 +1792,8 @@ k8s.io/kubernetes v1.13.0/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk= k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20221012122500-cfd413dd9e85 h1:cTdVh7LYu82xeClmfzGtgyspNh6UxpwLWGi8R4sspNo= k8s.io/utils v0.0.0-20221012122500-cfd413dd9e85/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -knative.dev/pkg v0.0.0-20221123011842-b78020c16606 h1:bHozIhJtQE9/SVQkVX2vqnoJGJt6zo7J0jnkLFX3Crw= -knative.dev/pkg v0.0.0-20221123011842-b78020c16606/go.mod h1:DMTRDJ5WRxf/DrlOPzohzfhSuJggscLZ8EavOq9O/x8= +knative.dev/pkg v0.0.0-20230221152827-2d84369c105d h1:3j5XVeK6B8w7HGAauirrSRwy9dA6HYUstjr6EyOI4bw= +knative.dev/pkg v0.0.0-20230221152827-2d84369c105d/go.mod h1:DMTRDJ5WRxf/DrlOPzohzfhSuJggscLZ8EavOq9O/x8= 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= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index 951cec59e8f..27907d4e65f 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -41,14 +41,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index 21c3e532dfd..ffc8f29c1f7 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -41,14 +41,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/pkg/client/resolution/clientset/versioned/fake/register.go b/pkg/client/resolution/clientset/versioned/fake/register.go index 70d792b35d6..8469024ac97 100644 --- a/pkg/client/resolution/clientset/versioned/fake/register.go +++ b/pkg/client/resolution/clientset/versioned/fake/register.go @@ -39,14 +39,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/pkg/client/resolution/clientset/versioned/scheme/register.go b/pkg/client/resolution/clientset/versioned/scheme/register.go index 9fe0d86a62e..19e5de5b4c6 100644 --- a/pkg/client/resolution/clientset/versioned/scheme/register.go +++ b/pkg/client/resolution/clientset/versioned/scheme/register.go @@ -39,14 +39,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/pkg/client/resource/clientset/versioned/fake/register.go b/pkg/client/resource/clientset/versioned/fake/register.go index 78bbf3de2ae..e33dea7aa03 100644 --- a/pkg/client/resource/clientset/versioned/fake/register.go +++ b/pkg/client/resource/clientset/versioned/fake/register.go @@ -37,14 +37,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/pkg/client/resource/clientset/versioned/scheme/register.go b/pkg/client/resource/clientset/versioned/scheme/register.go index 2eb6b537e5a..972999462fa 100644 --- a/pkg/client/resource/clientset/versioned/scheme/register.go +++ b/pkg/client/resource/clientset/versioned/scheme/register.go @@ -37,14 +37,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go index 28bc3185cb0..f27c1563391 100644 --- a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go +++ b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go @@ -150,6 +150,10 @@ func (g *reconcilerReconcilerGenerator) GenerateType(c *generator.Context, t *ty Package: "go.uber.org/zap", Name: "SugaredLogger", }), + "zapDebugLevel": c.Universe.Type(types.Name{ + Package: "go.uber.org/zapcore", + Name: "DebugLevel", + }), "setsNewString": c.Universe.Function(types.Name{ Package: "k8s.io/apimachinery/pkg/util/sets", Name: "NewString", @@ -520,7 +524,7 @@ func (r *reconcilerImpl) Reconcile(ctx {{.contextContext|raw}}, key string) erro // the elected leader is expected to write modifications. logger.Warn("Saw status changes when we aren't the leader!") default: - if err = r.updateStatus(ctx, original, resource); err != nil { + if err = r.updateStatus(ctx, logger, original, resource); err != nil { logger.Warnw("Failed to update resource status", zap.Error(err)) r.Recorder.Eventf(resource, {{.corev1EventTypeWarning|raw}}, "UpdateFailed", "Failed to update status for %q: %v", resource.Name, err) @@ -559,7 +563,7 @@ func (r *reconcilerImpl) Reconcile(ctx {{.contextContext|raw}}, key string) erro ` var reconcilerStatusFactory = ` -func (r *reconcilerImpl) updateStatus(ctx {{.contextContext|raw}}, existing *{{.type|raw}}, desired *{{.type|raw}}) error { +func (r *reconcilerImpl) updateStatus(ctx {{.contextContext|raw}}, logger *{{.zapSugaredLogger|raw}}, existing *{{.type|raw}}, desired *{{.type|raw}}) error { existing = existing.DeepCopy() return {{.reconcilerRetryUpdateConflicts|raw}}(func(attempts int) (err error) { // The first iteration tries to use the injectionInformer's state, subsequent attempts fetch the latest state via API. @@ -580,8 +584,10 @@ func (r *reconcilerImpl) updateStatus(ctx {{.contextContext|raw}}, existing *{{. return nil } - if diff, err := {{.kmpSafeDiff|raw}}(existing.Status, desired.Status); err == nil && diff != "" { - {{.loggingFromContext|raw}}(ctx).Debug("Updating status with: ", diff) + if logger.Desugar().Core().Enabled(zapcore.DebugLevel) { + if diff, err := {{.kmpSafeDiff|raw}}(existing.Status, desired.Status); err == nil && diff != "" { + logger.Debug("Updating status with: ", diff) + } } existing.Status = desired.Status diff --git a/vendor/modules.txt b/vendor/modules.txt index c7c71bf22ae..5e266d5ef29 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1651,7 +1651,7 @@ k8s.io/utils/net k8s.io/utils/pointer k8s.io/utils/strings/slices k8s.io/utils/trace -# knative.dev/pkg v0.0.0-20221123011842-b78020c16606 +# knative.dev/pkg v0.0.0-20230221152827-2d84369c105d ## explicit; go 1.18 knative.dev/pkg/apis knative.dev/pkg/apis/duck