New-OctopusArtifact

Hi,
We are using Octopus 3.0.4.2105 and when we try to use New-OctopusArtifact to get log file we have exception in Octopus Tentacle log and script hung forever.
This is probably because this method New-OctopusArtifact should try open file in read only mode.
This log file I can open for example in Notepad application.

System.IO.IOException: The process cannot access the file ‘E:\WebApplication\logs\2016-04-22.log’ because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream…ctor(String path, FileMode mode, FileAccess access, FileShare share)
at Octopus.Shared.Util.OctopusPhysicalFileSystem.OpenFile(String path, FileMode mode, FileAccess access, FileShare share) in Y:\work\refs\tags\3.3.2\source\Octopus.Shared\Util\OctopusPhysicalFileSystem.cs:line 184
at Octopus.Shared.Util.OctopusPhysicalFileSystem.OpenFile(String path, FileAccess access, FileShare share) in Y:\work\refs\tags\3.3.2\source\Octopus.Shared\Util\OctopusPhysicalFileSystem.cs:line 177
at Octopus.Tentacle.Services.FileTransfer.FileTransferService.<>c__DisplayClass4_0.b__0(Stream writer) in Y:\work\refs\tags\3.3.2\source\Octopus.Tentacle\Services\FileTransfer\FileTransferService.cs:line 37
at Halibut.Transport.Protocol.MessageExchangeStream.WriteEachStream(IEnumerable1 streams) in y:\work\7ab39c94136bc5c6\source\Halibut\Transport\Protocol\MessageExchangeStream.cs:line 275 at Halibut.Transport.Protocol.MessageExchangeStream.Send[T](T message) in y:\work\7ab39c94136bc5c6\source\Halibut\Transport\Protocol\MessageExchangeStream.cs:line 143 at Halibut.Transport.Protocol.MessageExchangeProtocol.ProcessClientRequests(Func2 incomingRequestProcessor) in y:\work\7ab39c94136bc5c6\source\Halibut\Transport\Protocol\MessageExchangeProtocol.cs:line 110
at Halibut.Transport.SecureListener.ExecuteRequest(TcpClient client) in y:\work\7ab39c94136bc5c6\source\Halibut\Transport\SecureListener.cs:line 126

Hi Robert,

Thanks for reaching out!

Could you try the following POC to prove your point and see if there’s something we can do about it? On the same script where you are calling New-OctopusArtifact, first make a copy of that file and then create the artifact out of that copy.

Let me know if that works.

Dalmiro

Yes, when I copy artifact to file with different name then New-OctopusArtifact works well.

Hi Robert,

Thanks for getting in touch.

Unfortunately we have been unable to reproduce this issue. We spun up a 3.0.4.2105 instance, added a log file to the Tentacle, kept it open in Notepad on the Tentacle machine, then included it in our project as a artifact during a deployment (New-OctopusArtifact "C:\Octopus\markse\log.txt") and were able to deploy without fail.

Can you please confirm the exact steps you’re using to help us reproduce this problem?

Cheers
Mark S.

We do the following steps.

  1. We are deploying Windows Service application with Octopus
  2. Our application is creating log file and is using this log file
  3. We wait some time in post deployment script
  4. We would like to get this log file(created by our application) after deployment as artifact

Example with Notepad is kind of proof that this file is accessible by other applications and is not exclusively open to read/write by our application.

Hi Robert,

We are unable to reproduce this behaviour yet, so we’ve created a Github issue to investigate this further (you can track this issue to be notified when it is fixed). While we investigate this, are you able to workaround the issue with the copying the file first, then artifact approach Dalmiro mentioned earlier?

Cheers
Mark