Skip to content
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
3 changes: 2 additions & 1 deletion cmd/infra/aws/iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ var (
"arn:*:ec2:*::image/*",
"arn:*:ec2:*::snapshot/*",
"arn:*:ec2:*:*:security-group/*",
"arn:*:ec2:*:*:subnet/*"
"arn:*:ec2:*:*:subnet/*",
"arn:*:ec2:*:*:capacity-reservation/*"
],
"Action": [
"ec2:RunInstances",
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/util/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func DestroyOIDCProvider(ctx context.Context, log logr.Logger, iamClient awsapi.
// associates it with an existing private route table (one with a NAT gateway route),
// and returns the subnet ID plus a cleanup function that disassociates and deletes it.
// The subnet CIDR is chosen dynamically to avoid overlapping with any existing subnets.
func CreateTestSubnet(ctx context.Context, t *testing.T, client *ec2v2.Client, vpcID, az, infraID, clusterName string, additionalTags map[string]string) (string, func()) {
func CreateTestSubnet(ctx context.Context, t testing.TB, client *ec2v2.Client, vpcID, az, infraID, clusterName string, additionalTags map[string]string) (string, func()) {
t.Helper()

// Fetch all existing subnets in the VPC to find a non-overlapping CIDR.
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ func WaitForGuestKubeConfig(t testing.TB, ctx context.Context, client crclient.C
return data
}

func WaitForGuestRestConfig(t *testing.T, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster) *rest.Config {
func WaitForGuestRestConfig(t testing.TB, ctx context.Context, client crclient.Client, hostedCluster *hyperv1.HostedCluster) *rest.Config {
g := NewWithT(t)
guestKubeConfigSecretData := WaitForGuestKubeConfig(t, ctx, client, hostedCluster)
guestConfig, err := clientcmd.RESTConfigFromKubeConfig(guestKubeConfigSecretData)
Expand Down Expand Up @@ -2844,7 +2844,7 @@ func extractDataFromFamilies(metricFamilies map[string]*dto.MetricFamily, metric

// ValidateMetricPresence checks if a metric meets the expected presence criteria
// Returns true if validation passes, false otherwise
func ValidateMetricPresence(t *testing.T, mf map[string]*dto.MetricFamily, query, labelKey, labelValue, metricName string, areMetricsExpectedToBePresent bool) bool {
func ValidateMetricPresence(t testing.TB, mf map[string]*dto.MetricFamily, query, labelKey, labelValue, metricName string, areMetricsExpectedToBePresent bool) bool {
labelPairs := extractDataFromFamilies(mf, query, labelKey, labelValue)
if areMetricsExpectedToBePresent {
if len(labelPairs) < 1 {
Expand Down
18 changes: 18 additions & 0 deletions test/e2e/v2/internal/env_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,13 @@ func init() {
"Azure DiskEncryptionSet resource ID for disk encryption NodePool tests.",
false,
)
// Karpenter test environment variables
RegisterEnvVarWithDefault(
"PULL_SECRET_FILE",
"Path to pull secret file for release image lookups. Used by Karpenter version field tests.",
false,
"",
)
// External OIDC test environment variables
RegisterEnvVar(
"E2E_EXTERNAL_OIDC_CA_BUNDLE_FILE",
Expand All @@ -219,4 +226,15 @@ func init() {
"Comma-separated list of test users in user:password format for External OIDC testing. Written by the lifecycle PostCreate.",
false,
)
RegisterEnvVar(
"RUN_KARPENTER_TESTS",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description fix helps, but the name RUN_KARPENTER_TESTS still reads like it gates whether the Karpenter tests run at all, when its only effect is lowering the min version from 4.23 to 4.22. Someone wiring CI from the var name alone would likely get it wrong. Could we rename it (e.g. KARPENTER_ALLOW_422) to reflect what it does?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not without changing all the existing CI machinery, this is meant to be a drop in parallel port for now. Agree it should be changed in a followup

"When the value is exactly \"true\", it lowers the minimum hosted-cluster version from 4.23 to 4.22.",
false,
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
)
// TODO: Should this be a capability check?
RegisterEnvVar(
"AWS_MULTI_ARCH",
"Enable multi-arch cluster tests on AWS",
false,
)
}
37 changes: 31 additions & 6 deletions test/e2e/v2/lifecycle/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,29 @@ func (a *AWSPlatformConfig) ClusterSpecs(releaseImage, n1Image string) []Cluster
}
return []ClusterSpec{
{
Variant: "public",
ExtraArgs: extraArgs,
Variant: "public",
ExtraArgs: append(extraArgs, []string{
"--public-only",
}...),
},
// The KarpenterBillingConsolidationTest actually tests hostedcluster teardown
// behavior and so needs its own dedicated cluster. This seems somewhat leaky
// in terms of test isolation because a downstream teardown of a cluster the
// test doesn't actually own is only indirectly related to the test and the
// test can't actually make any assertions. This is a fundamental difference
// from v1 where tests own the lifecycle of the hostedcluster. In v2 tests are
// explicitly decoupled from the hostedcluster lifecycle and so have no inherent
// ability to make any such lifecycle assertions. This could mean that either
// the assertion itself needs to change to decouple it from lifecycle somehow,
// or there's a gap in the v2 framework for this sort of use case...
{
Variant: "karpenter",
ExtraArgs: append(extraArgs, []string{
// Enables Karpenter-based node provisioning (AutoNode)
"--auto-node",
// Required for karpenter to reach the hosted cluster API server from the mgmt cluster
"--endpoint-access=PublicAndPrivate",
}...),
},
}
}
Expand All @@ -70,7 +91,6 @@ func (a *AWSPlatformConfig) CreateArgs() []string {
"--zones=" + strings.Join(a.zones, ","),
"--root-volume-size=64",
"--root-volume-type=gp3",
"--public-only",
"--pods-labels=hypershift-e2e-test-label=test",
"--toleration=key=hypershift-e2e-test-toleration,operator=Equal,value=true,effect=NoSchedule",
"--annotations=hypershift.openshift.io/cleanup-cloud-resources=true",
Expand Down Expand Up @@ -103,16 +123,21 @@ func (a *AWSPlatformConfig) TestMatrix(releaseImage string) TestMatrix {
return TestMatrix{
Parallel: []TestGroup{
{
Name: "aws-public",
Name: "public",
Variant: "public",
LabelFilter: "!lifecycle || hosted-cluster-aws",
JUnitFile: "junit_aws_public.xml",
JUnitFile: "junit_public.xml",
},
{
Name: "karpenter",
Variant: "karpenter",
LabelFilter: "karpenter",
JUnitFile: "junit_karpenter.xml",
},
},
}
}


func (a *AWSPlatformConfig) SetupTestEnv(sharedDir string) {}

func (a *AWSPlatformConfig) DestroyArgs() []string {
Expand Down
76 changes: 76 additions & 0 deletions test/e2e/v2/tests/assets/karpenter-kubelet-checker-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
apiVersion: v1
kind: Pod
metadata:
name: kubelet-config-checker
namespace: kube-system
spec:
restartPolicy: Never
containers:
- name: checker
image: alpine
command:
- /bin/sh
- -c
- |
set -u
FILE=/host/etc/kubernetes/kubelet.conf
ENV_FILE=/host/etc/node-sizing-enabled.env
FAIL=0

check() {
local label="$1"; shift
if grep -q "$@" "$FILE"; then
echo "PASS: $label"
else
echo "FAIL: $label (pattern: $*)"
FAIL=1
fi
}

check_env() {
local label="$1"; shift
if grep -q "$@" "$ENV_FILE"; then
echo "PASS: $label"
else
echo "FAIL: $label (pattern: $*)"
FAIL=1
fi
}

echo "=== kubelet.conf ==="
cat "$FILE"
echo "=== node-sizing-enabled.env ==="
cat "$ENV_FILE"
echo "=== grep checks ==="

check "maxPods: 203" 'maxPods: 203'
check "podsPerCore: 11" 'podsPerCore: 11'
check "cpuCFSQuota: false" 'cpuCFSQuota: false'
check "evictionMaxPodGracePeriod: 31" 'evictionMaxPodGracePeriod: 31'
check "imageGCHighThresholdPercent: 81" 'imageGCHighThresholdPercent: 81'
check "imageGCLowThresholdPercent: 71" 'imageGCLowThresholdPercent: 71'
check "kubeReserved cpu: 520m" 'cpu: 520m'
check "kubeReserved memory: 531Mi" 'memory: 531Mi'
check "evictionHard memory.available 201Mi" 'memory.available: 201Mi'
check "evictionHard nodefs.available 11%" 'nodefs.available: 11%'
check "evictionSoft memory.available 401Mi" 'memory.available: 401Mi'
check "evictionSoft nodefs.available 16%" 'nodefs.available: 16%'
check "evictionSoftGracePeriod 1m31s" '1m31s'
check "evictionSoftGracePeriod 2m5s" '2m5s'
check "podPidsLimit: 4096" 'podPidsLimit: 4096'
check "containerLogMaxSize: 50Mi" 'containerLogMaxSize: 50Mi'

check_env "SYSTEM_RESERVED_CPU=510m" 'SYSTEM_RESERVED_CPU=510m'
check_env "SYSTEM_RESERVED_MEMORY=521Mi" 'SYSTEM_RESERVED_MEMORY=521Mi'

exit $FAIL
securityContext:
privileged: true
volumeMounts:
- name: host
mountPath: /host
readOnly: true
volumes:
- name: host
hostPath:
path: /
2 changes: 1 addition & 1 deletion test/e2e/v2/tests/hosted_cluster_security_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func EnsureNetworkPoliciesTest(getTestCtx internal.TestContextGetter) {
g.Expect(runningPodName).NotTo(BeEmpty(), "a running private-router pod should exist")

_, err := v2util.RunCommandInPod(tc.Context, clientset, mgmtRestConfig,
tc.ControlPlaneNamespace, runningPodName, "private-router",
tc.ControlPlaneNamespace, runningPodName, "router",
"curl", "--connect-timeout", "2", "-Iks", kasAddress)
g.Expect(err).To(HaveOccurred(),
"private-router should not be able to reach the management KAS at %s", kasAddress)
Expand Down
Loading
Loading