Skip to content

Commit

Permalink
Merge branch 'main' into memory-overhead-controller
Browse files Browse the repository at this point in the history
  • Loading branch information
jukie authored Sep 14, 2024
2 parents 6ee1b24 + d07582b commit 6975505
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 11 deletions.
2 changes: 1 addition & 1 deletion test/hack/e2e_scripts/diff_karpenter.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CHART="oci://$ECR_ACCOUNT_ID.dkr.ecr.$ECR_REGION.amazonaws.com/karpenter/snapshot/karpenter"
if (( "$PRIVATE_CLUSTER" == 'true' )); then
if [[ "$PRIVATE_CLUSTER" == "true" ]]; then
CHART="oci://$ACCOUNT_ID.dkr.ecr.$REGION.amazonaws.com/karpenter/snapshot/karpenter"
fi

Expand Down
2 changes: 1 addition & 1 deletion test/hack/e2e_scripts/install_karpenter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ aws eks update-kubeconfig --name "$CLUSTER_NAME"

CHART="oci://$ECR_ACCOUNT_ID.dkr.ecr.$ECR_REGION.amazonaws.com/karpenter/snapshot/karpenter"
ADDITIONAL_FLAGS=""
if (( "$PRIVATE_CLUSTER" == "true" )); then
if [[ "$PRIVATE_CLUSTER" == "true" ]]; then
CHART="oci://$ACCOUNT_ID.dkr.ecr.$REGION.amazonaws.com/karpenter/snapshot/karpenter"
ADDITIONAL_FLAGS="--set .Values.controller.image.repository=$ACCOUNT_ID.dkr.ecr.$REGION.amazonaws.com/karpenter/snapshot/controller --set .Values.controller.image.digest=\"\" --set .Values.postInstallHook.image.repository=$ACCOUNT_ID.dkr.ecr.$REGION.amazonaws.com/ecr-public/bitnami/kubectl --set .Values.postInstallHook.image.digest=\"\""
fi
Expand Down
5 changes: 1 addition & 4 deletions test/pkg/environment/common/expectations.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,11 +506,8 @@ func (env *Environment) eventuallyExpectScaleDown() {

func (env *Environment) EventuallyExpectNotFound(objects ...client.Object) {
GinkgoHelper()
env.EventuallyExpectNotFoundAssertion(objects...).Should(Succeed())
}

func (env *Environment) EventuallyExpectNotFoundAssertion(objects ...client.Object) AsyncAssertion {
return Eventually(func(g Gomega) {
Eventually(func(g Gomega) {
for _, object := range objects {
err := env.Client.Get(env, client.ObjectKeyFromObject(object), object)
g.Expect(errors.IsNotFound(err)).To(BeTrue())
Expand Down
2 changes: 2 additions & 0 deletions test/suites/chaos/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"k8s.io/client-go/tools/cache"
controllerruntime "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
Expand Down Expand Up @@ -168,6 +169,7 @@ func (t *taintAdder) Reconcile(ctx context.Context, req reconcile.Request) (reco
func (t *taintAdder) Builder(mgr manager.Manager) *controllerruntime.Builder {
return controllerruntime.NewControllerManagedBy(mgr).
For(&corev1.Node{}).
WithOptions(controller.Options{SkipNameValidation: lo.ToPtr(true)}).
WithEventFilter(predicate.NewPredicateFuncs(func(obj client.Object) bool {
node := obj.(*corev1.Node)
if _, ok := node.Labels[coretest.DiscoveryLabel]; !ok {
Expand Down
28 changes: 24 additions & 4 deletions test/suites/interruption/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/uuid"
"sigs.k8s.io/controller-runtime/pkg/client"

karpv1 "sigs.k8s.io/karpenter/pkg/apis/v1"
coretest "sigs.k8s.io/karpenter/pkg/test"
Expand Down Expand Up @@ -104,7 +105,11 @@ var _ = Describe("Interruption", func() {

// We are expecting the node to be terminated before the termination is complete
By("waiting to receive the interruption and terminate the node")
env.EventuallyExpectNotFoundAssertion(node).WithTimeout(time.Second * 110).Should(Succeed())
Eventually(func(g Gomega) {
g.Expect(env.Client.Get(env.Context, client.ObjectKeyFromObject(node), node)).To(Succeed())
g.Expect(!node.DeletionTimestamp.IsZero()).To(BeTrue())
}).WithTimeout(time.Minute).Should(Succeed())
env.EventuallyExpectNotFound(node)
env.EventuallyExpectHealthyPodCount(selector, 1)
})
It("should terminate the node at the API server when the EC2 instance is stopped", func() {
Expand All @@ -130,7 +135,12 @@ var _ = Describe("Interruption", func() {

By("Stopping the EC2 instance without the EKS cluster's knowledge")
env.ExpectInstanceStopped(node.Name) // Make a call to the EC2 api to stop the instance
env.EventuallyExpectNotFoundAssertion(node).Should(Succeed())

Eventually(func(g Gomega) {
g.Expect(env.Client.Get(env.Context, client.ObjectKeyFromObject(node), node)).To(Succeed())
g.Expect(!node.DeletionTimestamp.IsZero()).To(BeTrue())
}).WithTimeout(time.Minute).Should(Succeed())
env.EventuallyExpectNotFound(node)
env.EventuallyExpectHealthyPodCount(selector, 1)
})
It("should terminate the node at the API server when the EC2 instance is terminated", func() {
Expand All @@ -156,7 +166,12 @@ var _ = Describe("Interruption", func() {

By("Terminating the EC2 instance without the EKS cluster's knowledge")
env.ExpectInstanceTerminated(node.Name) // Make a call to the EC2 api to stop the instance
env.EventuallyExpectNotFoundAssertion(node).Should(Succeed())

Eventually(func(g Gomega) {
g.Expect(env.Client.Get(env.Context, client.ObjectKeyFromObject(node), node)).To(Succeed())
g.Expect(!node.DeletionTimestamp.IsZero()).To(BeTrue())
}).WithTimeout(time.Minute).Should(Succeed())
env.EventuallyExpectNotFound(node)
env.EventuallyExpectHealthyPodCount(selector, 1)
})
It("should terminate the node when receiving a scheduled change health event", func() {
Expand Down Expand Up @@ -184,7 +199,12 @@ var _ = Describe("Interruption", func() {

By("Creating a scheduled change health event in the SQS message queue")
env.ExpectMessagesCreated(scheduledChangeMessage(env.Region, "000000000000", instanceID))
env.EventuallyExpectNotFoundAssertion(node).Should(Succeed())

Eventually(func(g Gomega) {
g.Expect(env.Client.Get(env.Context, client.ObjectKeyFromObject(node), node)).To(Succeed())
g.Expect(!node.DeletionTimestamp.IsZero()).To(BeTrue())
}).WithTimeout(time.Minute).Should(Succeed())
env.EventuallyExpectNotFound(node)
env.EventuallyExpectHealthyPodCount(selector, 1)
})
})
Expand Down
5 changes: 4 additions & 1 deletion test/suites/nodeclaim/nodeclaim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"os"
"time"

"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -348,7 +349,9 @@ var _ = Describe("StandaloneNodeClaim", func() {
}).Should(Succeed())

// Expect that the nodeClaim is eventually de-provisioned due to the registration timeout
env.EventuallyExpectNotFoundAssertion(nodeClaim).WithTimeout(time.Minute * 20).Should(Succeed())
Eventually(func(g Gomega) {
g.Expect(errors.IsNotFound(env.Client.Get(env.Context, client.ObjectKeyFromObject(nodeClaim), nodeClaim))).To(BeTrue())
}).WithTimeout(time.Minute * 20).Should(Succeed())
})
It("should delete a NodeClaim if it references a NodeClass that doesn't exist", func() {
nodeClaim := test.NodeClaim(karpv1.NodeClaim{
Expand Down

0 comments on commit 6975505

Please sign in to comment.