beanstalk-deploy icon indicating copy to clipboard operation
beanstalk-deploy copied to clipboard

Feature request: Make an initial wait for environment status before deploy

Open ffMathy opened this issue 4 years ago • 6 comments

Sometimes when we deploy, the environment isn't ready yet, because a previous deploy is also running.

It would be awesome with something similar to wait_for_deployment, but where it waits before deploying too.

ffMathy avatar Sep 30 '21 08:09 ffMathy

Hmmm. Might be a good idea. I'd probably have it as a number instead, like wait_for_deployment_max_seconds and give it a default of 20 or so. That way you could say that you wanted to wait for a max of maybe 2-3 minutes, since this waiting is eating up your github minutes.

einaregilsson avatar Sep 30 '21 10:09 einaregilsson

I strongly +1 this request. Since we already have wait_for_deployment and wait_for_environment_recovery, this is a natural third step.

Our use case is when we merge multiple PRs to main at the same time and deploy to Elastic Beanstalk, the second PR will throw an "Environment is not ready" error because the first PR has recently deployed or is currently deploying. We don't mind waiting for a few minutes and then triggering the deployment.

AnandChowdhary avatar Nov 07 '21 10:11 AnandChowdhary

@AnandChowdhary Yeah I'll definitely try to get this one into the next release. I'm not sure when that will be though, pretty busy at the moment.

einaregilsson avatar Nov 08 '21 11:11 einaregilsson

@einaregilsson any hints on where we could add this contribution ourselves, in case you don't end up getting any time for it?

ffMathy avatar Nov 11 '21 07:11 ffMathy

@ffMathy Look at the function waitForDeployment. That does essentially the same thing, although that also logs out events that are happening with the environment so it's a bit more complicated. There's also a lot of stuff in there to deal with potential throttling of events. But basically make a new function called waitForEnvironmentReady that does the same thing as waitForDeployment, except no need to call describeEvents all the time. Resolve the promise if the environment is in the ready state, exit the action with exit code 1 if we get past the given max_wait_for_environment_ready value.

Then add that function into both deployNewVersion and deployExistingVersion at the correct time in the flow. I would say you'd probably want to do it after you've created the version in S3 and done all those basic steps, right before you start the actual deployment. You'd want the action to fail immediately if there's some problem with creating the version, not wait for maybe 30 seconds and then give you an S3 upload error or something.

einaregilsson avatar Nov 11 '21 08:11 einaregilsson

Perfect @einaregilsson. I don't have much time either, but now the OS community knows how to do this, in case you don't have time as well. Perfect, thanks.

ffMathy avatar Nov 11 '21 08:11 ffMathy