Skip to content

Commit f541c9a

Browse files
authored
fix: Backport webhook smoke test v0.33.x (#7228)
1 parent f5b826b commit f541c9a

File tree

5 files changed

+77
-2
lines changed

5 files changed

+77
-2
lines changed

.github/actions/e2e/install-karpenter/action.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ inputs:
2222
k8s_version:
2323
description: 'Version of Kubernetes to use for the launched cluster'
2424
default: "1.28"
25+
webhooks_enabled:
26+
description: "Whether webhooks are enabled or not. Valid values are 'true' or 'false'"
27+
default: 'true'
2528
git_ref:
2629
description: "The git commit, tag, or branch to check out. Requires a corresponding Karpenter snapshot release"
2730
runs:
@@ -52,13 +55,12 @@ runs:
5255
# Parse minor version to determine whether to enable the webhooks
5356
VERSION=${{ inputs.k8s_version }}
5457
RELEASE_VERSION_MINOR="${VERSION#*.}"
55-
WEBHOOK_ENABLED=true
5658
5759
helm upgrade --install karpenter oci://${{ inputs.ecr_account_id }}.dkr.ecr.${{ inputs.ecr_region }}.amazonaws.com/karpenter/snapshot/karpenter \
5860
-n kube-system \
5961
--version "v0-$(git rev-parse HEAD)" \
6062
--set serviceAccount.annotations."eks\.amazonaws\.com/role-arn"="arn:aws:iam::${{ inputs.account_id }}:role/karpenter-irsa-${{ inputs.cluster_name }}" \
61-
--set webhook.enabled=${WEBHOOK_ENABLED} \
63+
--set webhook.enabled=${{ inputs.webhooks_enabled }} \
6264
--set settings.clusterName="${{ inputs.cluster_name }}" \
6365
--set settings.interruptionQueue="${{ inputs.cluster_name }}" \
6466
--set controller.resources.requests.cpu=3 \

.github/actions/e2e/setup-cluster/action.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ inputs:
3737
private_cluster:
3838
description: "Whether to create a private cluster which does not add access to the public internet. Valid values are 'true' or 'false'"
3939
default: 'false'
40+
webhooks_enabled:
41+
description: "Whether webhooks are enabled or not. Valid values are 'true' or 'false'"
42+
default: 'true'
4043
git_ref:
4144
description: "The git commit, tag, or branch to check out. Requires a corresponding Karpenter snapshot release"
4245
required: false
@@ -216,4 +219,5 @@ runs:
216219
ecr_region: ${{ inputs.ecr_region }}
217220
cluster_name: ${{ inputs.cluster_name }}
218221
k8s_version: ${{ inputs.k8s_version }}
222+
webhooks_enabled: ${{ inputs.webhooks_enabled }}
219223
git_ref: ${{ inputs.git_ref }}

.github/workflows/e2e-matrix.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ jobs:
6767
- Expiration
6868
- Chaos
6969
- IPv6
70+
- Webhooks
7071
uses: ./.github/workflows/e2e.yaml
7172
with:
7273
suite: ${{ matrix.suite }}

.github/workflows/e2e.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ on:
2626
- IPv6
2727
- Scale
2828
- PrivateCluster
29+
- Webhooks
2930
k8s_version:
3031
type: choice
3132
options:
@@ -116,6 +117,7 @@ jobs:
116117
ecr_region: ${{ vars.ECR_REGION }}
117118
prometheus_workspace_id: ${{ vars.WORKSPACE_ID }}
118119
prometheus_region: ${{ vars.PROMETHEUS_REGION }}
120+
webhooks_enabled: ${{ inputs.suite != 'Webhooks' && true }} # Set webhooks_enabled to false if running webhook smoke test suite
119121
- name: run the ${{ inputs.suite }} test suite
120122
run: |
121123
TEST_SUITE="${{ inputs.suite }}"

test/suites/webhooks/suite_test.go

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
Licensed under the Apache License, Version 2.0 (the "License");
3+
you may not use this file except in compliance with the License.
4+
You may obtain a copy of the License at
5+
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
8+
Unless required by applicable law or agreed to in writing, software
9+
distributed under the License is distributed on an "AS IS" BASIS,
10+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
See the License for the specific language governing permissions and
12+
limitations under the License.
13+
*/
14+
15+
package webhooks_test
16+
17+
import (
18+
"context"
19+
"testing"
20+
21+
v1beta1 "github.com/aws/karpenter/pkg/apis/v1beta1"
22+
"github.com/aws/karpenter/test/pkg/environment/aws"
23+
24+
karpv1beta1 "sigs.k8s.io/karpenter/pkg/apis/v1beta1"
25+
26+
karptest "sigs.k8s.io/karpenter/pkg/test"
27+
28+
. "github.com/onsi/ginkgo/v2"
29+
. "github.com/onsi/gomega"
30+
. "knative.dev/pkg/logging/testing"
31+
)
32+
33+
var ctx context.Context
34+
var env *aws.Environment
35+
var nodeClass *v1beta1.EC2NodeClass
36+
var nodePool *karpv1beta1.NodePool
37+
38+
func TestWebhooks(t *testing.T) {
39+
RegisterFailHandler(Fail)
40+
41+
ctx = TestContextWithLogger(t)
42+
BeforeSuite(func() {
43+
env = aws.NewEnvironment(t)
44+
})
45+
AfterSuite(func() {
46+
env.Stop()
47+
})
48+
RunSpecs(t, "Webhooks")
49+
}
50+
51+
var _ = BeforeEach(func() {
52+
env.BeforeEach()
53+
nodeClass = env.DefaultEC2NodeClass()
54+
nodePool = env.DefaultNodePool(nodeClass)
55+
})
56+
var _ = AfterEach(func() { env.Cleanup() })
57+
var _ = AfterEach(func() { env.AfterEach() })
58+
59+
var _ = Describe("Webhooks", func() {
60+
It("should schedule pods when webhooks are disabled", func() {
61+
pod := karptest.Pod()
62+
env.ExpectCreated(pod, nodeClass, nodePool)
63+
env.EventuallyExpectHealthy(pod)
64+
env.ExpectCreatedNodeCount("==", 1)
65+
})
66+
})

0 commit comments

Comments
 (0)