dsccommunity / SharePointDsc

The SharePointDsc PowerShell module provides DSC resources that can be used to deploy and manage a SharePoint farm
MIT License
245 stars 107 forks source link

SPDistributedCacheService: Add support for backgroundGC #1397

Open ChristophHannappel opened 2 years ago

ChristophHannappel commented 2 years ago

Resource proposal

The Article Installing Windows Server AppFabric updates SharePoint 2013 Servers recommends enabling the backgroundGC for the DistributedCacheService.exe via the DistributedCacheService.exe.config file.

Details Cumulative update package 3 for Microsoft AppFabric 1.1 for Windows Server.

SharePoint Subscription Edition enables this by default. All previous versions need to enable it manually. Since the SPDistributedCacheService has to run on every Node it would be a good fit, to add this to the ressource.

I can create a pull request, if this is the right ressource

Proposed properties

Property Type qualifier Data type Description Default value Allowed values
backgroundGC write boolean Should the DistributedCacheService use the nonblocking garbage collection (background server garbage collection) None $true, $false

Special considerations or limitations

Code Example

[system.reflection.assembly]::LoadWithPartialName("System.Configuration") | Out-Null

# intentionally leave off the trailing ".config" as OpenExeConfiguration will auto-append that
$configFilePath = "$env:ProgramFiles\AppFabric 1.1 for Windows Server\DistributedCacheService.exe"
$appFabricConfig = [System.Configuration.ConfigurationManager]::OpenExeConfiguration($configFilePath)

# if backgroundGC setting does not exist add it, else check if value is "false" and change to "true"
if($appFabricConfig.AppSettings.Settings.AllKeys -notcontains "backgroundGC")
{
    $appFabricConfig.AppSettings.Settings.Add("backgroundGC", "true")
}
elseif ($appFabricConfig.AppSettings.Settings["backgroundGC"].Value -eq "false")
{
    $appFabricConfig.AppSettings.Settings["backgroundGC"].Value = "true"
}

# save changes to config file
$appFabricConfig.Save()
ykuijs commented 2 years ago

Hi @ChristophHannappel, I agree that the SPDistributedCacheService resource indeed sounds like the best resource for this enhancement! I have assigned this issue to you!

ykuijs commented 2 years ago

Hi @ChristophHannappel, any idea when you are able to fix this issue?

ChristophHannappel commented 2 years ago

@ykuijs I think within the next 3 weeks. Ill have kinda working code and think creating a meaning full unit test is the largest challange for me