Skip to content

Commit 59c3292

Browse files
knative-prow-robotnader-ziadadprotaso
authored
[release-1.18] Fix: PodAutoscaler not reconciled due to missing class annotation (#16190)
* Fix: PodAutoscaler not reconciled due to missing class annotation race condition setting the annotation before creating the PA eliminating the race condition * use constant for autoscaling.knative.dev/class * bump knative.dev/hack to latest patch * use latest release branch patch images --------- Co-authored-by: Nader Ziada <[email protected]> Co-authored-by: Dave Protasowski <[email protected]>
1 parent 9abfc28 commit 59c3292

File tree

10 files changed

+31
-13
lines changed

10 files changed

+31
-13
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ require (
3434
k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7
3535
k8s.io/utils v0.0.0-20241210054802-24370beab758
3636
knative.dev/caching v0.0.0-20250415164313-8f20a1163dbf
37-
knative.dev/hack v0.0.0-20250331013814-c577ed9f7775
37+
knative.dev/hack v0.0.0-20251022160648-4a7a07f9b7b4
3838
knative.dev/networking v0.0.0-20250415164913-6268d931d247
3939
knative.dev/pkg v0.0.0-20250415155312-ed3e2158b883
4040
sigs.k8s.io/yaml v1.4.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -958,8 +958,8 @@ k8s.io/utils v0.0.0-20241210054802-24370beab758 h1:sdbE21q2nlQtFh65saZY+rRM6x6aJ
958958
k8s.io/utils v0.0.0-20241210054802-24370beab758/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
959959
knative.dev/caching v0.0.0-20250415164313-8f20a1163dbf h1:qQnKB6mx+beHzsoKU8aKrRU0oWAfgzKG2JgWMzr8CrM=
960960
knative.dev/caching v0.0.0-20250415164313-8f20a1163dbf/go.mod h1:q8ma7YxJ8Dofr+5kf3qR72A/7Zxl9uqQlOdMwNgCXY4=
961-
knative.dev/hack v0.0.0-20250331013814-c577ed9f7775 h1:UstB8/aowofYFHjLyZdPh1K7qB9BCx+lP1WuiCspYRE=
962-
knative.dev/hack v0.0.0-20250331013814-c577ed9f7775/go.mod h1:R0ritgYtjLDO9527h5vb5X6gfvt5LCrJ55BNbVDsWiY=
961+
knative.dev/hack v0.0.0-20251022160648-4a7a07f9b7b4 h1:CLFOOEXo5A278ScEdqOf4UnekCtYJ9l1PCsAi4eQp+E=
962+
knative.dev/hack v0.0.0-20251022160648-4a7a07f9b7b4/go.mod h1:R0ritgYtjLDO9527h5vb5X6gfvt5LCrJ55BNbVDsWiY=
963963
knative.dev/networking v0.0.0-20250415164913-6268d931d247 h1:BQcW8ur+WAmj6GCpYHyUyWoaJWVTs/75W1EObUV/bdA=
964964
knative.dev/networking v0.0.0-20250415164913-6268d931d247/go.mod h1:Y6OMRz/12RC8fzVa3gAB6K8BR415xbF4z35IAbdMHFc=
965965
knative.dev/pkg v0.0.0-20250415155312-ed3e2158b883 h1:UeOY7009M0EHwdyW3P35Fc1U6FJHzBrj6Gf370do8zY=

pkg/reconciler/revision/cruds.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"knative.dev/pkg/logging"
3131
autoscalingv1alpha1 "knative.dev/serving/pkg/apis/autoscaling/v1alpha1"
3232
v1 "knative.dev/serving/pkg/apis/serving/v1"
33+
"knative.dev/serving/pkg/client/injection/reconciler/autoscaling/v1alpha1/podautoscaler"
3334
"knative.dev/serving/pkg/reconciler/revision/config"
3435
"knative.dev/serving/pkg/reconciler/revision/resources"
3536
)
@@ -104,5 +105,17 @@ func (c *Reconciler) createPA(
104105
deployment *appsv1.Deployment,
105106
) (*autoscalingv1alpha1.PodAutoscaler, error) {
106107
pa := resources.MakePA(rev, deployment)
108+
109+
// Ensure autoscaling annotations are set before creating PA.
110+
// This avoids a race condition where the informer cache sees the PA
111+
// before the webhook defaulting completes.
112+
cfg := config.FromContext(ctx)
113+
if pa.Annotations == nil {
114+
pa.Annotations = make(map[string]string)
115+
}
116+
if _, ok := pa.Annotations[podautoscaler.ClassAnnotationKey]; !ok && cfg.Autoscaler.PodAutoscalerClass != "" {
117+
pa.Annotations[podautoscaler.ClassAnnotationKey] = cfg.Autoscaler.PodAutoscalerClass
118+
}
119+
107120
return c.client.AutoscalingV1alpha1().PodAutoscalers(pa.Namespace).Create(ctx, pa, metav1.CreateOptions{})
108121
}

third_party/contour-latest/net-contour.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ spec:
130130
- name: controller
131131
# This is the Go import path for the binary that is containerized
132132
# and substituted here.
133-
image: gcr.io/knative-nightly/knative.dev/net-contour/cmd/controller@sha256:dd8ca727b4aaf354ab17273617abcefc7b6e56ea5f5d5ff1f7840b6168b41d20
133+
image: gcr.io/knative-releases/knative.dev/net-contour/cmd/controller@sha256:dd8ca727b4aaf354ab17273617abcefc7b6e56ea5f5d5ff1f7840b6168b41d20
134134
resources:
135135
requests:
136136
cpu: 40m

third_party/gateway-api-latest/net-gateway-api.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ spec:
9595
- name: controller
9696
# This is the Go import path for the binary that is containerized
9797
# and substituted here.
98-
image: gcr.io/knative-nightly/knative.dev/net-gateway-api/cmd/controller@sha256:e8aede7a9af7bd31a2c6d11216e3a81d09d83b7a5bccc6939a6ab29f80139ac1
98+
image: gcr.io/knative-releases/knative.dev/net-gateway-api/cmd/controller@sha256:cf6eb5b8d4364976c449d489363e69453d003508bd27cf1548bf1fec78c876c7
9999
resources:
100100
requests:
101101
cpu: 100m
@@ -173,7 +173,7 @@ spec:
173173
- name: webhook
174174
# This is the Go import path for the binary that is containerized
175175
# and substituted here.
176-
image: gcr.io/knative-nightly/knative.dev/net-gateway-api/cmd/webhook@sha256:5685197c06ce287e4fdb331733aa3fe686dd27b5e784677234b56c13ef6e0021
176+
image: gcr.io/knative-releases/knative.dev/net-gateway-api/cmd/webhook@sha256:fa238aa79849f272a763a0871472236fb3246bcc5ec6c91692074967e36c50ec
177177
resources:
178178
requests:
179179
cpu: 20m

third_party/istio-latest/net-istio.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ spec:
336336
- name: controller
337337
# This is the Go import path for the binary that is containerized
338338
# and substituted here.
339-
image: gcr.io/knative-nightly/knative.dev/net-istio/cmd/controller@sha256:18376be76f77cd195e2bb4993eebf86c6b8c34222247f2f8e4a265c5c4e9b9a8
339+
image: gcr.io/knative-releases/knative.dev/net-istio/cmd/controller@sha256:0d5f740b4224ceae5a2e96325868d492ebf9433c3efc4b834e74e6408a76f9c5
340340
resources:
341341
requests:
342342
cpu: 30m
@@ -436,7 +436,7 @@ spec:
436436
- name: webhook
437437
# This is the Go import path for the binary that is containerized
438438
# and substituted here.
439-
image: gcr.io/knative-nightly/knative.dev/net-istio/cmd/webhook@sha256:dcc32d23e1565c26620c3735c28ea294215e8b01dd9a30b58e19152879b89422
439+
image: gcr.io/knative-releases/knative.dev/net-istio/cmd/webhook@sha256:697668be78934fa964730c745acb7bd951ed1160cd449f56ffc351d025e5261a
440440
resources:
441441
requests:
442442
cpu: 20m

third_party/kourier-latest/kourier.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ spec:
356356
app: net-kourier-controller
357357
spec:
358358
containers:
359-
- image: gcr.io/knative-nightly/knative.dev/net-kourier/cmd/kourier@sha256:6b86707a3042217d18a57911748e99033850af2703645747feb58bb6dd0ff400
359+
- image: gcr.io/knative-releases/knative.dev/net-kourier/cmd/kourier@sha256:15a601147ef4574386e296c4b2456bb1e230d2dc110254295dddb56e5118b5a8
360360
name: controller
361361
env:
362362
- name: CERTS_SECRET_NAMESPACE

vendor/knative.dev/hack/library.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ function report_go_test() {
588588
logfile="${logfile/.xml/.jsonl}"
589589
echo "Running go test with args: ${go_test_args[*]}"
590590
local gotest_retcode=0
591-
go_run gotest.tools/gotestsum@v1.11.0 \
591+
go_run gotest.tools/gotestsum@v1.13.0 \
592592
--format "${GO_TEST_VERBOSITY:-testname}" \
593593
--junitfile "${xml}" \
594594
--junitfile-testsuite-name relative \
@@ -681,7 +681,7 @@ function start_knative_eventing_extension() {
681681
# Parameters: $1 - tool package for go run.
682682
# $2..$n - parameters passed to the tool.
683683
function go_run() {
684-
local package
684+
local package gotoolchain
685685
package="$1"
686686
if [[ "$package" != *@* ]]; then
687687
abort 'Package for "go_run" needs to have @version'
@@ -696,6 +696,11 @@ function go_run() {
696696
GORUN_PATH="$(mktemp -t -d -u gopath.XXXXXXXX)"
697697
fi
698698
export GORUN_PATH
699+
gotoolchain="$(go env GOTOOLCHAIN)"
700+
if [[ "$package" == knative.dev/toolbox/* ]]; then
701+
gotoolchain=auto
702+
fi
703+
GOTOOLCHAIN="${gotoolchain}" \
699704
GOPATH="${GORUN_PATH}" \
700705
GOFLAGS='' \
701706
go run "$package" "$@"

vendor/knative.dev/hack/presubmit-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ function __build_test_runner_for_module() {
141141
# Don't merge these two lines, or return code will always be 0.
142142
# Get all build tags in go code (ignore /vendor, /hack and /third_party)
143143
local tags
144-
tags="$(go run knative.dev/toolbox/go-ls-tags@latest --joiner=,)"
144+
tags="$(go_run knative.dev/toolbox/go-ls-tags@latest --joiner=,)"
145145
local go_pkg_dirs
146146
go_pkg_dirs="$(go list -tags "${tags}" ./...)" || return $?
147147
if [[ -z "${go_pkg_dirs}" ]]; then

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1420,7 +1420,7 @@ knative.dev/caching/pkg/client/injection/informers/caching/v1alpha1/image/fake
14201420
knative.dev/caching/pkg/client/injection/informers/factory
14211421
knative.dev/caching/pkg/client/injection/informers/factory/fake
14221422
knative.dev/caching/pkg/client/listers/caching/v1alpha1
1423-
# knative.dev/hack v0.0.0-20250331013814-c577ed9f7775
1423+
# knative.dev/hack v0.0.0-20251022160648-4a7a07f9b7b4
14241424
## explicit; go 1.21
14251425
knative.dev/hack
14261426
# knative.dev/networking v0.0.0-20250415164913-6268d931d247

0 commit comments

Comments
 (0)