Increased Control Over Package Indexing - Revisited

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,

Hi @ShannonN,

Thank you for contacting Octopus Support. I’m sorry you are having issues with package reindexing getting in the way of deployments.

To get more control over reindexing, you could disable reindexing on startup per the image below:

Then you can create a Runbook using this script that will allow you to run the task on a schedule at a more convenient time:

Just be sure to change the value for the variable on line 3 to: SynchronizeBuiltInPackageRepositoryIndex

If you have any additional questions about this or anything else, please don’t hesitate to ask.

Best Regards,
Donny

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?

Hi @ShannonN,

Thank you for getting back to me.

Can you tell me what version of Octopus Server you are currently running?

Best Regards,
Donny

2021.1 (build 7788)

Hi @ShannonN,

Thank you for confirming.

Could you attempt to find re-indexing tasks in the Audit log in order to confirm if the task is being triggered by Octopus or by a user?

Example:

Let me know if you are able to find some examples in the Audit log at your earliest convenience.

Best Regards,
Donny

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?

Hi @ShannonN,

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:

Let me know what you are able to find at your earliest convenience.

Best Regards,
Donny

Awesome. Appreciate the help. Will respond as soon as I’m able to run some tests

1 Like

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.

1 Like

Hi @ShannonN,

No worries. Thanks for getting back to me.

If there is anything else we can assist with, please don’t hesitate to ask.

Best Regards,
Donny

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