If a deployment fails while Tentacle downloads a package, extracts it, or runs a script, and the error mentions locked files, denied access, or blocked content, antivirus or endpoint detection and response (EDR) software is a likely cause. The fix is to confirm the security tool is involved, then add targeted exclusions for the Tentacle home directory and the processes Tentacle runs.
This article applies to Windows and Linux Tentacles, including workers, running Windows Defender or third-party AV/EDR products.
Resolution
Add exclusions for the folders Tentacle writes to and the processes it runs. Start with the narrowest set that fixes the failure, and replace the default paths with the paths from show-configuration. Default folder exclusion recommendations can be found at the following link:
https://octopus.com/docs/support/troubleshooting-failed-or-hanging-tasks/#anti-virus-software
Symptom
Security software interference usually shows up as an intermittent failure that passes on retry, or that affects some targets and not others. Look for these messages in the deployment task log.
| Stage | Typical task log messages |
|---|---|
| Package acquisition |
Access to the path '...\Files\...' is denied, The process cannot access the file because it is being used by another process, package hash mismatch, or a transfer that stalls and times out |
| Package extraction |
Could not find file or Could not find a part of the path during extraction, Access to the path ... is denied, or files missing from the extracted folder |
| Script execution | Bootstrapper did not return the bootstrapper service message |
| Script execution |
This script contains malicious content and has been blocked by your antivirus software, ScriptContainedMaliciousContent, Operation did not complete successfully because the file contains a virus or potentially unwanted software, or Calamari exiting with an unexpected code and no script output |
| Calamari or Tentacle upgrade | Calamari fails to unpack into the Tools folder, or Tentacle fails to upgrade or start |
Other signs include deployments that slow down sharply after a security agent is installed or updated, and failures that started on a date that matches a security policy change rather than a change to your project.
Scope: when this is the right article
Use this article when all of these are true:
- The failure happens on a Tentacle or worker, during package acquisition, package extraction, or script execution.
- The error points to a file or a process: a locked file, denied access, a missing file, blocked script content, or a process that exits with no output.
- The machine runs antivirus or EDR software.
- The failure is intermittent, affects only some machines, or started after a security agent or policy change.
Cause
Every deployment step makes Tentacle write and run new files, which is the behavior security software is built to inspect. During a typical step, Tentacle:
- Receives the package from Octopus Server, or downloads it from a feed, into the package cache (
C:\Octopus\Filesby default). - Unpacks Calamari, the tool that runs deployment steps, into the Tools folder (
C:\Octopus\Tools) the first time a new version is needed. - Extracts the package into the Applications folder (
C:\Octopus\Applications), or a custom installation directory. - Writes a script and its variables to a temporary folder under
C:\Octopus\Work, then runs it with PowerShell, Bash, or another interpreter.
On-access scanners lock each new file while they inspect it, so Tentacle can't move, extract, or delete it in time. Some products quarantine or delete files they flag, often compressed archives or executables in the package. PowerShell script content also passes through the Windows Antimalware Scan Interface (AMSI), which can block a script before it runs. EDR tools can also kill a process whose behavior matches a rule, such as a script that downloads files or changes services.
The paths above are the Windows defaults. Your Tentacle home directory may be different, and on Linux it is set during installation.
Diagnosis and fix
Before you change any security settings, collect evidence. Your security team will need it to approve an exclusion.
- Find your Tentacle paths. On the Tentacle machine, run this from the Tentacle installation folder and note the home directory and application directory:
.\Tentacle.exe show-configuration
On Linux, run /opt/octopus/tentacle/Tentacle show-configuration --instance <instance-name>.
-
Match the failure time to security events. Note the timestamp of the failed task, then check the security product's logs for the same minute.
-
For third-party antivirus products, ask your security team to search the agent console for detections on the machine, filtered by the Tentacle home directory or by
Tentacle.exe,Calamari.exe, orpowershell.exe. -
Trace file access. If the security logs show nothing, run Process Monitor during a deployment. Filter on a path that begins with your Tentacle home directory and look for
ACCESS DENIEDorSHARING VIOLATIONresults raised by a security process. -
Keep the evidence. To capture the script and files Calamari used, add the project variable
Octopus.Calamari.CopyWorkingDirectoryIncludingKeyToand set it to a folder path (https://octopus.com/docs/support/copy-working-directory). Remove the variable after you finish, because the copy includes sensitive variable values. -
Test on a non-critical machine, if your policy allows it. On one non-production target, add an exclusion for the Tentacle home directory, then redeploy. If the failure continues, and it's possible in your environment, turn off the antivirus or EDR agent completely on that machine and redeploy again, because some products still scan or block excluded paths. Your security team may need to do this if the agent has tamper protection. If the failure goes away, you've confirmed the cause. Turn protection back on as soon as the test finishes, and never turn it off on production machines.
Verify
The fix worked when the deployment succeeds repeatedly on every affected machine, and the security product logs no new detections during those deployments.
- Confirm that the proper exclusions are in place.
- Redeploy the release that failed. Deploy the same release to the same targets, so you test the same package and scripts.
- Repeat the deployment. Because these failures are often intermittent, one success isn't proof. Deploy several times, and include every machine that failed before.
-
Check for new detections. Look at the Windows Defender Operational log,
Get-MpThreatDetection, or your AV/EDR console for events at the time of each deployment. You should see none for the Tentacle home directory or for Tentacle and Calamari. - Compare deployment times. If scanning slowed your deployments, step durations in the task log should return to what they were before the security agent was installed or updated.
-
Clean up. Remove any broad exclusion you added for testing, such as one for the whole Tentacle home directory, and remove the
Octopus.Calamari.CopyWorkingDirectoryIncludingKeyTovariable if you added it.
If failures continue, compare the new task log errors with the Symptoms table. A different error may point to a path or process your exclusions don't cover yet.
Related
- Hardening Octopus, including malware protection and a sample Windows Defender script
- Troubleshooting Tentacles