OctopusDeploy / OctopusDSC

| Public | A PowerShell DSC resource for installing Octopus Deploy & Tentacles
Other
1 stars 60 forks source link

cTentacleAgent test on workerpool membership fails when node is a member of only one workerpool #245

Closed JoshuaJSwain closed 4 years ago

JoshuaJSwain commented 4 years ago

Description The cTentacleAgent.psm1 module appears to have a bug on line #562. When a tentacle is a member of only one worker pool the count is always null. The Test will always fail and it causes the installation to run every time the resource is invoked.

$workerPoolMembership = Get-WorkerPoolMembership -ServerUrl $OctopusServerUrl -ApiKey $ApiKey -Thumbprint $tentacleThumbprint

if ($WorkerPools.Count -ne $workerPoolMembership.Count) change to if ($WorkerPools.Count -ne $workerPoolMembership.id.Count)

Environment running dsc module under puppet and tested locally on server2012r2

How to reproduce Import-Module C:\temp\OctopusDSC\DSCResources\cTentacleAgent\cTentacleAgent.psm1

Test-TargetResource -Ensure $ensure -Name $Name -State $state -ApiKey $ApiKey -OctopusServerUrl $OctopusServerUrl -DisplayName $displayname -Environments $environments -Roles $roles -tentacleDownloadUrl64 $tentacledownloadurl64 ` -PublicHostNameConfiguration $publichostnameconfiguration -registerwithserver $registerwithserver -octopusserverthumbprint $octopusserverthumbprint -tentacleservicecredential $tentacleservicecredential -WorkerPools $WorkerPools -Verbose

clipped output for brevity: VERBOSE: Worker pool counts do not match, not in desired state. False

matt-richardson commented 4 years ago

Sorry, @JoshuaJSwain, I had a lot of trouble reproducing this. For starters, I'm not sure which version you're on. It might have been version v4.0.689? Does it still happen in the latest version? Also, the example you've given doesn't actually provide any values for the parameters, so it doesn't help reproduce, unfortunately. Nor does it show what the value is on the server.

While investigating, i found a few issues where it tried to treat the worker as a normal deployment target, which wouldn't have worked anyway, so I've fixed that... Hopefully it fixes the issue for you.