Skip to content
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

check instance lifecycle before starting the work #75

Merged
merged 4 commits into from
Apr 4, 2024

Conversation

marjisound
Copy link
Contributor

@marjisound marjisound commented Apr 3, 2024

paired with @zekehuntergreen

What does this change?

We found several instances that had been launched several days previously without being scaled in. This delayed subsequent transcription jobs because the ASG capacity manager wouldn't update desired capacity.
The related logs for these instances were showing that the service had gone into failed state because of exception when trying to update scaling protection.

AutoScalingServiceException [ValidationError]: The instance <instanse-id> is not in InService or EnteringStandby or Standby.

Looking at AWS documentation, the instance can only go into Standby & EnteringStandby states through user interaction. So most probably, the state of the instance in our case was Pending.

In this change

  • the worker, retrieves the instance LifeCycle state and if it is not InService, it won't continue the work, but rather waits for 30 seconds.
    • Doing this check avoids the unhandled exception (AutoScalingServiceException) when trying to update the instance scaling protection.
  • We remove scale-in protection from the launch config so that new instances must update their own scale in protection when they are created. This should prevent workers existing forever if this initial update fails.

How to test

  • tested in CODE

Co-authored-by: Zeke Hunter-Green <zeke.huntergreen@guardian.co.uk>
Co-authored-by: Zeke Hunter-Green <zeke.huntergreen@guardian.co.uk>
@marjisound marjisound marked this pull request as ready for review April 3, 2024 16:50
@marjisound marjisound requested a review from a team April 3, 2024 16:50
(i) => i.InstanceId === instanceId,
)?.LifecycleState;
if (lifecycleState === undefined)
throw new Error('Could not find instance lifecycle state!');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed - this felt wrong

Copy link
Contributor

@philmcmahon philmcmahon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

@zekehuntergreen zekehuntergreen merged commit 75d406a into main Apr 4, 2024
1 check passed
@zekehuntergreen zekehuntergreen deleted the check-instance-lifecycle-state branch April 4, 2024 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants