Powershell script on tentacle hangs

So I’ve tried running a script and while it executes fine on when I run it myself and via the test method (http://octopusdeploy.com/blog/testing-powershell-scripts). It just hangs as seem in the picture, never timing out or finishing. Log output doesn’t appear to point to anything conclusive

2014-01-14 11:45:00.5533 TRACE Stored Octopus.Platform.Deployment.Messages.Deploy.Script.TentacleRunScriptCommand from ScriptActionOrchestrator-KlI-iR1Q6Nal@SQ-MY-HOSTNAME-04A4C628 to Dispatcher@SQ-MY-HOSTNAME-A10276BE (id: e4eba83ade324f86bf3912398334b643 env: 08D0DF783F03D06E00000293) 2014-01-14 11:45:00.6003 TRACE Attaching TentacleScriptRun as TentacleScriptRun-2w-iR1Q_+KT 2014-01-14 11:45:00.6003 TRACE Stored Octopus.Platform.Deployment.Messages.Deploy.Script.TentacleRunScriptCommand from ScriptActionOrchestrator-KlI-iR1Q6Nal@SQ-MY-HOSTNAME-04A4C628 to TentacleScriptRun-2w-iR1Q_+KT@SQ-MY-HOSTNAME-A10276BE (id: e4eba83ade324f86bf3912398334b643 env: 08D0DF783F0B49AC00000294) 2014-01-14 11:45:00.6003 TRACE Starting supervised actor TentacleScriptRun-2w-iR1Q_+KT@SQ-MY-HOSTNAME-A10276BE 2014-01-14 11:45:00.6003 TRACE Stored Pipefish.Messages.Supervision.StartedEvent from TentacleScriptRun-2w-iR1Q_+KT@SQ-MY-HOSTNAME-A10276BE to ScriptActionOrchestrator-KlI-iR1Q6Nal@SQ-MY-HOSTNAME-04A4C628 (id: 7ef19e8a5bca47fb89adf1d51d2199ef env: 08D0DF783F0CA98E00000295) 2014-01-14 11:45:00.6003 TRACE Stored Pipefish.Messages.Timing.SetTimeoutCommand from TentacleScriptRun-2w-iR1Q_+KT@SQ-MY-HOSTNAME-A10276BE to Clock@SQ-MY-HOSTNAME-A10276BE (id: a46807ea73834e6f92f4b2ac94561a7a env: 08D0DF783F0D6D0B00000296) 2014-01-14 11:45:00.6194 TRACE Accepted TCP client 10.16.0.16:9176 2014-01-14 11:45:00.6194 TRACE Routing Post request for /mx/v1... 2014-01-14 11:45:00.6194 TRACE Found handler. 2014-01-14 11:45:00.6634 TRACE Stored Octopus.Tentacle.Orchestration.Deploy.Mutex.AcquireCommand from TentacleScriptRun-2w-iR1Q_+KT@SQ-MY-HOSTNAME-A10276BE to Octopus.DeploymentMutex@SQ-MY-HOSTNAME-A10276BE (id: 0b13672a3b9c41239941d4eeac031f1d env: 08D0DF783F14C1BB00000297) 2014-01-14 11:45:00.6634 TRACE Received a request from TentacleScriptRun-2w-iR1Q_+KT@SQ-MY-HOSTNAME-A10276BE to acquire the deployment mutex 2014-01-14 11:45:00.6634 TRACE New deployment mutex acquisition eaba5849-aec3-4535-afef-6a781772d17c for TentacleScriptRun-2w-iR1Q_+KT@SQ-MY-HOSTNAME-A10276BE 2014-01-14 11:45:00.6634 TRACE Stored Octopus.Tentacle.Orchestration.Deploy.Mutex.AcquiredEvent from Octopus.DeploymentMutex@SQ-MY-HOSTNAME-A10276BE to TentacleScriptRun-2w-iR1Q_+KT@SQ-MY-HOSTNAME-A10276BE (id: c29645a8a42e45dbab090ab9a6702fe0 env: 08D0DF783F16E52200000298) 2014-01-14 11:45:00.7285 TRACE Accepted TCP client 10.16.0.16:9177 2014-01-14 11:45:00.7285 TRACE Routing Post request for /mx/v1... 2014-01-14 11:45:00.7285 TRACE Found handler. 2014-01-14 11:45:00.9097 DEBUG Invoking the script runner... 2014-01-14 11:45:00.9097 TRACE Stored Octopus.Platform.Deployment.Logging.LogMessageEvent from TentacleScriptRun-2w-iR1Q_+KT@SQ-MY-HOSTNAME-A10276BE to Octopus.Logger@SQ-MY-HOSTNAME-04A4C628 (id: 98c5522785b144d3a36c3ab769ea1313 env: 08D0DF783F3A565900000299) 2014-01-14 11:45:01.8064 TRACE Accepted TCP client 10.16.0.16:9181 2014-01-14 11:45:01.8064 TRACE Routing Post request for /mx/v1... 2014-01-14 11:45:01.8064 TRACE Found handler. 2014-01-14 11:45:02.0317 TRACE Accepted TCP client 10.16.0.16:9182 2014-01-14 11:45:02.0317 TRACE Routing Post request for /mx/v1... 2014-01-14 11:45:02.0317 TRACE Found handler. 2014-01-14 11:45:03.0285 INFO # TC API 2014-01-14 11:45:03.0285 TRACE Stored Octopus.Platform.Deployment.Logging.LogMessageEvent from TentacleScriptRun-2w-iR1Q_+KT@SQ-MY-HOSTNAME-A10276BE to Octopus.Logger@SQ-MY-HOSTNAME-04A4C628 (id: 4234f2c496c14fea89fc625f800193c3 env: 08D0DF78407DCD500000029A) 2014-01-14 11:45:03.0285 INFO $teamcity = New-Module -ScriptBlock { 2014-01-14 11:45:03.0285 TRACE Stored Octopus.Platform.Deployment.Logging.LogMessageEvent from TentacleScriptRun-2w-iR1Q_+KT@SQ-MY-HOSTNAME-A10276BE to Octopus.Logger@SQ-MY-HOSTNAME-04A4C628 (id: cb183d55b154475aa829b4d74d07a3be env: 08D0DF78407E1B820000029B) 2014-01-14 11:45:03.0285 INFO $tc_url = "http://our_teamcity_url:81/httpAuth/app/rest" 2014-01-14 11:45:03.0285 TRACE Stored Octopus.Platform.Deployment.Logging.LogMessageEvent from TentacleScriptRun-2w-iR1Q_+KT@SQ-MY-HOSTNAME-A10276BE to Octopus.Logger@SQ-MY-HOSTNAME-04A4C628 (id: 394b3527ff044f638e967fe4284e47af env: 08D0DF78407E90CD0000029C) 2014-01-14 11:45:03.0285 INFO $tc_username = "octopus" 2014-01-14 11:45:03.0285 TRACE Stored Octopus.Platform.Deployment.Logging.LogMessageEvent from TentacleScriptRun-2w-iR1Q_+KT@SQ-MY-HOSTNAME-A10276BE to Octopus.Logger@SQ-MY-HOSTNAME-04A4C628 (id: 0b586a7c3e7248a2a26b83080a3797f0 env: 08D0DF78407EE1120000029D) 2014-01-14 11:45:03.0385 INFO $tc_password = "some_password" 2014-01-14 11:45:03.0385 TRACE Stored Octopus.Platform.Deployment.Logging.LogMessageEvent from TentacleScriptRun-2w-iR1Q_+KT@SQ-MY-HOSTNAME-A10276BE to Octopus.Logger@SQ-MY-HOSTNAME-04A4C628 (id: cb582193ed55486991e7c0ba87ceff6c env: 08D0DF78407F2D2D0000029E) 2014-01-14 11:45:03.0385 INFO $bytes = [System.Text.Encoding]::UTF8.GetBytes("$tc_username:$tc_password")
2014-01-14 11:45:03.0385 TRACE Stored Octopus.Platform.Deployment.Logging.LogMessageEvent from TentacleScriptRun-2w-iR1Q_+KT@SQ-MY-HOSTNAME-A10276BE to Octopus.Logger@SQ-MY-HOSTNAME-04A4C628 (id: 968991e730cf4954afb96a32ba5e51e1 env: 08D0DF78407F7B640000029F)
2014-01-14 11:45:03.0385 INFO $encodedCredentials = [System.Convert]::ToBase64String($bytes)
2014-01-14 11:45:03.0385 TRACE Stored Octopus.Platform.Deployment.Logging.LogMessageEvent from TentacleScriptRun-2w-iR1Q_+KT@SQ-MY-HOSTNAME-A10276BE to Octopus.Logger@SQ-MY-HOSTNAME-04A4C628 (id: b5035f0acda849eb94d3be8adff882d6 env: 08D0DF78407FF0BC000002A0)
2014-01-14 11:45:03.0385 INFO $tc_api_datePattern = ‘yyyyMMdd\THHmmss:ffff’
2014-01-14 11:45:03.0385 TRACE Stored Octopus.Platform.Deployment.Logging.LogMessageEvent from TentacleScriptRun-2w-iR1Q_+KT@SQ-MY-HOSTNAME-A10276BE to Octopus.Logger@SQ-MY-HOSTNAME-04A4C628 (id: 3b831266e5b741e38f9295e99dcaac2d env: 08D0DF7840803EDD000002A1)
2014-01-14 11:45:03.0385 INFO
2014-01-14 12:50:12.0836 DEBUG Octopus version: 2.0.5 / 43417865/master `

I’ve experimented taking various lines out but it doesn’t seem to make a difference.

The tentacle process crashes almost immediately and the logs a portion of the script.

Hi Piers,

This sounds like a bug we recently fixed, whereby empty messages/lines written to the log output could cause a crash.

Which version of Octopus are you using? 2.0.9.1020 contains the fix. You’ll need to upgrade Tentacles as well (can be done from the Environments page automatically).

Regards,
Nick

I’m on 2.0.8.977.

I’ll give it a shot.

Success. Thanks Nick!

Funny enough I wasn’t getting the upgrade prompt at the bottom. Now I am i.e.
Octopus Deploy 2.0.9.1020 Download 2.0.9.1020

Great, thanks Piers. Yes, the upgrade prompt was added in the new build but doesn’t dismiss correctly; we’ll have that fixed up shortly :slight_smile:

Cool

So now I just noticed that I can’t put the script text into a variable and reference that as script body in the Powershell Script step.

This means if I have a step I want to include in multiple deployments I need to copy and paste the script repeatedly. This is very cumbersome when making changes to such scripts.

Hi - yes, we generally recommend shared PowerShell modules for common functionality, but I can see how doing variable token replacement inside the script body would be handy. It’s unlikely we’ll tackle it this way however as the mash-up of PowerShell syntax and Octopus syntax could get crazy to work with.

We’ve been intending for a while to support some kind of script reuse via the library; I’ve created an issue here to track it, feel free to add your thoughts: https://github.com/OctopusDeploy/Issues/issues/507

Cheers,
Nick

Sounds good. Probably worth my creating modules anyways. Do you guys have a preferred method that will be future proof with whereever you’re planning to take the product?

Right now I’m thinking I create a project with my .psm1 and deploying that to all tentacles and installing.

Your approach sounds like the right one. It’s hard to say how we’ll approach this, but PowerShell modules are a solid packaging option that we’re likely to keep in mind.

Cheers,
Nick