Issues icon indicating copy to clipboard operation
Issues copied to clipboard

Nupkg deployments to Azure Web Apps fail the release package part of the deployment (Error - The file 'C:\Octopus\Tentacle\Files\packagename.zip' already exists).

Open Clare-Octopus opened this issue 1 year ago • 0 comments

Severity

Not blocking customers, the package itself is deployed, its just the release part of the deployment fails.

Version

2024.2.3973, 2024.1.12087

Latest Version

I could reproduce the problem in the latest build

What happened?

When trying to deploy a nupkg to an Azure App Service using the Azure App Service step in a deployment, the step will convert the nupkg to a .zip file (as the step itself is a zip deploy step). The package itself will get sent to the target Web App so the deployment itself will succeed and your application will be deployed, but on the release packages stage you will see one of three errors depending on what workers you use for the step:

Cloud Hosted Windows Worker Pool (our dynamic worker):

The process cannot access the file 'C:\Octopus\Tentacle\Files\packagename.zip' because it is being used by another process.

On retry of the deployment you will see:

The file 'C:\Octopus\Tentacle\Files\packagename.zip' already exists.

During my testing I found if using a normal windows worker or one of our Ubuntu Dynamic Cloud workers you will see:

Response status code does not indicate success: 401 (Unauthorized).

Your applications will be deployed but the Octopus deployment itself will show as a failure.

Reproduction

  1. Ensure you have a WebApp to deploy to in Azure.
  2. Set that WebApp up in Octopus as a target.
  3. Ensure you have a basic .nupkg in the Octopus Built-In feed or an external feed.
  4. Create a basic project with a Deploy an App Service step.
  5. Create a release and deploy the nupkg file to that webapp.
  6. See the errors.

Error and Stacktrace

08:12:10   Verbose  |       Target Site: ClareWebApp
08:12:10   Verbose  |       Publishing C:\Octopus\Tentacle\Files\[email protected]@8E53B723E7435A46A4E14257A6A2A940.zip to https://clarewebapp.scm.azurewebsites.net:443/api/zipdeploy
08:14:20   Error    |       Running rollback behaviours...
08:14:20   Error    |       The process cannot access the file 'C:\Octopus\Tentacle\Files\[email protected]@8E53B723E7435A46A4E14257A6A2A940.zip' because it is being used by another process.
08:14:20   Error    |       System.IO.IOException
08:14:20   Error    |       at System.IO.FileSystem.DeleteFile(String fullPath)
08:14:20   Error    |       at System.IO.File.Delete(String path)
08:14:20   Error    |       at Calamari.AzureAppService.Behaviors.AzureAppServiceZipDeployBehaviour.CleanupUploadFile(String uploadPath) in C:\BuildAgent\work\e0cefbed4ad11812\source\Calamari.AzureAppService\Behaviors\AzureAppServiceZipDeployBehaviour.cs:line 358
08:14:20   Error    |       at Calamari.AzureAppService.Behaviors.AzureAppServiceZipDeployBehaviour.Execute(RunningDeployment context) in C:\BuildAgent\work\e0cefbed4ad11812\source\Calamari.AzureAppService\Behaviors\AzureAppServiceZipDeployBehaviour.cs:line 176
08:14:20   Error    |       at Calamari.Common.Plumbing.Pipeline.PipelineCommand.ExecuteBehaviour(RunningDeployment context, IBehaviour behaviour) in C:\BuildAgent\work\e0cefbed4ad11812\source\Calamari.Common\Plumbing\Pipeline\PipelineCommand.cs:line 165
08:14:20   Error    |       at Calamari.Common.Plumbing.Pipeline.PipelineCommand.Execute(ILifetimeScope lifetimeScope, IVariables variables) in C:\BuildAgent\work\e0cefbed4ad11812\source\Calamari.Common\Plumbing\Pipeline\PipelineCommand.cs:line 61
08:14:20   Error    |       at Calamari.Common.Plumbing.Pipeline.PipelineCommand.Execute(ILifetimeScope lifetimeScope, IVariables variables) in C:\BuildAgent\work\e0cefbed4ad11812\source\Calamari.Common\Plumbing\Pipeline\PipelineCommand.cs:line 85
08:14:20   Error    |       at Calamari.Common.CalamariFlavourProgramAsync.Run(String[] args) in C:\BuildAgent\work\e0cefbed4ad11812\source\Calamari.Common\CalamariFlavourProgramAsync.cs:line 144
08:14:20   Verbose  |       Process C:\Windows\system32\WindowsPowershell\v1.0\PowerShell.exe in C:\Octopus\Tentacle\Work\EzhrA7ICpkeJBgDV3Ji2A exited with code 100
08:14:21   Verbose  |       Updating manifest with output variables
08:14:21   Verbose  |       Updating manifest with action evaluated variables
08:14:21   Verbose  |       Updating manifest with output variables
08:14:21   Verbose  |       Updating manifest with action evaluated variables
08:14:21   Fatal    |       The remote script failed with exit code 100
08:14:21   Fatal    |       The action Deploy an Azure App Service on ClareWebApp failed

More Information

  • Initial ticket raised (internal) - https://octopus.zendesk.com/agent/tickets/178242

  • Slack Discussion (internal) - https://octopusdeploy.slack.com/archives/C01Q95KPRM4/p1712244924367929

  • Reproduction (internal) - https://octopus-operations.octopus.app/app#/Spaces-422/projects/ticket-178242-test/deployments?groupBy=Channel

Engineers Note, my WebApp wont be around for long so you may need to create a new one if using my reproduction for testing.

Workaround

No workaround at the moment, your WebApp applications will be deployed to your webapp so you may need to manually go into the deployment and change its status to a success if using a lifecycle where environments need to be successfully deployed to before the release being promoted:

image

Clare-Octopus avatar Apr 08 '24 10:04 Clare-Octopus