Remove-DbaAgListener - Honor the AvailabilityGroup filter - #10609
Open
andreasjordan wants to merge 2 commits into
Open
Remove-DbaAgListener - Honor the AvailabilityGroup filter#10609andreasjordan wants to merge 2 commits into
andreasjordan wants to merge 2 commits into
Conversation
…Listener The parameter was declared and documented but never used, so a removal scoped to one availability group removed the named listener from whatever availability group it belonged to. The regression test scopes a removal to a second availability group and asserts the listener of the first one survives. Found via static analysis by @greenmtnsun in #10607. (do Remove-DbaAgListener)
…oes not require The error text told the user to specify one or more availability groups, but the condition only ever required -Listener. The AvailabilityGroup parameter is an optional filter. (do Remove-DbaAgListener)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Remove-DbaAgListenerdeclares and documents-AvailabilityGroup("Filters listener removal to only those within the specified availability groups") but never uses it. The internalGet-DbaAgListenercall only received-Listener, so a removal scoped to one availability group removed the named listener regardless of which availability group it belonged to.What changed
The
-AvailabilityGroupparameter is now passed through toGet-DbaAgListener, which already supported it. The call was converted to a splat per the style guide.A follow-up commit also corrects the
-SqlInstancevalidation message, which demanded "one or more Availability Groups" although the check only requires-Listener.What deliberately did not change
The pipeline path (
-InputObject) is untouched: piped listener objects are already the caller's explicit selection.Tests
Added a regression test that creates a second availability group, scopes the removal of the first group's listener to that second group, and asserts nothing is returned and the listener survives. Verified against the lab HADR instance (SQL Server 2025): the new test fails on the old code with exactly the reported behavior (
Status=Removedfor the out-of-scope listener) and the full file passes with the fix (3/3).Same defect shape as #10608. Found by @greenmtnsun via static analysis, reported in #10607.
🤖 Generated with Claude Code