Slow execution of AWS CLI Script process step

Hi,

Here is the log from a deploy with the custom Calamari.Aws.dll.deploy_log.txt (4.9 KB)

Hi Karl, thanks for that log file.

From those additional log messages, the delay must be introduced in Powershell somewhere.

The delay happens after START: NextWrapper.ExecuteScript(), which means we can rule out any of the calls made by the AWS SDK to log in and prepare the environment.

Given that the delay happens after the output of AvailablePhysicalMemory, it must be occurring some time after the call to Log-EnvironmentInformation in the bootstrap script at https://github.com/OctopusDeploy/Calamari/blob/master/source/Calamari.Shared/Integration/Scripting/WindowsPowerShell/Bootstrap.ps1#L687.

It is possible that the delay is introduced when the AWS Powershell modules are imported with the call to Import-CalamariModules at https://github.com/OctopusDeploy/Calamari/blob/master/source/Calamari.Shared/Integration/Scripting/WindowsPowerShell/Bootstrap.ps1#L692.

Unless you have enabled the debugger, the line {{BeforeLaunchingUserScriptDebugLocation}} at https://github.com/OctopusDeploy/Calamari/blob/master/source/Calamari.Shared/Integration/Scripting/WindowsPowerShell/Bootstrap.ps1#L697 will be replaced with an empty string and have no effect.

The final step is to import the script that is being run at https://github.com/OctopusDeploy/Calamari/blob/master/source/Calamari.Shared/Integration/Scripting/WindowsPowerShell/Bootstrap.ps1#L698.

To answer your original question, Octopus itself doesn’t need to make any external HTTP calls in order to run a script. Preparing the AWS environment does make calls to the metadata API at http://169.254.169.254/latest/meta-data/iam/security-credentials/, but we can rule that out as the source of the delay with the log file you provided.

Importing the AWS Powershell modules can be disabled by setting the OctopusUseBundledAwsPowerShellModules Octopus variable to false. Does disabling these modules remove the delay?

Regards

Matt C

Hi,

Setting the Octopus variable OctopusUseBundledAwsPowerShellModules to false does indeed remove the delay - nice find!

Hi Karl, that is good news. If you don’t make use of the AWS Powershell module, then disabling the import would be a reasonable fix. The cross-platform aws command is still available should you need it.

Regards
Matt C

Hi,

Yes, I agree that is a reasonable fix. Thanks for all the support.

Regards
Karl

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.