-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
xDFSReplicationGroup - Error while comparing array containing $null #27
Comments
Thanks @solbirn - I'll get this sorted this weekend. Thanks muchly for submitting this. |
Hi @solbirn - I've been looking into this error and I'm not sure it is caused by this problem. Looking at the error message it is reporting that the |
Hi @PlagueHO, Below is the config. I know this is the issue as I resolved in our environment by using a modified version of xDFS with Configuration DFSRConfig
{
Param
(
[String[]]
$NodeName = "localhost",
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[String]
$GroupName,
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[String[]]
$DFSMembers,
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[PSCredential]
$Credential,
[String]
$DomainName = $env:USERDNSDOMAIN
)
Import-DscResource -ModuleName PSDesiredStateConfiguration, xDFS
Node $NodeName
{
if($DFSMembers.Length -eq 2){
WaitForAll DomainJoin
{
ResourceName = "[xComputer]JoinDomain"
NodeName = $NodeName
RetryIntervalSec = 30
RetryCount = 0
}
WaitForAll WaitDCPromo
{
ResourceName = "[xADDomainController]NewDC"
NodeName = $NodeName
RetryIntervalSec = 30
RetryCount = 0
}
WindowsFeature InstallDFSR
{
Name = "FS-DFS-Replication"
Ensure = "Present"
}
WindowsFeature InstallDFSRTools
{
Name = "RSAT-DFS-Mgmt-Con"
Ensure = "Present"
}
xDFSReplicationGroup DFSRBackupReplicationGroup
{
GroupName = $GroupName
Description = "$GroupName "
Ensure = 'Present'
Members = $DFSMembers
Folders = 'SharedData','UserData'
DomainName = $DomainName
DependsOn = @("[WindowsFeature]InstallDFSR","[WindowsFeature]InstallDFSRTools","[WaitForAll]WaitDCPromo")
}
xDFSReplicationGroupConnection DFSRBackupReplicationConnectionSource
{
GroupName = $GroupName
Ensure = 'Present'
EnsureEnabled = 'Enabled'
SourceComputerName = $DFSMembers[0]
DestinationComputerName = $DFSMembers[1]
DependsOn = '[xDFSReplicationGroup]DFSRBackupReplicationGroup'
}
xDFSReplicationGroupConnection DFSRBackupReplicationConnectionDestination
{
GroupName = $GroupName
Ensure = 'Present'
EnsureEnabled = 'Enabled'
SourceComputerName = $DFSMembers[1]
DestinationComputerName = $DFSMembers[0]
DependsOn = '[xDFSReplicationGroup]DFSRBackupReplicationGroup'
}
xDFSReplicationGroupFolder DFSRBackupReplicationFolderSharedData
{
GroupName = $GroupName
FolderName = "SharedData"
Description = "Site specific shared data"
DependsOn = '[xDFSReplicationGroup]DFSRBackupReplicationGroup'
}
xDFSReplicationGroupFolder DFSRBackupReplicationFolderUserData
{
GroupName = $GroupName
FolderName = "UserData"
Description = "Site specific user data"
DependsOn = '[xDFSReplicationGroup]DFSRBackupReplicationGroup'
}
xDFSReplicationGroupMembership DFSRBackupReplicationMembershipSharedDataPrimary
{
GroupName = $GroupName
FolderName = 'SharedData'
ComputerName = $DFSMembers[0]
ContentPath = 'D:\SharedData'
PrimaryMember = $true
DependsOn = '[xDFSReplicationGroupFolder]DFSRBackupReplicationFolderSharedData'
}
xDFSReplicationGroupMembership DFSRBackupReplicationMembershipSharedDataSecondary
{
GroupName = $GroupName
FolderName = 'SharedData'
ComputerName = $DFSMembers[1]
ContentPath = "D:\$GroupName\SharedData"
PsDscRunAsCredential = $Credential
DependsOn = '[xDFSReplicationGroupMembership]DFSRBackupReplicationMembershipSharedDataPrimary'
}
xDFSReplicationGroupMembership DFSRBackupReplicationMembershipUserDataPrimary
{
GroupName = $GroupName
FolderName = 'UserData'
ComputerName = $DFSMembers[0]
ContentPath = 'D:\UserData'
PrimaryMember = $true
DependsOn = '[xDFSReplicationGroupFolder]DFSRBackupReplicationFolderUserData'
}
xDFSReplicationGroupMembership DFSRBackupReplicationMembershipUserDataSecondary
{
GroupName = $GroupName
FolderName = 'UserData'
ComputerName = $DFSMembers[1]
ContentPath = "D:\$GroupName\UserData"
PsDscRunAsCredential = $Credential
DependsOn = '[xDFSReplicationGroupMembership]DFSRBackupReplicationMembershipUserDataPrimary'
}
}
}
} |
Oh cool! Thank you @solbirn - that is much appreciated. I'll take a look into this this weekend! |
Hi @solbirn - I'm having trouble writing any unit/regression tests that replicate this issue. I'm also having trouble replicating this issue on any WS 2016 DFS servers. I'm a bit worried about making the change above because I'm not actually sure why it would actually work (I might be being dumb though). I've checked through this every way and I do think the error you're seeing might be being caused by something else. Could you answer the following questions for me to help me solve this: Sorry I haven't managed to figure this out yet. |
Just ran into this error, though I think I'm hitting the issue around line 630 where it checks for differences in membership. I have a dfs replication group with no existing members, and using DFSReplicationGroup resource to specify two members. The line My first thought would be to check if either I suppose if they're both null then it could be the same but not sure there's a use case for ensuring that a replication group has no members. |
Hi @murrahjm - do you know the version of Windows Server you are running? I was never able to replicate the issue so wasn't able to confirm if the fix would resolve it or not (e.g. I couldn't write tests to confirm this). |
I ran into the error against 2012r2 and 2016. Full disclosure, I'm actually
calling the resource from an ansible playbook, but it should amount to the
same thing since the error comes from compare-object.
When I saw it I had just created a new replication group from Powershell
with no members or folders or anything, then tried to configure it with the
dsc resource vs. creating it all from the resource.
On May 18, 2018 6:31 PM, "Daniel Scott-Raynsford" <[email protected]> wrote:
Hi @murrahjm <https://github.com/murrahjm> - do you know the version of
Windows Server you are running? I was never able to replicate the issue so
wasn't able to confirm if the fix would resolve it or not (e.g. I couldn't
write tests to confirm this).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#27 (comment)>,
or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AQ-wt2NQjpl0sxbPenCnDxv_RDJFuRmfks5tz1nbgaJpZM4NJLSF>
.
|
Hi @murrahjm - it should work being used in an Ansible playbook OK (or at least I'd want it to). So to confirm, you actually created the replication group as an empty group first with no members or anything manually and then ran the playbook? That is a scenario I didn't actually test so it may indeed cause an error. I'm just in the process of spinning up a DFS environment to do some other testing, so I'll check this scenario. |
Correct. Completely new group created via Powershell before running the
playbook. I forget the exact command but I think it was
new-dfsrreplicationgroup or something like that with just a name parameter.
…On Fri, May 18, 2018, 7:07 PM Daniel Scott-Raynsford < ***@***.***> wrote:
Hi @murrahjm <https://github.com/murrahjm> - it should work being used in
an Ansible playbook OK (or at least I'd want it to).
So to confirm, you actually created the replication group as an empty
group first with no members or anything manually and then ran the playbook?
That is a scenario I didn't actually test so it may indeed cause an error.
I'm just in the process of spinning up a DFS environment to do some other
testing, so I'll check this scenario.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#27 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AQ-wt7lUZNcwygekvwQW2UUWLLfUeJghks5tz2IxgaJpZM4NJLSF>
.
|
Also I have an update that fixes the null comparison issue if you'd like a pull request. Not sure how it fares against all the other scenarios but it should be relatively benign. |
Hi @murrahjm - sure - would be delighted to accept a PR (see https://github.com/PowerShell/DscResources/blob/master/CONTRIBUTING.md). But with a change like this it would be good to validate against the integration tests (https://github.com/PowerShell/DFSDsc/blob/dev/Tests/Integration/MSFT_DFSReplicationGroup.Integration.Tests.ps1). The integration tests do need to be run outside of AppVeyor CI because it needs two DFS server nodes to check against. I'm spinning up a test environment at the moment, so if you can submit your PR I can run some checks against the a real environment. |
Potentially solves dsccommunity#27. Add section to check for null values in existing member list or proposed member list before using compare-object. Also added same logic to the comparison of existing and proposed folder list.
I can confirm that I can replicate this now by taking a deployed Replication Group and removing all the members from it and then reapplying the config. I'm now going to make @murrahjm changes to my copy and check it resolves the issue without any regression of other functions. |
Potentially solves dsccommunity#27. Add section to check for null values in existing member list or proposed member list before using compare-object. Also added same logic to the comparison of existing and proposed folder list. style corrections add tests for null members and null folders correct issue number
In xDFSReplicationGroup
Test-TargetResource
the following code can set$ExistingFolders
to a@($null)
array when the replication group does not yet contain folders. This results in aParameterBindingValidation
exception while subsequently evaluating the Compare-Object just below it.Error message;
Can be resolved with:
$ExistingFolders = @((Get-DfsReplicatedFolder @Splat -ErrorAction Stop).FolderName) | where { $_ -ne $null }
The text was updated successfully, but these errors were encountered: