Skip to content

Commit d6e3f34

Browse files
authored
Merge pull request kubernetes#131211 from BenTheElder/max-pods
fix flaky garbage collector tests
2 parents b15dfce + 18249aa commit d6e3f34

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

test/conformance/testdata/conformance.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@
511511
file: test/e2e/apimachinery/garbage_collector.go
512512
- testname: Garbage Collector, delete replication controller, after owned pods
513513
codename: '[sig-api-machinery] Garbage collector should keep the rc around until
514-
all its pods are deleted if the deleteOptions says so [Conformance]'
514+
all its pods are deleted if the deleteOptions says so [Serial] [Conformance]'
515515
description: Create a replication controller with maximum allocatable Pods between
516516
10 and 100 replicas. Once RC is created and the all Pods are created, delete RC
517517
with deleteOptions.PropagationPolicy set to Foreground. Deleting the Replication
@@ -528,7 +528,8 @@
528528
file: test/e2e/apimachinery/garbage_collector.go
529529
- testname: Garbage Collector, multiple owners
530530
codename: '[sig-api-machinery] Garbage collector should not delete dependents that
531-
have both valid owner and owner that''s waiting for dependents to be deleted [Conformance]'
531+
have both valid owner and owner that''s waiting for dependents to be deleted [Serial]
532+
[Conformance]'
532533
description: Create a replication controller RC1, with maximum allocatable Pods
533534
between 10 and 100 replicas. Create second replication controller RC2 and set
534535
RC2 as owner for half of those replicas. Once RC1 is created and the all Pods
@@ -549,7 +550,7 @@
549550
file: test/e2e/apimachinery/garbage_collector.go
550551
- testname: Garbage Collector, delete replication controller, propagation policy orphan
551552
codename: '[sig-api-machinery] Garbage collector should orphan pods created by rc
552-
if delete options say so [Conformance]'
553+
if delete options say so [Serial] [Conformance]'
553554
description: Create a replication controller with maximum allocatable Pods between
554555
10 and 100 replicas. Once RC is created and the all Pods are created, delete RC
555556
with deleteOptions.PropagationPolicy set to Orphan. Deleting the Replication Controller

test/e2e/apimachinery/garbage_collector.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,31 @@ import (
5454
// estimateMaximumPods estimates how many pods the cluster can handle
5555
// with some wiggle room, to prevent pods being unable to schedule due
5656
// to max pod constraints.
57+
//
58+
// Tests that call this should use framework.WithSerial() because they're not
59+
// safe to run concurrently as they consume a large number of pods.
5760
func estimateMaximumPods(ctx context.Context, c clientset.Interface, min, max int32) int32 {
5861
nodes, err := e2enode.GetReadySchedulableNodes(ctx, c)
5962
framework.ExpectNoError(err)
6063

6164
availablePods := int32(0)
65+
// estimate some reasonable overhead per-node for pods that are non-test
66+
const daemonSetReservedPods = 10
6267
for _, node := range nodes.Items {
6368
if q, ok := node.Status.Allocatable["pods"]; ok {
6469
if num, ok := q.AsInt64(); ok {
65-
availablePods += int32(num)
70+
if num > daemonSetReservedPods {
71+
availablePods += int32(num - daemonSetReservedPods)
72+
}
6673
continue
6774
}
6875
}
69-
// best guess per node, since default maxPerCore is 10 and most nodes have at least
76+
// Only when we fail to obtain the number, we fall back to a best guess
77+
// per node. Since default maxPerCore is 10 and most nodes have at least
7078
// one core.
7179
availablePods += 10
7280
}
73-
//avoid creating exactly max pods
81+
// avoid creating exactly max pods
7482
availablePods = int32(float32(availablePods) * 0.5)
7583
// bound the top and bottom
7684
if availablePods > max {
@@ -377,7 +385,7 @@ var _ = SIGDescribe("Garbage collector", func() {
377385
Testname: Garbage Collector, delete replication controller, propagation policy orphan
378386
Description: Create a replication controller with maximum allocatable Pods between 10 and 100 replicas. Once RC is created and the all Pods are created, delete RC with deleteOptions.PropagationPolicy set to Orphan. Deleting the Replication Controller MUST cause pods created by that RC to be orphaned.
379387
*/
380-
framework.ConformanceIt("should orphan pods created by rc if delete options say so", func(ctx context.Context) {
388+
framework.ConformanceIt("should orphan pods created by rc if delete options say so", framework.WithSerial(), func(ctx context.Context) {
381389
clientSet := f.ClientSet
382390
rcClient := clientSet.CoreV1().ReplicationControllers(f.Namespace.Name)
383391
podClient := clientSet.CoreV1().Pods(f.Namespace.Name)
@@ -636,7 +644,7 @@ var _ = SIGDescribe("Garbage collector", func() {
636644
Testname: Garbage Collector, delete replication controller, after owned pods
637645
Description: Create a replication controller with maximum allocatable Pods between 10 and 100 replicas. Once RC is created and the all Pods are created, delete RC with deleteOptions.PropagationPolicy set to Foreground. Deleting the Replication Controller MUST cause pods created by that RC to be deleted before the RC is deleted.
638646
*/
639-
framework.ConformanceIt("should keep the rc around until all its pods are deleted if the deleteOptions says so", func(ctx context.Context) {
647+
framework.ConformanceIt("should keep the rc around until all its pods are deleted if the deleteOptions says so", framework.WithSerial(), func(ctx context.Context) {
640648
clientSet := f.ClientSet
641649
rcClient := clientSet.CoreV1().ReplicationControllers(f.Namespace.Name)
642650
podClient := clientSet.CoreV1().Pods(f.Namespace.Name)
@@ -711,7 +719,7 @@ var _ = SIGDescribe("Garbage collector", func() {
711719
Testname: Garbage Collector, multiple owners
712720
Description: Create a replication controller RC1, with maximum allocatable Pods between 10 and 100 replicas. Create second replication controller RC2 and set RC2 as owner for half of those replicas. Once RC1 is created and the all Pods are created, delete RC1 with deleteOptions.PropagationPolicy set to Foreground. Half of the Pods that has RC2 as owner MUST not be deleted or have a deletion timestamp. Deleting the Replication Controller MUST not delete Pods that are owned by multiple replication controllers.
713721
*/
714-
framework.ConformanceIt("should not delete dependents that have both valid owner and owner that's waiting for dependents to be deleted", func(ctx context.Context) {
722+
framework.ConformanceIt("should not delete dependents that have both valid owner and owner that's waiting for dependents to be deleted", framework.WithSerial(), func(ctx context.Context) {
715723
clientSet := f.ClientSet
716724
rcClient := clientSet.CoreV1().ReplicationControllers(f.Namespace.Name)
717725
podClient := clientSet.CoreV1().Pods(f.Namespace.Name)

0 commit comments

Comments
 (0)