Issues
Issues copied to clipboard
Retention Policy - Updating Cron Schedule Doesn't Update Next Retention Task
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
Cron expression entry doesn't modify the QueueApplyRetentionPolicyTasksJob value:
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 }