1

We are using eb_deployer which under the hood uses ElasticBeanstalk Ruby Aws Sdk. The Aws::ElasticBeanstalk::Client#update_environment method is used in particular to trigger a deployment. I'm trying to make use of RollingWithAdditionalBatch deployment policy however this settings seems to be ignored when the environment update is initiated via mentioned sdk method.

Inside of option_settings parameter of update_environment we have:

{
    "namespace"=>"aws:elasticbeanstalk:command",
    "option_name"=>"DeploymentPolicy",
    "value"=>"RollingWithAdditionalBatch"
},

However despite the above the deployment is using Rolling strategy as far as I can tell:

2017-01-11 15:59:42 UTC+0100    INFO    Environment update completed successfully.
2017-01-11 15:59:42 UTC+0100    INFO    Successfully deployed new configuration to environment.
2017-01-11 15:59:42 UTC+0100    INFO    New application version was deployed to running EC2 instances.
2017-01-11 15:58:32 UTC+0100    INFO    Deploying new version to instance(s).
2017-01-11 15:57:57 UTC+0100    INFO    Updating environment ENV_ID configuration settings.

You can find the details of the method call in the update-environment-call.txt.

After some more tests it turned out that the issue might not necessarily be related to aws-sdk-ruby. The following invocation:

client.update_environment(
         environment_id:"ENV_ID",
         version_label:"backend.1762",
         option_settings:[{
            "namespace"=>"aws:elasticbeanstalk:command",
            "option_name"=>"DeploymentPolicy",
            "value"=>"RollingWithAdditionalBatch"
         },{
            "namespace"=>"aws:ec2:vpc",
            "option_name"=>"VPCId",
            "value"=>"VPC_ID_ABC"
         }]
)

Triggers Rolling deployment.

However if we remove the VPC setting then Rolling with additional batch is invoked as requested:

client.update_environment(
         environment_id:"ENV_ID",
         version_label:"backend.1762",
         option_settings:[{
            "namespace"=>"aws:elasticbeanstalk:command",
            "option_name"=>"DeploymentPolicy",
            "value"=>"RollingWithAdditionalBatch"
         }]
)  

Between subsequent calls to update_environment the only parameter that has different value is version_label.

Steps to reproduce the problem:

Step 1. We call update_environment with version_label: 1 and certain option_settings. The option_settings include RollingWithAdditionalBatch but also have other settings i.e. VPCId. The environment is updated properly and the RollingWithAdditionalBatch shows up as a configured value in AWS Web Console.

Step 2,3,4,5,... We call update_environment with version_label: n and the same option_settings as in Step 1. The new version of application is deployed using Rolling strategy which in my view is unexpected.

However if we perform Step 2,3,5 and in option_settings provide only a single option for RollingWithAdditionalBatch then the new version is deployed correctly using RollingWithAdditionalBatch.

Did somebody encounter this behaviour and knows how to work around it?

Related Github Issue

Related AWS Forum Post

miensol
  • 39,733
  • 7
  • 116
  • 112

1 Answers1

1

As noted by AWS Support

Here are some important excerpts from our conversation with aws support so that people having the same problem as we do can find it (emphasis mine):

As (...) mentioned, this behaviour occurred because the changes you made resulted in a configuration update being triggered. The deployment strategy used by a configuration change is different to that used by an application deployment. Certain modifications will trigger a configuration update, and some of these changes will require that your environment's instances be replaced (though some will not). Importantly, a configuration update can be triggered even if the configuration option has not been changed since the last update_environment call.

So it turns out that the behavior, while poorly documented if at all is how the elastic beanstalk is supposed to work.

In order to overcome it's best to supply empty option_settings to be sure that the update_environment triggers Application Deployment like so:

client.update_environment(
         environment_id:"ENV_ID",
         version_label:"new_version_of_app",
         option_settings:[]
)  
miensol
  • 39,733
  • 7
  • 116
  • 112
  • This sounds exactly like our situation. We recently changed our EB Deploy pipeline to set environment variables using `option_settings` and ever since then we noticed the deploys changed to `rolling` from `rolling with additional batch`. Thanks for sharing this. – Steve G Jun 19 '23 at 14:59