Rention Policy Definition

Hi,

In the documentation on retention policies there is the following line about package retention.

‘Any packages that are used with a variable in the project will not be deleted even if the releases have been deleted.’

Does this mean that any project you use a variable in the step details of a package step e.g. the ‘NuGet package ID’, all packages will never be deleted. If not what does it mean?

Also, why is this the case?

I’m using v2.6.

Thanks,
Tim

To add, is this only packages that have actually been used in a release, or does it know which ones are used so keeps them all?

I just use variable for the package id and I have gigs of retained packages.

Hi Tim,

Thanks for asking.

Normally a project will reference a package like:

NuGet Package ID: MyPackage

When we run the package retention policies, we look for packages that are not used by any existing releases. So if you had these packages:

MyPackage.1.0.0   // Had been used by a release, but the release has since been deleted
MyPackage.1.0.1   // Was never used
MyPackage.1.0.2   // Still in use by release 1.0.2
MyPackage.1.0.3   // Still in use by release 1.0.3

Octopus would see that it is safe to delete MyPackage.1.0.0 and MyPackage.1.0.1 since they aren’t used. We work that out by saying:

  1. What packages do we have?
  2. What releases do we have?
  3. Which of those packages are not used by any releases

Now, imagine you use a variable:

NuGet Package ID: #{PackageName}

And you have the same packages:

MyPackage.1.0.0   // Had been used by a release, but the release has since been deleted
MyPackage.1.0.1   // Was never used
MyPackage.1.0.2   // Still in use by release 1.0.2
MyPackage.1.0.3   // Still in use by release 1.0.3

When we try to apply the policies:

  1. What packages do we have?
  2. What releases do we have?
  3. Which of those packages are not used by any releases

We get stuck at step 3, because all we know is that a release references #{PackageName}.1.0.1 - we don’t know if PackageName refers to MyPackage, or SomeOtherPackage - we can’t evaluate the variable at retention policy time. So there’s a small chance that we will delete the package even though it might really be used by a release.

So the way we approach this, is we keep a list of packages actually used by a given project, and update that list every deployment. So if you have something like this:

Project 1: NuGet Package ID: MyPackageA
Project 2: NuGet Package ID: #{PackageName}   // Sometimes resolves to MyPackageB, sometimes MyPackageC

We’ll do a good job of cleaning up MyPackageA packages without making mistakes, since it’s easy to tell when they are and are not used. But we’ll leave MyPackageB and MyPackageC packages alone. And if you upload a MyPackageD package which you intended to use, but never got around to deploying it, there’s a slim chance it will be deleted.

You can read more about how this has changed over time here:

Hope this helps!

Paul Stovell

Thanks Paul,

A great description that makes sense.

Tim