0

I am running managed instance group in google cloud. These are behind a loadbalancer and it is working fine. The problem is when the managed instance group scales down, the loadbalancer will not notice this until after the instance has been killed so some requests will be sent to an instance that is dead causing the application to not work properly for a while.

On this page https://cloud.google.com/compute/docs/autoscaler/understanding-autoscaler-decisions I have read that shutdown scripts can be used. I tried to add one that tells the instance it will be shut down so it starts sending unhealthy when the load balancer does a health check, the script then waits for a while to make sure to give the load balancer time to check it. It does however not seem to work. The script seems to be called but to late so it just shuts down.

Anyone know how to write a shutdown script for this scenario?

  • You did the things correctly. Are you sure the script has been ran? Are you sure the script make the instance unhealthy? What is your HealthCheck frequency? – guillaume blaquiere Feb 06 '23 at 08:30
  • 1
    Problem was not the shutdown script but that the healthcheck timed out causing all instances to become unhealthy. – Markus Hervén Feb 07 '23 at 09:09

1 Answers1

0

Seems like this was not the problem after all. After inspecting the logs it turned out that the health checks timed out causing the load balancer to ot find any nodes with a healthy state.