-
Notifications
You must be signed in to change notification settings - Fork 0
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
fix: prevent creating duplicate machine ids #116
Conversation
We saw the same machine id created more than one time. This caused an issue where the cli would not be able to connect to the correct machine. We now wait for the instance to be created. We don't care about what state the instance is in only that it has been handled by AWS. We believe duplication would happen when the scheduleTask would finish quickly, receive the next update from the API, but without AWS reporting the machine as pending. Co-authored-by: Billy Batista <[email protected]> Signed-off-by: Chris Goller <[email protected]>
Fixes DEP-1943 |
src/utils/aws.ts
Outdated
|
||
// We are waiting for the instance to exist because we are blocking scheduleTask | ||
// from starting another task with the same machine ID until this one completes. | ||
while (!instanceCreated) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs a sleep otherwise this is a tight loop of API requests
Possibly better and API aware, the AWS SDK should have a wait for method I believe, similar to the Go SDK https://aws.amazon.com/blogs/developer/waiters-in-modular-aws-sdk-for-javascript/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the one, something like https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ec2/Variable/waitForInstanceExists/:
const maxWaitTime = 30 // seconds
await waitForInstanceExists({client, maxWaitTime}, {InstanceIds: [instanceID]})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in ffc5a68
Signed-off-by: Chris Goller <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
We saw the same machine id created more than one time. This caused an issue where the cli would not be able to connect to the correct machine.
We now wait for the instance to be created.
We don't care about what state the instance is in
only that it has been handled by AWS.
We believe duplication would happen when the scheduleTask would finish quickly, receive the next update from the API, but without AWS reporting the machine as pending.
Note: another way we could fix this is to use the cache of changes as we did with volumes.