Issues icon indicating copy to clipboard operation
Issues copied to clipboard

Retention Policy - Updating Cron Schedule Doesn't Update Next Retention Task

Open FinnianDempsey opened this issue 11 months ago • 1 comments

Severity

not blocking, workaround exists

Version

2024.3.12915

Latest Version

I could reproduce the problem in the latest build

What happened?

When updating the cron schedule under Configuration -> Settings -> Retention Policies the Retention Task isn't updated until the next task is executed.

If it's set too far into the future then it requires manually running retention until the time specified with QueueApplyRetentionPolicyTasksJob or manually updating the value in the DB.

Reproduction

  • Configure Retention Policies cron to a future date (e.g. 0 0 0 15 * * *)
  • Check QueueApplyRetentionPolicyTasksJob to see it hasn't updated
  • Wait until for the time specified in QueueApplyRetentionPolicyTasksJob (e.g. 4 hours)
  • See QueueApplyRetentionPolicyTasksJob set to the future date

Error and Stacktrace

N/A

More Information

Internal Link - Slack

Cron expression entry doesn't modify the QueueApplyRetentionPolicyTasksJob value: image

Workaround

Update the QueueApplyRetentionPolicyTasksJob entry in the DB manually or run the Retention Task via the API:

$OctopusServerUrl = "https://youroctopusurl"  #PUT YOUR SERVER LOCATION HERE. (e.g. http://localhost)
$ApiKey = "API-1234"   #PUT YOUR API KEY HERE
$taskname = "Retention" #IF YOU WANT TO RUN A DIFFERENT TASK, MODIFY THIS VARIABLE

$task = Invoke-RestMethod -Method "get" "$OctopusServerUrl/api/tasks?take=1&skip=0&name=$($taskname)&spaces=all&includeSystem=true" -Headers @{"X-Octopus-ApiKey" = $ApiKey }
$rerunurl = $task.Items[0].Links.Rerun
Invoke-RestMethod -Method "POST" "$OctopusServerUrl$($rerunurl)" -Headers @{"X-Octopus-ApiKey" = $ApiKey }

FinnianDempsey avatar Nov 06 '24 03:11 FinnianDempsey