Skip to content

filtering out instances that are terminating #37

Closed
@HeyBillFinn

Description

@HeyBillFinn

Is your feature request related to a problem? Please describe.

Very similar to #16 (but in the opposite direction), how can we ensure that instances that are in the process of terminating (or very recently terminated) do not get served any requests? I'd like to solve the race condition described by the diagram below.

NGINX            Instance A              AWS
  |  health check   |                 |
  ------------------>                 |
  |                 |                 |
  |       ok        |                 |
  <------------------                 |
  |                 | scale in        |
  |                 <------------------
  |                 | *transition to  |
  |                 | "Terminating"   |
  |                 |                 |
  |  HTTP request   |                 |
  ------------------>                 |
  |                 |                 |
  |    times out    |                 |
X <------------------                 |
  |                 |                 |
  |                 |                 |
  |  health check   |                 |
  ------------------>                 |
  |                 |                 |
  |      bad        |                 |
  <------------------                 |
  | *mark A                           |
  | as unhealthy                      |
  |                                   |
  |                                   |
  | get current ASG state             |
  ------------------------------------>
  |                                   |
  |         instance A has terminated |
  <-----------------------------------|
  | *remove A from                    |
  | ASG upstream group                |

Describe the solution you'd like

I'd like GetPrivateIPsForScalingGroup to optionally filter out instances (controlled by a remove_terminating config flag) that are in a state of Terminating, Terminating:Wait, Terminating:Proceed, or Terminated per this life cycle chart:

image

Source: https://docs.aws.amazon.com/autoscaling/ec2/userguide/lifecycle-hooks.html

In the API, I believe these map to some combination of instance states of shutting-down, terminated, stopping, and stopped. Unfortunately, these life cycle states do not cleanly map to the instance states returned by describe-instances.

Describe alternatives you've considered

Custom script on our deploy instances that remove themselves from the NGINX upstream group via the NGINX API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalAn issue that proposes a feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions