Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

waitFor should have an initial timeout option #19

Closed
antonsamper opened this issue May 9, 2017 · 4 comments
Closed

waitFor should have an initial timeout option #19

antonsamper opened this issue May 9, 2017 · 4 comments
Assignees
Labels
closed-for-staleness This issue was closed because it didn't receive updates feature-request New feature or request rds

Comments

@antonsamper
Copy link

I've been playing around with RDS instances and modifying them but i have noticed an issue that may affect others. What I'm trying to do is upgrade one of my RDS instances and once the upgrade is complete, then continue with the rest of the code:

return RDS.modifyDBInstance({
    DBInstanceIdentifier: instanceId,
    DBInstanceClass: instanceClass,
    ApplyImmediately: true
}).promise().then(() => {
    return RDS.waitFor('dBInstanceAvailable', {
        DBInstanceIdentifier: instanceId
    }).promise();
});

The problem that I'm having with the above is that the RDS.waitFor promise is resolved straight away because the ApplyImmediately settings seem to take a few seconds to actually start. As a result, to make the code work as expected, I'm having to manually delay the call to waitFor (with bluebirds .delay)

return RDS.modifyDBInstance({
    DBInstanceIdentifier: instanceId,
    DBInstanceClass: instanceClass,
    ApplyImmediately: true
}).promise().then(() => {
    return Promise.delay(5000).then(() => {
        return RDS.waitFor('dBInstanceAvailable', {
            DBInstanceIdentifier: instanceId
        }).promise();
    });
});

Currently, the waitFor function seems to run straight away and then every 30 seconds. Could we have an option to wait 30 seconds before the first check?

@jeskew
Copy link

jeskew commented May 10, 2017

Hi @antonsamper,

I can definitely see how the delay between when the modifyDBInstance promise is resolved and when the instances begin reporting their status as modifying can be frustrating, but I don't think adding an initial delay to waiters will solve it in all cases. If RDS requires a few retries to contact the node or there's some transient networking issue that keeps the modify command from reaching the affected instance, then the instance might still report as available even after 5 or 30 seconds.

A more reliable solution would be to add a DBInstanceModifying waiter that uses the same delay and maxAttempts count as DBInstanceAvailable but that uses modifying as its target instance status instead of available. You could then wait for the modifications to take effect by chaining the waiters together:

return RDS.modifyDBInstance({
    DBInstanceIdentifier: instanceId,
    DBInstanceClass: instanceClass,
    ApplyImmediately: true
}).promise().then(() => {
    return RDS.waitFor('dBInstanceModifying', {
        DBInstanceIdentifier: instanceId
    }).promise();
}).then(() => {
    return RDS.waitFor('dBInstanceAvailable', {
        DBInstanceIdentifier: instanceId
    }).promise();
}).then(() => {
    // the modifications have been applied
});

Would that be a reasonable remedy?

@antonsamper
Copy link
Author

Hi @jeskew,

That would be great! In hindsight adding a new dBInstanceModifying state would be cleaner and more robust as relying on arbitrary timings is not good practice.

@antonsamper
Copy link
Author

hi @jeskew, do you know when this new waiter might be added?

@ajredniwja ajredniwja transferred this issue from aws/aws-sdk-js Nov 6, 2020
@ajredniwja ajredniwja added feature-request New feature or request service-api This issue pertains to the AWS API labels Nov 6, 2020
@stobrien89 stobrien89 added rds and removed service-api This issue pertains to the AWS API labels Jul 26, 2021
@github-actions
Copy link

This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will be closed soon label Aug 11, 2022
@github-actions github-actions bot added closed-for-staleness This issue was closed because it didn't receive updates and removed closing-soon This issue will be closed soon labels Aug 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
closed-for-staleness This issue was closed because it didn't receive updates feature-request New feature or request rds
Projects
None yet
Development

No branches or pull requests

5 participants