in github-runner-ami/packer/files/runner-supervisor.py [0:0]
def protect_from_scale_in(self, protect: bool = True):
""" Set (or unset) ProtectedFromScaleIn on our instance"""
if not OWN_ASG:
# Not part of an ASG
return
if self.in_termating_lifecycle:
log.info("Not trying to SetInstanceProtection, we are already in the terminating lifecycle step")
return
asg_client = boto3.client('autoscaling')
try:
self._protect_from_scale_in(asg_client, protect)
self.protected = protect
except asg_client.exceptions.ClientError as e:
# This can happen if this the runner picks up a job "too quick", and the ASG still has the state
# as Pending:Proceed, so we can't yet set it as protected
log.warning("Failed to set scale in protection: %s", str(e))