From 7f1a53d1f8fa9a200682af18713e4024e5501008 Mon Sep 17 00:00:00 2001 From: Chris Hill <53898223+Borgquite@users.noreply.github.com> Date: Thu, 18 Apr 2024 21:57:52 +0100 Subject: [PATCH] DFSReplicationGroup - update PrimaryMember to write-only but not test (#138) * Do not test PrimaryMember * Update description for PrimaryMember * Update PrimaryMember mismatch message * Update PrimaryMember unit test * Update CHANGELOG.md * Update README.md * Update style * Style tweaks --- CHANGELOG.md | 5 +++++ .../DSC_DFSReplicationGroupMembership.psm1 | 9 ++++++--- .../DSC_DFSReplicationGroupMembership.schema.mof | 2 +- .../DSC_DFSReplicationGroupMembership/README.md | 3 +++ .../en-US/DSC_DFSReplicationGroupMembership.strings.psd1 | 2 +- tests/Unit/DSC_DFSReplicationGroupMembership.Tests.ps1 | 5 +++-- 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f63fcc3..6ad12ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + + - DFSReplicationGroupMembership + - Make PrimaryMember write-only when testing resources - fixes [Issue #58](https://github.com/dsccommunity/DFSDsc/issues/58). + ## [5.1.0] - 2024-03-02 ### Added diff --git a/source/DSCResources/DSC_DFSReplicationGroupMembership/DSC_DFSReplicationGroupMembership.psm1 b/source/DSCResources/DSC_DFSReplicationGroupMembership/DSC_DFSReplicationGroupMembership.psm1 index eff8777..6eb0f0c 100644 --- a/source/DSCResources/DSC_DFSReplicationGroupMembership/DSC_DFSReplicationGroupMembership.psm1 +++ b/source/DSCResources/DSC_DFSReplicationGroupMembership/DSC_DFSReplicationGroupMembership.psm1 @@ -167,7 +167,7 @@ function Get-TargetResource .PARAMETER PrimaryMember Used to configure this as the Primary Member. Every folder must have at least one primary member for initial replication to take - place. + place. Only set during initial creation of membership. .PARAMETER DfsnPath Specify the DFS Namespace folder path of the membership. This value does not affect replication. @@ -307,7 +307,7 @@ function Set-TargetResource .PARAMETER PrimaryMember Used to configure this as the Primary Member. Every folder must have at least one primary member for initial replication to take - place. + place. Only set during initial creation of membership. .PARAMETER DfsnPath Specify the DFS Namespace folder path of the membership. This value does not affect replication. @@ -534,7 +534,10 @@ function Test-TargetResource -f $GroupName,$FolderName,$ComputerName ) -join '' ) - $desiredConfigurationMatch = $false + <# + See https://techcommunity.microsoft.com/t5/storage-at-microsoft/the-primary-member-in-dfs-replication/ba-p/423127 + Do not flag as a change required as flag is cleared after initial sync + #> } # if # Check the DfsnPath diff --git a/source/DSCResources/DSC_DFSReplicationGroupMembership/DSC_DFSReplicationGroupMembership.schema.mof b/source/DSCResources/DSC_DFSReplicationGroupMembership/DSC_DFSReplicationGroupMembership.schema.mof index aed6a0f..35eec68 100644 --- a/source/DSCResources/DSC_DFSReplicationGroupMembership/DSC_DFSReplicationGroupMembership.schema.mof +++ b/source/DSCResources/DSC_DFSReplicationGroupMembership/DSC_DFSReplicationGroupMembership.schema.mof @@ -13,7 +13,7 @@ class DSC_DFSReplicationGroupMembership : OMI_BaseResource [Write, Description("The local conflict and deleted path quota size in MB.")] UInt32 ConflictAndDeletedQuotaInMB; [Write, Description("Specify if this content path should be read only.")] Boolean ReadOnly; [Write, Description("Specify if a member computer deletes files and folders immediately following inbound replication.")] Boolean RemoveDeletedFiles; - [Write, Description("Used to configure this as the Primary Member. Every folder must have at least one primary member for initial replication to take place.")] Boolean PrimaryMember; + [Write, Description("Used to configure this as the Primary Member. Every folder must have at least one primary member for initial replication to take place. Only set during initial creation of membership.")] Boolean PrimaryMember; [Write, Description("Specify the DFS Namespace folder path of the membership. This value does not affect replication.")] String DfsnPath; [Write, Description("The name of the AD Domain the DFS Replication Group this replication group is in.")] String DomainName; }; diff --git a/source/DSCResources/DSC_DFSReplicationGroupMembership/README.md b/source/DSCResources/DSC_DFSReplicationGroupMembership/README.md index 8365f5b..0ac5e9b 100644 --- a/source/DSCResources/DSC_DFSReplicationGroupMembership/README.md +++ b/source/DSCResources/DSC_DFSReplicationGroupMembership/README.md @@ -5,3 +5,6 @@ usually used to set the **ContentPath** for each Replication Group folder on eac Member computer. It can also be used to set additional properties of the Membership. This resource shouldn't be used for folders where the Content Path is set in the DFSReplicationGroup. + +> Note: The PrimaryMember flag is automatically cleared by DFS once an initial +> replication sync takes place, so is not tested by this resource. diff --git a/source/DSCResources/DSC_DFSReplicationGroupMembership/en-US/DSC_DFSReplicationGroupMembership.strings.psd1 b/source/DSCResources/DSC_DFSReplicationGroupMembership/en-US/DSC_DFSReplicationGroupMembership.strings.psd1 index ec0347f..f112312 100644 --- a/source/DSCResources/DSC_DFSReplicationGroupMembership/en-US/DSC_DFSReplicationGroupMembership.strings.psd1 +++ b/source/DSCResources/DSC_DFSReplicationGroupMembership/en-US/DSC_DFSReplicationGroupMembership.strings.psd1 @@ -13,6 +13,6 @@ ConvertFrom-StringData @' ReplicationGroupMembershipConflictAndDeletedMismatchMessage = DFS Replication Group "{0}" folder "{1}" on "{2}" has incorrect ConflictAndDeletedQuotaInMB. Change required. ReplicationGroupMembershipReadOnlyMismatchMessage = DFS Replication Group "{0}" folder "{1}" on "{2}" has incorrect ReadOnly. Change required. ReplicationGroupMembershipRemoveDeletedFilesMismatchMessage = DFS Replication Group "{0}" folder "{1}" on "{2}" has incorrect RemoveDeletedFiles. Change required. - ReplicationGroupMembershipPrimaryMemberMismatchMessage = DFS Replication Group "{0}" folder "{1}" on "{2}" has incorrect PrimaryMember. Change required. + ReplicationGroupMembershipPrimaryMemberMismatchMessage = DFS Replication Group "{0}" folder "{1}" on "{2}" has incorrect PrimaryMember. Ignoring as flag clears after initial sync. ReplicationGroupMembershipDfsnPathMismatchMessage = DFS Replication Group "{0}" folder "{1}" on "{2}" has incorrect DfsnPath. Change required. '@ diff --git a/tests/Unit/DSC_DFSReplicationGroupMembership.Tests.ps1 b/tests/Unit/DSC_DFSReplicationGroupMembership.Tests.ps1 index f29b26a..0780bfc 100644 --- a/tests/Unit/DSC_DFSReplicationGroupMembership.Tests.ps1 +++ b/tests/Unit/DSC_DFSReplicationGroupMembership.Tests.ps1 @@ -541,11 +541,12 @@ try Context 'Replication group membership exists but has different PrimaryMember' { Mock Get-DfsrMembership -MockWith { return @($mockReplicationGroupMembership) } - It 'Should return false' { + # Return *true* - should not flag as changed required as cleared after initial sync + It 'Should return true' { $splat = $replicationGroupMemberships[0].Clone() $splat.Remove('ConflictAndDeletedPath') $splat.PrimaryMember = (-not $splat.PrimaryMember) - Test-TargetResource @splat | Should -BeFalse + Test-TargetResource @splat | Should -BeTrue } It 'Should call expected Mocks' {