Skip to content

Commit

Permalink
[release-v1.10] Sync upstream release (#345)
Browse files Browse the repository at this point in the history
* Min TLS for tag to digest defaults to 1.2 again and is configurable (knative#13963)

quay.io only supports 1.2

Co-authored-by: dprotaso <[email protected]>

* drop safe to evict annotations (knative#14051)

this prevents nodes from draining

Co-authored-by: dprotaso <[email protected]>

* [release-1.10] RandomChoice 2 policy wasn't random when the number of targets is 2 (with equal weight) (knative#14052)

* RandomChoice 2 policy wasn't random when the number of targets is 2

* fix linting

---------

Co-authored-by: dprotaso <[email protected]>

* Sync upstream release

---------

Co-authored-by: Knative Prow Robot <[email protected]>
Co-authored-by: dprotaso <[email protected]>
Co-authored-by: John Doe <johndoe@localhost>
Co-authored-by: nak3 <[email protected]>
  • Loading branch information
5 people authored Jun 8, 2023
1 parent 650511a commit 6e25efb
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 28 deletions.
2 changes: 0 additions & 2 deletions config/core/deployments/activator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ spec:
role: activator
template:
metadata:
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: "false"
labels:
app: activator
role: activator
Expand Down
2 changes: 0 additions & 2 deletions config/core/deployments/autoscaler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ spec:
maxUnavailable: 0
template:
metadata:
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: "false"
labels:
app: autoscaler
app.kubernetes.io/component: autoscaler
Expand Down
2 changes: 0 additions & 2 deletions config/core/deployments/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ spec:
app: controller
template:
metadata:
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
labels:
app: controller
app.kubernetes.io/component: controller
Expand Down
2 changes: 0 additions & 2 deletions config/core/deployments/domainmapping-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ spec:
app: domain-mapping
template:
metadata:
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
labels:
app: domain-mapping
app.kubernetes.io/component: domain-mapping
Expand Down
2 changes: 0 additions & 2 deletions config/core/deployments/domainmapping-webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ spec:
role: domainmapping-webhook
template:
metadata:
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: "false"
labels:
app: domainmapping-webhook
role: domainmapping-webhook
Expand Down
2 changes: 0 additions & 2 deletions config/core/deployments/webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ spec:
role: webhook
template:
metadata:
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: "false"
labels:
app: webhook
role: webhook
Expand Down
2 changes: 0 additions & 2 deletions config/hpa-autoscaling/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ spec:
app: autoscaler-hpa
template:
metadata:
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
labels:
app: autoscaler-hpa
app.kubernetes.io/component: autoscaler-hpa
Expand Down
12 changes: 0 additions & 12 deletions openshift/release/artifacts/serving-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6028,8 +6028,6 @@ spec:
role: activator
template:
metadata:
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: "false"
labels:
app: activator
role: activator
Expand Down Expand Up @@ -6192,8 +6190,6 @@ spec:
maxUnavailable: 0
template:
metadata:
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: "false"
labels:
app: autoscaler
app.kubernetes.io/component: autoscaler
Expand Down Expand Up @@ -6334,8 +6330,6 @@ spec:
app: controller
template:
metadata:
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
labels:
app: controller
app.kubernetes.io/component: controller
Expand Down Expand Up @@ -6471,8 +6465,6 @@ spec:
app: domain-mapping
template:
metadata:
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
labels:
app: domain-mapping
app.kubernetes.io/component: domain-mapping
Expand Down Expand Up @@ -6582,8 +6574,6 @@ spec:
role: domainmapping-webhook
template:
metadata:
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: "false"
labels:
app: domainmapping-webhook
role: domainmapping-webhook
Expand Down Expand Up @@ -6790,8 +6780,6 @@ spec:
role: webhook
template:
metadata:
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: "false"
labels:
app: webhook
role: webhook
Expand Down
2 changes: 0 additions & 2 deletions openshift/release/artifacts/serving-hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ spec:
app: autoscaler-hpa
template:
metadata:
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
labels:
app: autoscaler-hpa
app.kubernetes.io/component: autoscaler-hpa
Expand Down
5 changes: 5 additions & 0 deletions pkg/activator/net/lb_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ func randomChoice2Policy(_ context.Context, targets []*podTracker) (func(), *pod
// so fine.
if pick.getWeight() > alt.getWeight() {
pick = alt
} else if pick.getWeight() == alt.getWeight() {
//nolint:gosec // We don't need cryptographic randomness here.
if rand.Int63()%2 == 0 {
pick = alt
}
}
pick.increaseWeight()
return pick.decreaseWeight, pick
Expand Down
26 changes: 26 additions & 0 deletions pkg/activator/net/lb_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,32 @@ import (
"knative.dev/serving/pkg/queue"
)

func TestRandomChoice_TwoTrackersDistribution(t *testing.T) {
podTrackers := makeTrackers(2, 0)
counts := map[string]int{}

total := 100
for i := 0; i < total; i++ {
cb, pt := randomChoice2Policy(context.Background(), podTrackers)
cb()
counts[pt.dest]++
}

first := counts[podTrackers[0].dest]
second := counts[podTrackers[1].dest]

// probability of this occurring is 0.5^100
if first == 0 {
t.Error("expected the first tracker to get some requests")
}
if second == 0 {
t.Error("expected the second tracker to get some requests")
}
if first+second != total {
t.Error("expected total requests to equal 100 - was ", first+second)
}
}

func TestRandomChoice2(t *testing.T) {
t.Run("1 tracker", func(t *testing.T) {
podTrackers := makeTrackers(1, 0)
Expand Down

0 comments on commit 6e25efb

Please sign in to comment.