-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
ASG Warmpool instances join before Lifecycle hook is in effect #16582
Comments
Fixes: kubernetes#16582 When creating a new ASG with a Warmpool using Lifecycle hooks, the instances that first join the Warmpool when the ASG is created could come up before the Lifecycle hook is in effect. This can lead to problems such as those instances not calling the Lifecycle hook notification when pressed into service, causing the ASG to terminate them approximately 10 mins after they've been performing work in the cluster. Setting a dependency on for the Warmpool to take into account any Lifecycle hooks means that the Warmpool won't be created until the hooks are ready. Signed-off-by: Jim Barber <jim.barber@healthengine.com.au>
I created a pull request to address the above: #16583 |
We had the ASG terminate an instance today that didn't get the Lifecycle hook notification even though there were no issues with the instance when it joined the Warmpool.
And that step does the change to set |
Based on your PR, I think you've figured this out, but ....
The builders are run in order, but they set up a list of Tasks which run in parallel. The Tasks don't run fully parallelized, rather they run in "waves", the first wave has all the tasks that have no dependencies, then when all of those complete we move onto the next wave, which comprises the tasks that are newly unblocked. Dependencies are either because we see that an object has a reference to a Task (and there's some "resolving" that happens based on the Task ID so we don't need to pass around Tasks everywhere), or because there are explicit Dependencies. (We could change it to run each task as soon as possible, "waves" are just how it works today. I don't think it will make a huge difference in execution time, and it might be a little less deterministic i.e. more bugs, so that's why we haven't prioritized it) At least that's my recollection :-) |
Looking at how the lifecycle hook should be called from nodeup: kops/upup/pkg/fi/nodeup/command.go Lines 375 to 382 in 0e70556
That is actually called after all the nodeup tasks. So if the node isn't delivering that hook, then I don't think it's about task execution. A few things to check:
Based on the CloudTrail events, I'm assuming that the One thing though, you mention model.HookBuilder - IIUC that is for custom hooks, not for the built-in warmpool hook I've linked above. Are you using a custom hook for the lifecycle action? On the ENI task, I did a quick spot check and the the error handling / retry logic looked correct, so I'd be surprised if that was interfering with the CompleteLifecycleAction call. But ... something is plainly going wrong. |
Hi @justinsb This issue has been overloaded a little bit in that it is covering two issues and perhaps you're mixing the two given your responses above? The first (and the main thing this issue was about), was the instances in the ASG starting before the ASG Lifecycle Hook was in place. The Pull Request I raised fixes the problem above for the instances that join the Warmpool only. They longer encounter the The above problem has nothing to do with the For kOps 1.28.4 and earlier (where we were using Ubuntu 20.04) we have never seen the above issue before. The 2nd issue is what I posted about on May 31, and this is the one where I was wondering if the In this case these instances joined the Warmpool a long time after the ASG and its Lifecycle hook was established and had no errors at all. But later when they leave the Warmpool to go into service, there are no logs in CloudTrail showing them attempting to perform the Lifecycle hook notification (successfully or not); and after 10 mins the ASG kills them for having not completed the Lifecycle notification, causing an outage. Note that what I failed to mention at the time I wrote about this 2nd problem on May 31 was that it was encountered on a Kubernetes 1.29.5 cluster that was created with kOps 1.29.0. Still talking about the 2nd issue but addressing your questions...
No that was me making a bad assumption that it might have had something to do with the creation of the lifecycle hooks.
Unfortunately with this problem any node specific configuration and the logs produced by nodeup or caught by the systemd journal are lost, since we are not actually aware there is a problem with the instance until the ASG has already terminated it. We've since stopped deploying our own node-termination-handler that was running as a Daemon Set in IMDS mode to catch spot interruptions into having kOps deploy it in queue-processor mode so that it also handles when the ASG terminates the instances that fail lifecycle hooks.
It should be getting the same configuration as all the other instances on the same ASG that didn't encounter the issue.
Due to the ASG terminating the instances, I have no way of knowing as far as I can tell? With my theory of the |
Hi @justinsb |
Fixes: kubernetes#16582 When creating a new ASG with a Warmpool using Lifecycle hooks, the instances that first join the Warmpool when the ASG is created could come up before the Lifecycle hook is in effect. This can lead to problems such as those instances not calling the Lifecycle hook notification when pressed into service, causing the ASG to terminate them approximately 10 mins after they've been performing work in the cluster. Setting a dependency on for the Warmpool to take into account any Lifecycle hooks means that the Warmpool won't be created until the hooks are ready. Signed-off-by: Jim Barber <jim.barber@healthengine.com.au>
Fixes: kubernetes#16582 When creating a new ASG with a Warmpool using Lifecycle hooks, the instances that first join the Warmpool when the ASG is created could come up before the Lifecycle hook is in effect. This can lead to problems such as those instances not calling the Lifecycle hook notification when pressed into service, causing the ASG to terminate them approximately 10 mins after they've been performing work in the cluster. Setting a dependency on for the Warmpool to take into account any Lifecycle hooks means that the Warmpool won't be created until the hooks are ready. Signed-off-by: Jim Barber <jim.barber@healthengine.com.au>
Hopefully this will do it: /reopen Just to confirm, you are using the AWS VPC CNI? The systemd-networkd change does look like a likely possibly-related change, but it should only be in play if you're using AWS VPC CNI |
@justinsb: Reopened this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Yes. We are using the AWS VPC CNI. |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
Hi @justinsb I'm guessing you either didn't get time to look at this issue any more; or you did look but couldn't find the cause of the issue? |
/kind bug
1. What
kops
version are you running? The commandkops version
, will displaythis information.
2. What Kubernetes version are you running?
kubectl version
will print theversion if a cluster is running or provide the Kubernetes version specified as
a
kops
flag.3. What cloud provider are you using?
4. What commands did you run? What is the simplest way to reproduce this issue?
Create a number of new instance groups, some of which have the
spec.warmPool
defined withspec.warmPool.enableLifecycleHook: true
set.In my case I was creating 9 instance groups of which 3 of them had Warmpools enabled.
All instances were created by passing their manifests to
kops create -f
, then once that is done for all of them akops update cluster --admin --yes
command is run to put them into effect.5. What happened after the commands executed?
All the instance groups were created fine and it appeared to be without issue...
But about an hour later when some of the instances that were in the warmpool were pressed into service, they joined the cluster as expected and started serving web traffic for our application until the ASG terminated them after they had been in service for 10 minutes.
Investigation via the AWS CloudTrail logs showed these EC2 instances had tried to run the
CompleteLifecycleAction
event a number of times when they joined the Warmpool all producing aValidationException
error with the messageNo active Lifecycle Action found with instance ID i-xxxxxxxxxxxxxxxxx
.So they have come up before the Lifecycle hook was in place.
Then later when put into service, the Lifecycle hook is now in place on the ASG, but these instances do not try to notify it, so the ASG assumes they are unhealthy after 10 minutes and terminates them.
In our case it killed our webservers causing a complete outage of our application for a while.
6. What did you expect to happen?
Instances that have joined the Warmpool should be properly executing the ASG Lifecycle hook notification when pressed into service so that the ASG won't terminate them after 10 minutes.
7. Please provide your cluster manifest. Execute
kops get --name my.example.com -o yaml
to display your cluster manifest.You may want to remove your cluster name and other sensitive information.
8. Please run the commands with most verbose logging by adding the
-v 10
flag.Paste the logs into this report, or in a gist and provide the gist link here.
9. Anything else do we need to know?
I am unable to reproduce this problem if I just create one new instance group at a time.
In that case the Lifecycle hook manages to be in effect before new instances need it.
But I am able to reliably reproduce it when I create a number of instance groups at once (9 of them since I just reproduced the problem we had in production).
I guess you need a lot of them to cause some AWS API server throttling or something?
I have a Slack topic detailing the issue: https://kubernetes.slack.com/archives/C3QUFP0QM/p1715733980241579
The problem would be fixed if the ASG didn't add instances to it until all lifecycle hooks are created.
The text was updated successfully, but these errors were encountered: