Apply retention policies failing

The releases are not available via the UI and the API call /{baseSpaceId}/projects/{projectId}/releases does not return those releases.

I could try and delete the releases directly using DELETE
​/{baseSpaceId}​/releases​/{id} but could you confirm that I can use the Id column in SELECT * FROM [dbo].[Release] where JSON = ‘’ for that API call please?

Hi @simon.george ,

You are correct, the value from the Id column in the dbo.Release table is what should be used for any API calls referencing that release. Let us know if you hit any other issues trying to get those cleaned up.

Thanks!
Dan

Hi Dan,

The API returns 404 when I try and delete these releases. They are orphaned from both the API and UI.
Can you provide SQL to delete? Or advice otherwise…
Thanks
Simon

Hi Simon,

Sorry that attempting to remove these releases via the API is returning a 404. I’ve tested this on my end and am getting the same behavior, however I think the following should work to get these releases removed.

First, take a backup of your database prior to doing any of the following.

Next, update the JSON for the missing releases to have an empty JSON body by running the following SQL script:

UPDATE
dbo.Release
SET JSON = '{}'
WHERE JSON = ''

Once you’ve done that, you should be able to remove the releases via the API in a safer manner (i.e. a cascade delete rather than via the database) with the following script:

# Define working variables
$octopusURL = "https://YOUR_OCTO_URL"
$octopusAPIKey = "API-####"
$header = @{ "X-Octopus-ApiKey" = $octopusAPIKey }
$spaceName = "YOUR_SPACE_NAME"
$releaseId = "Releases-####"

# Get space
$space = (Invoke-RestMethod -Method Get -Uri "$octopusURL/api/spaces/all" -Headers $header) | Where-Object {$_.Name -eq $spaceName}

# Delete release
Invoke-RestMethod -Method Delete "$octopusURL/api/$($space.Id)/releases/$releaseId" -Headers $header

Hopefully that gets you unblocked, but let us know how it goes!

Best,
Partrick

Thank you for your help, retention policies are now running and we have recovered 2Tb of disk space. Plus the UI is a bit more responsive :grinning:

1 Like

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