Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-v1.10] Sync upstream release #345

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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