Calamari unable to remove junction points

We just did a somewhat large upgrade jump from 2018.6.13 to 2018.9.1 (can’t wait for LTS), which upgraded Calamari from 4.7.21 to 4.9.16 on some of our targets.

Anyway, we have a node web app that uses a junction point for one of its modules (node-windows). This was not a problem in our previous version, but after this upgrade, our targets started throwing errors when they tried to clear out a folder before copying contents over from the Work directory to the destination app directory.

I can temporarily work around that issue by excluding the junction point from the deployment step purge process.
https://i.imgur.com/KTJmocG.png

Then it gave me a somewhat different error saying it couldn’t remove the junction point during the Work folder retention cleanup.

Did something change with how Calamari removes files inside a directory, specifically with junction points? I think it’s a UAC elevation issue. I was able to remove the junction point without elevating by adding something like this:

if ((Get-Item -Path "#{Application.BaseFolder}\AppName\node_modules\node-windows" -Force).LinkType) {
    fsutil reparsepoint delete #{Application.BaseFolder}\AppName\node_modules\node-windows
}

Note: the problem does not occur if I run the Tentacle service as Administrator.

Logs:

08:54:03   Info     |       Purging the directory 'C:\ProjectName\AppName'
08:54:03   Error    |       System.IO.IOException: (87) The parameter is incorrect: [\\?\C:\ProjectName\AppName\node_modules\node-windows]
08:54:03   Error    |       at Alphaleonis.Win32.NativeError.ThrowException(UInt32 errorCode, String readPath, String writePath)
08:54:03   Error    |       at Alphaleonis.Win32.Filesystem.Directory.DeleteDirectoryCore(FileSystemEntryInfo fileSystemEntryInfo, KernelTransaction transaction, String path, Boolean recursive, Boolean ignoreReadOnly, Boolean continueOnNotExist, PathFormat pathFormat)
08:54:03   Error    |       at Calamari.Integration.FileSystem.LongPathsDirectory.Delete(String path, Boolean recursive)
08:54:03   Error    |       at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate`1 exclude, FailureOptions options, CancellationToken cancel, Boolean includeTarget)
08:54:03   Error    |       at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate`1 exclude, FailureOptions options, CancellationToken cancel, Boolean includeTarget)
08:54:03   Error    |       at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, FailureOptions options, String[] globs)
08:54:03   Error    |       at Calamari.Deployment.Conventions.CopyPackageToCustomInstallationDirectoryConvention.Install(RunningDeployment deployment)
08:54:03   Error    |       at Calamari.Deployment.ConventionProcessor.RunInstallConventions()
08:54:03   Error    |       at Calamari.Deployment.ConventionProcessor.RunConventions()
08:54:03   Error    |       Running rollback conventions...


After adding the exclude:

13:16:21   Info     |       Purging the directory 'C:\ProjectName\AppName'
13:16:21   Info     |       Leaving files and directories that match any of: 'C:\ProjectName\AppName\node_modules\node-windows'
13:16:21   Verbose  |       Retry #1 on delete file 'C:\ProjectName\AppName\daemon\AppName.err.log'. Exception: (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProjectName\AppName\daemon\AppName.err.log]
13:16:21   Info     |       Copying package contents to 'C:\ProjectName\AppName'
13:16:21   Verbose  |       Retry #1 on copy 'C:\ProjectName\AppName\node_modules\node-windows\LICENSE'. Exception: (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProjectName\AppName\node_modules\node-windows\LICENSE]
13:16:21   Verbose  |       Retry #2 on copy 'C:\ProjectName\AppName\node_modules\node-windows\LICENSE'. Exception: (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProjectName\AppName\node_modules\node-windows\LICENSE]
13:16:22   Verbose  |       Retry #3 on copy 'C:\ProjectName\AppName\node_modules\node-windows\LICENSE'. Exception: (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProjectName\AppName\node_modules\node-windows\LICENSE]
13:16:22   Verbose  |       Retry #4 on copy 'C:\ProjectName\AppName\node_modules\node-windows\LICENSE'. Exception: (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProjectName\AppName\node_modules\node-windows\LICENSE]
13:16:33   Verbose  |       Retry #54 on copy 'C:\ProjectName\AppName\node_modules\node-windows\LICENSE'. Exception: (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProjectName\AppName\node_modules\node-windows\LICENSE]
13:16:44   Verbose  |       Retry #104 on copy 'C:\ProjectName\AppName\node_modules\node-windows\LICENSE'. Exception: (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProjectName\AppName\node_modules\node-windows\LICENSE]
13:16:54   Verbose  |       Retry #154 on copy 'C:\ProjectName\AppName\node_modules\node-windows\LICENSE'. Exception: (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProjectName\AppName\node_modules\node-windows\LICENSE]
13:17:04   Verbose  |       Retry #204 on copy 'C:\ProjectName\AppName\node_modules\node-windows\LICENSE'. Exception: (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProjectName\AppName\node_modules\node-windows\LICENSE]
13:17:14   Verbose  |       Retry #254 on copy 'C:\ProjectName\AppName\node_modules\node-windows\LICENSE'. Exception: (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProjectName\AppName\node_modules\node-windows\LICENSE]
13:17:24   Error    |       System.IO.IOException: (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProjectName\AppName\node_modules\node-windows\LICENSE]
13:17:24   Error    |       at Alphaleonis.Win32.NativeError.ThrowException(UInt32 errorCode, String readPath, String writePath)
13:17:24   Error    |       at Alphaleonis.Win32.Filesystem.File.CopyMoveCore(Boolean isFolder, KernelTransaction transaction, String sourcePath, String destinationPath, Boolean preserveDates, Nullable`1 copyOptions, Nullable`1 moveOptions, CopyMoveProgressRoutine progressHandler, Object userProgressData, PathFormat pathFormat)
13:17:24   Error    |       at Alphaleonis.Win32.Filesystem.File.Copy(String sourceFileName, String destinationFileName, Boolean overwrite)
13:17:24   Error    |       at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.RetryTrackerFileAction(Action fileAction, String target, String action)
13:17:24   Error    |       at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.CopyDirectory(String sourceDirectory, String targetDirectory, CancellationToken cancel)
13:17:24   Error    |       at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.CopyDirectory(String sourceDirectory, String targetDirectory, CancellationToken cancel)
13:17:24   Error    |       at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.CopyDirectory(String sourceDirectory, String targetDirectory, CancellationToken cancel)
13:17:24   Error    |       at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.CopyDirectory(String sourceDirectory, String targetDirectory)
13:17:24   Error    |       at Calamari.Deployment.Conventions.CopyPackageToCustomInstallationDirectoryConvention.Install(RunningDeployment deployment)
13:17:24   Error    |       at Calamari.Deployment.ConventionProcessor.RunInstallConventions()
13:17:24   Error    |       at Calamari.Deployment.ConventionProcessor.RunConventions()
13:17:24   Error    |       Running rollback conventions...


13:17:24   Error    |       (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProjectName\AppName\node_modules\node-windows\LICENSE]
13:17:24   Error    |       System.IO.IOException
13:17:24   Error    |       at Alphaleonis.Win32.NativeError.ThrowException(UInt32 errorCode, String readPath, String writePath)
13:17:24   Error    |       at Alphaleonis.Win32.Filesystem.File.CopyMoveCore(Boolean isFolder, KernelTransaction transaction, String sourcePath, String destinationPath, Boolean preserveDates, Nullable`1 copyOptions, Nullable`1 moveOptions, CopyMoveProgressRoutine progressHandler, Object userProgressData, PathFormat pathFormat)
13:17:24   Error    |       at Alphaleonis.Win32.Filesystem.File.Copy(String sourceFileName, String destinationFileName, Boolean overwrite)
13:17:24   Error    |       at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.RetryTrackerFileAction(Action fileAction, String target, String action)
13:17:24   Error    |       at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.CopyDirectory(String sourceDirectory, String targetDirectory, CancellationToken cancel)
13:17:24   Error    |       at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.CopyDirectory(String sourceDirectory, String targetDirectory, CancellationToken cancel)
13:17:24   Error    |       at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.CopyDirectory(String sourceDirectory, String targetDirectory, CancellationToken cancel)
13:17:24   Error    |       at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.CopyDirectory(String sourceDirectory, String targetDirectory)
13:17:24   Error    |       at Calamari.Deployment.Conventions.CopyPackageToCustomInstallationDirectoryConvention.Install(RunningDeployment deployment)
13:17:24   Error    |       at Calamari.Deployment.ConventionProcessor.RunInstallConventions()
13:17:24   Error    |       at Calamari.Deployment.ConventionProcessor.RunConventions()
13:17:24   Error    |       at Calamari.Commands.DeployPackageCommand.Execute(String[] commandLineArguments)
13:17:24   Error    |       at Calamari.Program.Execute(String[] args)

Work folder cleanup:

20:32:00   Info     |         Removing directory 'C:\Octopus\Applications\ServerName\SomeFolderName\0.532.193'
20:32:00   Error    |         (87) The parameter is incorrect: [\\?\C:\Octopus\Applications\ServerName\SomeFolderName\0.532.193\node_modules\node-windows]
20:32:00   Error    |         System.IO.IOException
20:32:00   Error    |         at Alphaleonis.Win32.NativeError.ThrowException(UInt32 errorCode, String readPath, String writePath)
20:32:00   Error    |         at Alphaleonis.Win32.Filesystem.Directory.DeleteDirectoryCore(FileSystemEntryInfo fileSystemEntryInfo, KernelTransaction transaction, String path, Boolean recursive, Boolean ignoreReadOnly, Boolean continueOnNotExist, PathFormat pathFormat)
20:32:00   Error    |         at Calamari.Integration.FileSystem.LongPathsDirectory.Delete(String path, Boolean recursive)
20:32:00   Error    |         at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate`1 exclude, FailureOptions options, CancellationToken cancel, Boolean includeTarget)
20:32:00   Error    |         at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate`1 exclude, FailureOptions options, CancellationToken cancel, Boolean includeTarget)
20:32:00   Error    |         at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, FailureOptions options)
20:32:00   Error    |         at Calamari.Deployment.Retention.RetentionPolicy.DeleteExtractionDestination(JournalEntry deployment, List`1 preservedEntries)
20:32:00   Error    |         at Calamari.Deployment.Retention.RetentionPolicy.ApplyRetentionPolicy(String retentionPolicySet, Nullable`1 days, Nullable`1 releases)
20:32:00   Error    |         at Calamari.Commands.CleanCommand.Execute(String[] commandLineArguments)
20:32:00   Error    |         at Calamari.Program.Execute(String[] args)
20:32:00   Verbose  |         Process C:\Windows\system32\WindowsPowershell\v1.0\PowerShell.exe in C:\Octopus\Work\20181106023159-108299-101 exited with code 100
20:32:00   Warning  |         The remote script failed with exit code 100

Hi Adam,

​Thanks for reaching out. Sorry to hear you have hit this issue with Octopus. We have identified the issue and have fixed it in Calamari 4.9.17, which will get release with Octopus 2018.9.7.
​If you like, I can send through a build of Calamari 4.9.17 with instructions on how to configure your server to use a specific version?

​I hope that helps, please let me know if you have any further questions.

​Kind regards,
​Tom

1 Like

Hi,

We hit the same issue. Nice to know its fixed. We’ll wait for the next release for this fix.

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