From d84e7c840cdd73da640614f7104f4304c5f147f8 Mon Sep 17 00:00:00 2001 From: Charlie McBride <33269602+charliedmcb@users.noreply.github.com> Date: Mon, 2 Dec 2024 14:11:02 -0800 Subject: [PATCH 1/2] add optional control over log level (#597) --- hack/deploy/configure-values.sh | 6 +++++- karpenter-values-template.yaml | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/hack/deploy/configure-values.sh b/hack/deploy/configure-values.sh index 37d50fab9..d1c6b8441 100755 --- a/hack/deploy/configure-values.sh +++ b/hack/deploy/configure-values.sh @@ -16,6 +16,9 @@ AZURE_RESOURCE_GROUP=$2 KARPENTER_SERVICE_ACCOUNT_NAME=$3 AZURE_KARPENTER_USER_ASSIGNED_IDENTITY_NAME=$4 +# Optional values through env vars: +LOG_LEVEL=${LOG_LEVEL:-"info"} + AKS_JSON=$(az aks show --name "$CLUSTER_NAME" --resource-group "$AZURE_RESOURCE_GROUP" -o json) AZURE_LOCATION=$(jq -r ".location" <<< "$AKS_JSON") AZURE_RESOURCE_GROUP_MC=$(jq -r ".nodeResourceGroup" <<< "$AKS_JSON") @@ -47,7 +50,8 @@ NODE_IDENTITIES=$(jq -r ".identityProfile.kubeletidentity.resourceId" <<< "$AKS_ KARPENTER_USER_ASSIGNED_CLIENT_ID=$(az identity show --resource-group "${AZURE_RESOURCE_GROUP}" --name "${AZURE_KARPENTER_USER_ASSIGNED_IDENTITY_NAME}" --query 'clientId' -otsv) export CLUSTER_NAME AZURE_LOCATION AZURE_RESOURCE_GROUP_MC KARPENTER_SERVICE_ACCOUNT_NAME \ - CLUSTER_ENDPOINT BOOTSTRAP_TOKEN SSH_PUBLIC_KEY VNET_SUBNET_ID KARPENTER_USER_ASSIGNED_CLIENT_ID NODE_IDENTITIES AZURE_SUBSCRIPTION_ID NETWORK_PLUGIN NETWORK_PLUGIN_MODE NETWORK_POLICY + CLUSTER_ENDPOINT BOOTSTRAP_TOKEN SSH_PUBLIC_KEY VNET_SUBNET_ID KARPENTER_USER_ASSIGNED_CLIENT_ID NODE_IDENTITIES AZURE_SUBSCRIPTION_ID NETWORK_PLUGIN NETWORK_PLUGIN_MODE NETWORK_POLICY \ + LOG_LEVEL # get karpenter-values-template.yaml, if not already present (e.g. outside of repo context) if [ ! -f karpenter-values-template.yaml ]; then diff --git a/karpenter-values-template.yaml b/karpenter-values-template.yaml index 01473e98c..8b8fa5e12 100644 --- a/karpenter-values-template.yaml +++ b/karpenter-values-template.yaml @@ -43,3 +43,4 @@ serviceAccount: azure.workload.identity/client-id: ${KARPENTER_USER_ASSIGNED_CLIENT_ID} podLabels: azure.workload.identity/use: "true" +logLevel: ${LOG_LEVEL} From 44cddef292d0e55e0b379880c727c7072864ecd1 Mon Sep 17 00:00:00 2001 From: Alex Leites <18728999+tallaxes@users.noreply.github.com> Date: Mon, 2 Dec 2024 14:41:51 -0800 Subject: [PATCH 2/2] fix: E2E node expiration test (#595) * fix: expiration test * Update test/suites/integration/expiration_test.go --- test/suites/integration/expiration_test.go | 27 +++++----------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/test/suites/integration/expiration_test.go b/test/suites/integration/expiration_test.go index 278038541..33a76eba1 100644 --- a/test/suites/integration/expiration_test.go +++ b/test/suites/integration/expiration_test.go @@ -18,7 +18,6 @@ package integration_test import ( . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" "github.com/samber/lo" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -26,7 +25,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/util/intstr" - "sigs.k8s.io/controller-runtime/pkg/client" karpv1 "sigs.k8s.io/karpenter/pkg/apis/v1" @@ -53,7 +51,8 @@ var _ = Describe("Expiration", func() { selector = labels.SelectorFromSet(dep.Spec.Selector.MatchLabels) }) It("should expire the node after the expiration is reached", func() { - nodePool.Spec.Template.Spec.ExpireAfter = karpv1.MustParseNillableDuration("2m") + // Set expire after large enough to make sure the new nodes are not expired before workloads are moved over. + nodePool.Spec.Template.Spec.ExpireAfter = karpv1.MustParseNillableDuration("3m") env.ExpectCreated(nodeClass, nodePool, dep) nodeClaim := env.EventuallyExpectCreatedNodeClaimCount("==", 1)[0] @@ -62,15 +61,8 @@ var _ = Describe("Expiration", func() { env.Monitor.Reset() // Reset the monitor so that we can expect a single node to be spun up after expiration // Eventually the node will be tainted, which means its actively being disrupted - Eventually(func(g Gomega) { - g.Expect(env.Client.Get(env.Context, client.ObjectKeyFromObject(node), node)).Should(Succeed()) - _, ok := lo.Find(node.Spec.Taints, func(t corev1.Taint) bool { - return t.MatchTaint(&karpv1.DisruptedNoScheduleTaint) - }) - g.Expect(ok).To(BeTrue()) - }).Should(Succeed()) - - env.EventuallyExpectCreatedNodeCount("==", 2) + env.EventuallyExpectTaintedNodeCount("==", 1) + env.EventuallyExpectCreatedNodeCount("==", 1) // Set the limit to 0 to make sure we don't continue to create nodeClaims. // This is CRITICAL since it prevents leaking node resources into subsequent tests nodePool.Spec.Limits = karpv1.Limits{ @@ -109,15 +101,8 @@ var _ = Describe("Expiration", func() { env.Monitor.Reset() // Reset the monitor so that we can expect a single node to be spun up after expiration // Eventually the node will be tainted, which means its actively being disrupted - Eventually(func(g Gomega) { - g.Expect(env.Client.Get(env.Context, client.ObjectKeyFromObject(node), node)).Should(Succeed()) - _, ok := lo.Find(node.Spec.Taints, func(t corev1.Taint) bool { - return t.MatchTaint(&karpv1.DisruptedNoScheduleTaint) - }) - g.Expect(ok).To(BeTrue()) - }).Should(Succeed()) - - env.EventuallyExpectCreatedNodeCount("==", 2) + env.EventuallyExpectTaintedNodeCount("==", 1) + env.EventuallyExpectCreatedNodeCount("==", 1) // Set the limit to 0 to make sure we don't continue to create nodeClaims. // This is CRITICAL since it prevents leaking node resources into subsequent tests nodePool.Spec.Limits = karpv1.Limits{