-
Notifications
You must be signed in to change notification settings - Fork 379
feat: (BREAKING) addition of launch timeout for nodeclaim lifecycle #2349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
979741a
feat: addition of launch TTL for nodeclaim lifecycle
rschalo 77c4939
pr responses
rschalo 40558f7
update test
rschalo c861aa8
requeue for launch timeout
rschalo 1ed07dd
test expansion
rschalo ae0d3dc
clean up
rschalo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ import ( | |
|
|
||
| operatorpkg "github.com/awslabs/operatorpkg/test/expectations" | ||
| . "github.com/onsi/ginkgo/v2" | ||
| . "github.com/onsi/gomega" | ||
| corev1 "k8s.io/api/core/v1" | ||
| "k8s.io/apimachinery/pkg/api/resource" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
|
@@ -72,6 +73,8 @@ var _ = Describe("Liveness", func() { | |
| } | ||
rschalo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| nodeClaim := test.NodeClaim(nodeClaimOpts...) | ||
| ExpectApplied(ctx, env.Client, nodePool, nodeClaim) | ||
| nodeClaim.StatusConditions().SetTrue(v1.ConditionTypeLaunched) | ||
| ExpectApplied(ctx, env.Client, nodeClaim) | ||
| ExpectObjectReconciled(ctx, env.Client, nodeClaimController, nodeClaim) | ||
| nodeClaim = ExpectExists(ctx, env.Client, nodeClaim) | ||
|
|
||
|
|
@@ -91,10 +94,10 @@ var _ = Describe("Liveness", func() { | |
| ExpectExists(ctx, env.Client, nodeClaim) | ||
| } | ||
| }, | ||
| Entry("should delete the nodeClaim when the Node hasn't registered past the registration ttl", true), | ||
| Entry("should delete the nodeClaim when the Node hasn't registered past the registration timeout", true), | ||
| Entry("should ignore NodeClaims not managed by this Karpenter instance", false), | ||
| ) | ||
| It("shouldn't delete the nodeClaim when the node has registered past the registration ttl", func() { | ||
| It("shouldn't delete the nodeClaim when the node has registered past the registration timeout", func() { | ||
| nodeClaim := test.NodeClaim(v1.NodeClaim{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Labels: map[string]string{ | ||
|
|
@@ -124,7 +127,7 @@ var _ = Describe("Liveness", func() { | |
| ExpectExists(ctx, env.Client, nodeClaim) | ||
| ExpectExists(ctx, env.Client, node) | ||
| }) | ||
| It("should delete the NodeClaim when the NodeClaim hasn't launched past the registration ttl", func() { | ||
| It("should delete the NodeClaim when the NodeClaim hasn't launched past the launch timeout", func() { | ||
| nodeClaim := test.NodeClaim(v1.NodeClaim{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Labels: map[string]string{ | ||
|
|
@@ -147,18 +150,121 @@ var _ = Describe("Liveness", func() { | |
| _ = ExpectObjectReconcileFailed(ctx, env.Client, nodeClaimController, nodeClaim) | ||
| nodeClaim = ExpectExists(ctx, env.Client, nodeClaim) | ||
|
|
||
| // If the node hasn't registered in the registration timeframe, then we deprovision the nodeClaim | ||
| fakeClock.Step(time.Minute * 20) | ||
| // If the node hasn't launched in the launch timeout timeframe, then we deprovision the nodeClaim | ||
| fakeClock.Step(time.Minute * 6) | ||
| _ = ExpectObjectReconcileFailed(ctx, env.Client, nodeClaimController, nodeClaim) | ||
| operatorpkg.ExpectStatusConditions(ctx, env.Client, 1*time.Minute, nodePool, status.Condition{ | ||
| Type: v1.ConditionTypeNodeRegistrationHealthy, | ||
| Status: metav1.ConditionFalse, | ||
| Reason: nodeClaim.StatusConditions().Get(v1.ConditionTypeLaunched).Reason, | ||
| Message: nodeClaim.StatusConditions().Get(v1.ConditionTypeLaunched).Message, | ||
| }) | ||
| ExpectFinalizersRemoved(ctx, env.Client, nodeClaim) | ||
| ExpectNotFound(ctx, env.Client, nodeClaim) | ||
| }) | ||
| It("should not delete the NodeClaim when the NodeClaim hasn't launched before the launch timeout", func() { | ||
| nodeClaim := test.NodeClaim(v1.NodeClaim{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Labels: map[string]string{ | ||
| v1.NodePoolLabelKey: nodePool.Name, | ||
| }, | ||
| }, | ||
| Spec: v1.NodeClaimSpec{ | ||
| Resources: v1.ResourceRequirements{ | ||
| Requests: corev1.ResourceList{ | ||
| corev1.ResourceCPU: resource.MustParse("2"), | ||
| corev1.ResourceMemory: resource.MustParse("50Mi"), | ||
| corev1.ResourcePods: resource.MustParse("5"), | ||
| fake.ResourceGPUVendorA: resource.MustParse("1"), | ||
| }, | ||
| }, | ||
| }, | ||
| }) | ||
| cloudProvider.AllowedCreateCalls = 0 // Don't allow Create() calls to succeed | ||
| ExpectApplied(ctx, env.Client, nodePool, nodeClaim) | ||
| _ = ExpectObjectReconcileFailed(ctx, env.Client, nodeClaimController, nodeClaim) | ||
| nodeClaim = ExpectExists(ctx, env.Client, nodeClaim) | ||
|
|
||
| // try again a minute later but before the launch timeout | ||
| fakeClock.Step(time.Minute * 1) | ||
| _ = operatorpkg.ExpectObjectReconcileFailed(ctx, env.Client, nodeClaimController, nodeClaim) | ||
| // expect that the nodeclaim was not deleted | ||
| ExpectExists(ctx, env.Client, nodeClaim) | ||
| }) | ||
| It("should use the status condition transition time for launch timeout, not the creation timestamp", func() { | ||
| nodeClaim := test.NodeClaim(v1.NodeClaim{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Labels: map[string]string{ | ||
| v1.NodePoolLabelKey: nodePool.Name, | ||
| }, | ||
| }, | ||
| Spec: v1.NodeClaimSpec{ | ||
| Resources: v1.ResourceRequirements{ | ||
| Requests: corev1.ResourceList{ | ||
| corev1.ResourceCPU: resource.MustParse("2"), | ||
| corev1.ResourceMemory: resource.MustParse("50Mi"), | ||
| corev1.ResourcePods: resource.MustParse("5"), | ||
| fake.ResourceGPUVendorA: resource.MustParse("1"), | ||
| }, | ||
| }, | ||
| }, | ||
| }) | ||
| // the result cannot be tested with launch because if the launch fails the error is returned instead of requeue after | ||
| cloudProvider.AllowedCreateCalls = 0 // Don't allow Create() calls to succeed | ||
| ExpectApplied(ctx, env.Client, nodePool, nodeClaim) | ||
| _ = ExpectObjectReconcileFailed(ctx, env.Client, nodeClaimController, nodeClaim) | ||
rschalo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| nodeClaim = ExpectExists(ctx, env.Client, nodeClaim) | ||
|
|
||
| conditions := nodeClaim.Status.Conditions | ||
| newConditions := make([]status.Condition, len(conditions)) | ||
| for i, condition := range conditions { | ||
| condition.LastTransitionTime = metav1.NewTime(fakeClock.Now().Add(10 * time.Minute)) | ||
| newConditions[i] = condition | ||
| } | ||
| nodeClaim.Status.Conditions = newConditions | ||
| ExpectApplied(ctx, env.Client, nodeClaim) | ||
| // advance the clock to show that the timeout is not based on creation timestamp when considering launch timeout | ||
| fakeClock.Step(12 * time.Minute) | ||
| _ = ExpectObjectReconcileFailed(ctx, env.Client, nodeClaimController, nodeClaim) | ||
|
|
||
| // expect that the nodeclaim was not deleted after the timeout | ||
rschalo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ExpectExists(ctx, env.Client, nodeClaim) | ||
| }) | ||
|
|
||
| It("should use the status condition transition time for registration timeout, not the creation timestamp", func() { | ||
| nodeClaim := test.NodeClaim(v1.NodeClaim{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Labels: map[string]string{ | ||
| v1.NodePoolLabelKey: nodePool.Name, | ||
| }, | ||
| }, | ||
| Spec: v1.NodeClaimSpec{ | ||
| Resources: v1.ResourceRequirements{ | ||
| Requests: corev1.ResourceList{ | ||
| corev1.ResourceCPU: resource.MustParse("2"), | ||
| corev1.ResourceMemory: resource.MustParse("50Mi"), | ||
| corev1.ResourcePods: resource.MustParse("5"), | ||
| fake.ResourceGPUVendorA: resource.MustParse("1"), | ||
| }, | ||
| }, | ||
| }, | ||
| }) | ||
| ExpectApplied(ctx, env.Client, nodePool, nodeClaim) | ||
| ExpectObjectReconciled(ctx, env.Client, nodeClaimController, nodeClaim) | ||
| nodeClaim = ExpectExists(ctx, env.Client, nodeClaim) | ||
|
|
||
| conditions := nodeClaim.Status.Conditions | ||
| newConditions := make([]status.Condition, len(conditions)) | ||
| for i, condition := range conditions { | ||
| condition.LastTransitionTime = metav1.NewTime(fakeClock.Now().Add(10 * time.Minute)) | ||
| newConditions[i] = condition | ||
| } | ||
| nodeClaim.Status.Conditions = newConditions | ||
| ExpectApplied(ctx, env.Client, nodeClaim) | ||
| // advance the clock to show that the timeout is not based on creation timestamp when considering registration timeout | ||
| fakeClock.Step(16 * time.Minute) | ||
| result := ExpectObjectReconciled(ctx, env.Client, nodeClaimController, nodeClaim) | ||
| Expect(result.RequeueAfter).To(Not(Equal(0 * time.Second))) | ||
| Expect(result.RequeueAfter > 0*time.Second && result.RequeueAfter < 15*time.Minute).To(BeTrue()) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expect that the |
||
|
|
||
| // expect that the nodeclaim was not deleted after the timeout | ||
| ExpectExists(ctx, env.Client, nodeClaim) | ||
| }) | ||
|
|
||
| It("should not update NodeRegistrationHealthy status condition if it is already set to True", func() { | ||
| nodePool.StatusConditions().SetTrue(v1.ConditionTypeNodeRegistrationHealthy) | ||
| nodeClaim := test.NodeClaim(v1.NodeClaim{ | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.