Error with 'Apply retention policy on Tentacles' step.

jshantz's Avatar


22 Jan, 2018 04:02 PM

Version: 4.0.10
Problem: The mentioned step is consistently erroring out. The error message is: "The step failed: Sequence contains no elements." See a screenshot here; a screenshot of the full deployment log is here.

Things that may be related:

  • I recently started deploying to multiple servers. Single-server environments are still deployed without error; only multi-server environments are failing.
  • I use rolling deployments with a window size of 1 as the deployment process cannot yet be run in parallel on each server.
  • The deployment is part of a process run by TeamCity; after the deployment is complete, the deployment targets are disabled (my theory is that this is relevant).

Relevant bit from the deployment log:

== Failed: Apply retention policy on Tentacles ==
17:52:58   Info     |     Apply retention policies...
17:52:58   Verbose  |     An operation in "Apply Tentacle Retention Policy" failed
                    |     Sequence contains no elements
                    |     System.InvalidOperationException: Sequence contains no elements
                    |     at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
                    |     at Octopus.Server.Orchestration.Deploy.DeploymentTaskController.<ApplyRetention>b__23_2(String key, IEnumerable`1 group)
                    |     at System.Linq.Lookup`2.<ApplyResultSelector>d__13`1.MoveNext()
                    |     at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
                    |     at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
                    |     at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
                    |     at Octopus.Server.Orchestration.Tasks.OctoParallel.ForEach[T](IEnumerable`1 workItems, Int32 maxParallelism, Action`1 executeCallback, ITaskContext taskContext)
                    |     at Octopus.Server.Orchestration.Deploy.DeploymentTaskController.ApplyRetention(PlannedStep step)
                    |     at Octopus.Server.Orchestration.Deploy.DeploymentTaskController.DispatchStep(PlannedStep step)
                    |     Octopus.Server version 4.0.10 (4.0.10+Branch.master.Sha.8e26d7e6c5fc9975d60673a9afaa79060fb0909a)
17:52:58   Fatal    |     The step failed: Sequence contains no elements
17:52:58   Verbose  |     Apply Tentacle Retention Policy completed
  1. 1 Posted by jshantz on 22 Jan, 2018 06:03 PM

    jshantz's Avatar

    I figured out the problem.

    1) The process was taking longer than 10 minutes but, by default, the Deploy build step in TeamCity has a 10 minute time out. TeamCity was reporting the deployment step as failed when it was, in fact, still running.

    2) I have a subsequent build step that disables the deployment targets even if preceding steps have failed. This step was run and the deployment targets were disabled.

    3) The process in Octopus happily continued until completion, then tried to apply the retention policy. There were no enabled deployment targets left to apply it to, though, and it errored out.

    The lesson: don't assume the reason why the deployment failed is what was reported in Octopus. What your CI server reports may be something different.

  2. Support Staff 2 Posted by Alex Rolley on 23 Jan, 2018 02:13 AM

    Alex Rolley's Avatar


    Thanks for getting in touch, glad you were able to work out what the issue was!

    Let me know if there is anything that we can assist with,

    Happy deploying,


Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac