Skip to content

Commit 436374b

Browse files
authoredSep 13, 2022
test: Use daemonset count to calculate maxPods and podsPerCore (#2497)
1 parent ad9f2c5 commit 436374b

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed
 

‎Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ battletest: ## Run randomized, racing, code coveraged, tests
4949

5050
e2etests: ## Run the e2e suite against your local cluster
5151
go clean -testcache
52-
go test -p 1 -timeout 180m -v ./test/suites/... -run=${TEST_FILTER}
52+
CLUSTER_NAME=${CLUSTER_NAME} go test -p 1 -timeout 180m -v ./test/suites/... -run=${TEST_FILTER}
5353

5454
benchmark:
5555
go test -tags=test_performance -run=NoTests -bench=. ./...

‎test/suites/integration/kubelet_config_test.go

+21-6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ package integration_test
1616

1717
import (
1818
. "github.com/onsi/ginkgo/v2"
19+
. "github.com/onsi/gomega"
20+
appsv1 "k8s.io/api/apps/v1"
1921
v1 "k8s.io/api/core/v1"
2022
"knative.dev/pkg/ptr"
2123

@@ -27,15 +29,22 @@ import (
2729

2830
var _ = Describe("KubeletConfiguration Overrides", func() {
2931
It("should schedule pods onto separate nodes when maxPods is set", func() {
32+
// Get the total number of daemonsets so that we see how many pods will be taken up
33+
// by daemonset overhead
34+
dsList := &appsv1.DaemonSetList{}
35+
Expect(env.Client.List(env.Context, dsList)).To(Succeed())
36+
dsCount := len(dsList.Items)
37+
3038
provider := test.AWSNodeTemplate(v1alpha1.AWSNodeTemplateSpec{AWS: awsv1alpha1.AWS{
3139
SecurityGroupSelector: map[string]string{"karpenter.sh/discovery": env.ClusterName},
3240
SubnetSelector: map[string]string{"karpenter.sh/discovery": env.ClusterName},
3341
}})
42+
3443
// MaxPods needs to account for the daemonsets that will run on the nodes
3544
provisioner := test.Provisioner(test.ProvisionerOptions{
3645
ProviderRef: &v1alpha5.ProviderRef{Name: provider.Name},
3746
Kubelet: &v1alpha5.KubeletConfiguration{
38-
MaxPods: ptr.Int32(3),
47+
MaxPods: ptr.Int32(1 + int32(dsCount)),
3948
},
4049
})
4150

@@ -48,6 +57,12 @@ var _ = Describe("KubeletConfiguration Overrides", func() {
4857
env.ExpectCreatedNodeCount("==", 3)
4958
})
5059
It("should schedule pods onto separate nodes when podsPerCore is set", func() {
60+
// Get the total number of daemonsets so that we see how many pods will be taken up
61+
// by daemonset overhead
62+
dsList := &appsv1.DaemonSetList{}
63+
Expect(env.Client.List(env.Context, dsList)).To(Succeed())
64+
dsCount := len(dsList.Items)
65+
5166
provider := test.AWSNodeTemplate(v1alpha1.AWSNodeTemplateSpec{AWS: awsv1alpha1.AWS{
5267
SecurityGroupSelector: map[string]string{"karpenter.sh/discovery": env.ClusterName},
5368
SubnetSelector: map[string]string{"karpenter.sh/discovery": env.ClusterName},
@@ -57,13 +72,13 @@ var _ = Describe("KubeletConfiguration Overrides", func() {
5772
provisioner := test.Provisioner(test.ProvisionerOptions{
5873
ProviderRef: &v1alpha5.ProviderRef{Name: provider.Name},
5974
Kubelet: &v1alpha5.KubeletConfiguration{
60-
PodsPerCore: ptr.Int32(2),
75+
PodsPerCore: ptr.Int32(2 + int32(dsCount)),
6176
},
6277
Requirements: []v1.NodeSelectorRequirement{
6378
{
6479
Key: awsv1alpha1.LabelInstanceCPU,
6580
Operator: v1.NodeSelectorOpIn,
66-
Values: []string{"2"},
81+
Values: []string{"1"},
6782
},
6883
},
6984
})
@@ -87,13 +102,13 @@ var _ = Describe("KubeletConfiguration Overrides", func() {
87102
provisioner := test.Provisioner(test.ProvisionerOptions{
88103
ProviderRef: &v1alpha5.ProviderRef{Name: provider.Name},
89104
Kubelet: &v1alpha5.KubeletConfiguration{
90-
PodsPerCore: ptr.Int32(2),
105+
PodsPerCore: ptr.Int32(1),
91106
},
92107
Requirements: []v1.NodeSelectorRequirement{
93108
{
94109
Key: awsv1alpha1.LabelInstanceCPU,
95110
Operator: v1.NodeSelectorOpIn,
96-
Values: []string{"2"},
111+
Values: []string{"1"},
97112
},
98113
},
99114
})
@@ -104,6 +119,6 @@ var _ = Describe("KubeletConfiguration Overrides", func() {
104119
env.ExpectCreated(pod)
105120
}
106121
env.EventuallyExpectHealthy(pods...)
107-
env.ExpectCreatedNodeCount("<=", 2) // should probably all land on a single node, but at worst two depending on batching
122+
env.ExpectCreatedNodeCount("==", 1)
108123
})
109124
})

0 commit comments

Comments
 (0)
Please sign in to comment.