Back in 2019 I posted a message about some challenges we’ve been having with package indexing. The latest in the thread indicated there’s work being done in this area (operations) but it was it wasn’t clear if the features were published. Are there any updates?
Thanks for the quick response. Disabling the index on startup will help in scheduled outage or upgrade scenarios; however indexing tasks seem to fire on their own during when Octopus is running. Is there a mechanism to completely disable the indexing task so it can be handled with a custom runbook process?
The audit screen doesn’t seem to have a filter on re-index tasks so getting examples via the UI isn’t really practical. When I attempt get the data via the api, I can’t seem to find an “initiator” property in the servertask object. Any suggestions on how I can get task detail and the initiator from the API?
Thank you for getting back to me. I have, hopefully, an easier way of parsing the Audit log.
Below is a PowerShell script you may run to find re-indexing tasks. The Audit log only includes the deletion of the system triggered re-index tasks, not the task itself. However, this will still tell us who is triggering these and how often they are attempting to run. Be sure to replace the values for $octopusUrl and $octopusApiKey. You’ll also likely need to adjust the value for $totalevents. If 10000 isn’t enough, try 100000, but you’ll need to be patient as it will probably take a minute or two to complete.
$Name = "SynchronizeBuiltInPackageRepositoryIndex" #name of the task as shown in the JSON for the event under ChangeDetails->DocumentContext->Name
$octopusUrl = "YOUR_OCTOPUS_URL"
$octopusApiKey = "YOUR_OCTOPUS_API_KEY"
$totalevents = "10000" #the total number of events you want to look through in decending order from most recent
$header = @{ "X-Octopus-ApiKey" = $octopusApiKey }
$json = (Invoke-RestMethod $OctopusUrl/api/events?take=$totalevents -Headers $header -Method Get)
Foreach ($event in $json.items){
If ($event.ChangeDetails.DocumentContext.Name -eq $Name){
Write-Host ---
Write-Host At `"$($event.Occurred)`" the user `"$($event.Username)`" triggered the following event: `"$($event.Message)`"
}
}
Here is an example of how the results should look:
Hey Donny -
Spent some time on this but wasn’t able to get tasks that were system initiated even though I can see them in the UI. Definitely an issue with my scripts but this is no longer a hot item. Will continue to work on this in the background but for now we’re going to set this issue down. Thnx for the help.