Skip to content
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

Added Per-pod eviction backoff and retry logic #515

Merged
merged 5 commits into from
Jul 22, 2021
Merged

Added Per-pod eviction backoff and retry logic #515

merged 5 commits into from
Jul 22, 2021

Conversation

njtran
Copy link
Contributor

@njtran njtran commented Jul 16, 2021

Issue, if available:
#452

Description of changes:

  • Pod evictions now have separate backoffs per pod
  • Drain in termination controller queues up pods to a continually running queue processor as a goroutine in the background
  • Accounts for different pod eviction errors

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@njtran njtran changed the title Eviction Added Per-pod eviction backoff and retry logic Jul 16, 2021
Copy link
Contributor

@ellistarn ellistarn left a comment

Choose a reason for hiding this comment

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

Nice! Overall looks good. I'll take a deeper look tomorrow. We need some robust tests though.

pkg/controllers/termination/controller.go Outdated Show resolved Hide resolved
pkg/controllers/termination/controller.go Outdated Show resolved Hide resolved
pkg/controllers/termination/eviction.go Show resolved Hide resolved
pkg/controllers/termination/eviction.go Show resolved Hide resolved
pkg/controllers/termination/suite_test.go Outdated Show resolved Hide resolved
}

// Evict adds a pod to the EvictionQueue
func (e *EvictionQueue) Add(pods []*v1.Pod) {
Copy link
Contributor

@ellistarn ellistarn Jul 19, 2021

Choose a reason for hiding this comment

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

A variadic might be a bit cleaner here, since you could imagine evicting a single pod. 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since the only code that is adding a pod is our code, I thought it would make more sense just to put an array here, since that's how we form the list of pods anyways. I have no strong feelings either way though.

"sigs.k8s.io/controller-runtime/pkg/client"
)

const (
evictionQueueMaxDelay = 10 * time.Second
Copy link
Contributor

Choose a reason for hiding this comment

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

Thoughts on pushing this to 60 seconds? I'm a bit wary of too much eviction QPS. 1,000 pods at 10 seconds is 100qps.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm a little wary of pushing it to 60 seconds. Imagine I have 5 pods, with a PDB that allows me to evict one at a time. If we assume that our nodes take 50 seconds to be fully provisioned, we have enough time for the eviction delay to get to reach a minute for any one of these pods. At the worst, we could wait a whole minute after the PDB would allow an eviction to evict another pod. Let's say these are all on the same node, this node would then take much much longer to terminate and drain.

I realize this is a very specific case, but since our allocation logic tends to group pods that are created together (since scaling up deployments is the most basic happenstance of pending pods), our logic may end up running into something like this more than not.

I think we could fine tune these numbers when we get to performance and scale testing. What do you think?

@@ -137,3 +145,37 @@ func ExpectReconcileSucceeded(reconciler reconcile.Reconciler, key client.Object
_, err := reconciler.Reconcile(context.Background(), reconcile.Request{NamespacedName: key})
Expect(err).ToNot(HaveOccurred())
}

func ExpectPodsEvictingSucceeded(c client.Client, pods ...*v1.Pod) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thoughts on calling this
ExpectEvicted(c client.Client, pods ...*v1.Pod)
and then actually doing the deletion after we verify the deletion timestamp is set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would rather have this check just check it, then separately delete the pod, just in case there is a time where we don't immediately want to delete it, and check some other things first.

pkg/controllers/termination/controller.go Outdated Show resolved Hide resolved
pkg/controllers/termination/controller.go Outdated Show resolved Hide resolved
queue workqueue.RateLimitingInterface
coreV1Client corev1.CoreV1Interface

enqueued set.Set
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add this functionality to the newly added utils/parallel/workqueue.go? That implementation is slightly different, but there is a lot of shared functionality. This could definitely be done later though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ellis and I talked about this, and we think there is a possibility to merge them here. We decided to punt on this merging effort later in favor of getting this feature in.

pkg/test/pods.go Outdated Show resolved Hide resolved
pkg/test/pods.go Outdated Show resolved Hide resolved
@njtran njtran merged commit c0fd259 into aws:main Jul 22, 2021
@njtran njtran deleted the eviction branch September 8, 2021 19:21
gfcroft pushed a commit to gfcroft/karpenter-provider-aws that referenced this pull request Nov 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants