Octopus purges whole directory on first deploy

execution

(Luuk Jensen) #1

Hello,

We are trying to deploy a website to a live location. This is done to a custom install directory,
As shown below we purge the directory before we deploy, and skip some directories. This works fine after the first deployment Octopus does.

However when Octopus deploys for the first time to a given environment, it purges the whole directory, including the directories/files that we excluded.

We are using Octopus version 2018.1.2


#3

Hi Luuk,

Thanks for getting in touch!

That doesn’t look like correct behaviour as when we review the code for the purge directory option we don’t appear have a special flag for first run instances. So that we can try and work out what may be happening are you able to export and attach the raw logs for the deployment where this occurred?

I tested on the version that I currently have installed (2018.5.1) and it didn’t exhibit the same issue.

I look forward to hearing from you shortly,

Regards
Alex


(Luuk Jensen) #4

Hello,

Thanks for the swift answer.

I have attached the raw server task log. The given build failed due to something on our end (another problem we are trying to solve involving certificates and bindings). Note that for some reason the release was not rolled back. maybe because it was impossible at this point, or some setting I missed.

We will also look into this ourselves, maybe one of our variables was wrongly configured and octopus did exactly what we asked it to do.

I hope that together we can come to a solution.

ServerTasks-9834.log.txt (43.1 KB)


#5

Hi Luuk,

Everything looks OK from a log point of view, I’m seeing exactly what I expect to see:

9:41:53   Info     |         Purging the directory 'C:\****\****'
19:41:53   Info     |         Leaving files and directories that match any of: 'App_Data\*, Media\*, Downloads\*'
19:42:09   Info     |         Copying package contents to 'C:\****\****'
19:42:09   Info     |         Copied 3106 files

Is it possible for you to try and replicate the issue with another release (if you have a test environment that you can check against).

As for the error you are seeing:

19:42:30   Error    |         Cannot create a file when that file already exists. (Exception from HRESULT: 0x
19:42:30   Error    |         800700B7)
19:42:30   Error    |         At C:\Octopus\Work\20180515160821-9834-188\Script.ps1:11 char:1
19:42:30   Error    |         + $webSite.Start()
19:42:30   Error    |         + ~~~~~~~~~~~~~~~~
19:42:30   Error    |         + CategoryInfo          : OperationStopped: (:) [], COMException
19:42:30   Error    |         + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException

That is IIS reporting that you have multiple sites bound to the same port, more information on how to resolve that can be found here.

I hope that helps, please let me know if there is anything else we can assist with, and please let me know if you are able to replicate your initial issue,

Regards,
Alex


(Luuk Jensen) #6

Alas we were not able to replicate the issue, but we found what might have been part of the problem.
Turns out we were excluding the wrong directory.
I have one question that might shed some light on the problem. Is there a functional difference between excluding <directory>\* and <directory>\ ?

It might be a good idea to include an option to make a backup prior to purging, or to add what files are being deleted to the raw log so that we can see if something happens that shouldn’t and fix it.


#7

Hi Luuk,

That’s good to hear, unfortunate that the wrong directory was excluded.

I have passed on to the team your suggestions around backups (unlikely) and logging deleted files (more likely), so keep an eye out for those in future. As for <directory>\* and <directory> we had a look at the code and they should be functionally the same, we can’t identify any differences at this point. Below is the code we use when using <directory>\*:

private IEnumerable<FileSystemInfo> EnumerateWithGlob(string parentDirectoryPath, params string[] globPattern)
        {
            var results = globPattern.Length == 0
                ? Glob.Expand(Path.Combine(parentDirectoryPath, "*"))
                : globPattern.SelectMany(pattern => Glob.Expand(Path.Combine(parentDirectoryPath, pattern)));

            return results
                .GroupBy(fi => fi.FullName) // use groupby + first to do .Distinct using fullname
                .Select(g => g.First());
        }

Please let me know if there is anything else that I can assist with,

Regards,
Alex


(system) #8

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