Skip to content

SqlAGReplica: fix SeedingMode check in Test-TargetResource#2099

Merged
johlju merged 1 commit intodsccommunity:mainfrom
cai-n:fix-seeding-mode-enum
Apr 29, 2025
Merged

SqlAGReplica: fix SeedingMode check in Test-TargetResource#2099
johlju merged 1 commit intodsccommunity:mainfrom
cai-n:fix-seeding-mode-enum

Conversation

@cai-n
Copy link
Copy Markdown
Contributor

@cai-n cai-n commented Apr 28, 2025

Pull Request (PR) description

  • SqlAG
    • Fix SeedingMode existence condition as AvailabilityReplicaSeedingMode is an enum.
  • SqlAGReplica
    • Fix SeedingMode existence condition as AvailabilityReplicaSeedingMode is an enum.

This Pull Request (PR) fixes the following issues

None

Task list

  • Added an entry to the change log under the Unreleased section of the
    file CHANGELOG.md. Entry should say what was changed and how that
    affects users (if applicable), and reference the issue being resolved
    (if applicable).
  • Resource documentation updated in the resource's README.md.
  • Resource parameter descriptions updated in schema.mof.
  • Comment-based help updated, including parameter descriptions.
  • Localization strings updated.
  • Examples updated.
  • Unit tests updated. See DSC Community Testing Guidelines.
  • Integration tests updated (where possible). See DSC Community Testing Guidelines.
  • Code changes adheres to DSC Community Style Guidelines.

This change is Reviewable

@cai-n cai-n requested review from a team and johlju as code owners April 28, 2025 13:39
@johlju
Copy link
Copy Markdown
Member

johlju commented Apr 28, 2025

@cai-n Since there is no issue linked to this PR, can you explain the need for this change and why it is necessary in your scenario? 🙂

@johlju johlju added the needs review The pull request needs a code review. label Apr 28, 2025
@johlju johlju requested a review from Copilot April 28, 2025 15:20
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request updates the changelog to document fixes for the SeedingMode existence condition in both SqlAG and SqlAGReplica.

  • Updated changelog entry for SqlAG to clarify the fix.
  • Updated changelog entry for SqlAGReplica to clarify the fix.
Files not reviewed (4)
  • source/DSCResources/DSC_SqlAG/DSC_SqlAG.psm1: Language not supported
  • source/DSCResources/DSC_SqlAGReplica/DSC_SqlAGReplica.psm1: Language not supported
  • tests/Unit/DSC_SqlAG.Tests.ps1: Language not supported
  • tests/Unit/DSC_SqlAGReplica.Tests.ps1: Language not supported

@cai-n
Copy link
Copy Markdown
Contributor Author

cai-n commented Apr 28, 2025

Hi, I was trying to change the a replica's seeding mode from automatic to manual and noticed that it didn't update the replica, but it worked if it was the other way around

@johlju
Copy link
Copy Markdown
Member

johlju commented Apr 28, 2025

Thank you. Have you tested that your change actually makes it possible to switch between both?

Also, unrelated to your PR and does need to be resolved here, but looking at this now, isn't this a bug:

If a Availability Group has Automatic as a seeding mode, and if the user does not provide the Seeding Mode parameter in the configuration, then the resource will change to Manual on the Availability Group because of the default value that will be used and enforced. 🤔

@cai-n
Copy link
Copy Markdown
Contributor Author

cai-n commented Apr 28, 2025

I've tried to change it from manual to automatic and back to manual and it updated correctly.
About the default, I think this line should skip the parameter check if it's not in the configuration and not trigger the update:

foreach ( $parameter in $PSBoundParameters.GetEnumerator() )

@johlju
Copy link
Copy Markdown
Member

johlju commented Apr 29, 2025

You are correct with the default value. Thank you. This is also handled with $submittedParameter in 'Set' if it would be called separately. So it seems that is not an issue. Cool, no need for an issue for that then. 🙂

if ( ( $submittedParameters -contains 'SeedingMode' ) -and ( $sqlMajorVersion -ge 13 ) -and ( $SeedingMode -ne $availabilityGroup.AvailabilityReplicas[$serverObject.DomainInstanceName].SeedingMode ) )

Copy link
Copy Markdown
Member

@johlju johlju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 5 of 5 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @cai-n)

@johlju
Copy link
Copy Markdown
Member

johlju commented Apr 29, 2025

Waiting for the tests to pass, then I merge.

@johlju johlju merged commit 6e9ed37 into dsccommunity:main Apr 29, 2025
56 checks passed
@johlju
Copy link
Copy Markdown
Member

johlju commented Apr 29, 2025

@cai-n thank you for this! 🙇‍♂️

@cai-n cai-n deleted the fix-seeding-mode-enum branch May 23, 2025 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs review The pull request needs a code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants