When we refresh an autoscaling group, we check if it's protected against scale in.
The function "SetASGInstanceProtection" first sets the protection to scale in on the autoscalingGroup, and then for all the instances.
If the call for protect the instances fails, deathnode will never try again to set those instances as protectedToScaleIn, leaving it in an inconsistent state.
The correct order should be:
- Set all instances with protectToScaleIn
- Set autoscaling group with protectToScaleIn flag