Make Lite FinOps AG-aware (#980)#985
Merged
Merged
Conversation
…a role (#980) FinOps treated SERVERPROPERTY('Edition') as the whole story. On an Availability Group readable secondary it reported Enterprise and recommended "downgrade to Standard, save $X/mo" - advice that can't be acted on, since every replica in an AG must run the same edition. - GetAgReplicaRoleAsync detects Primary / Secondary / Standalone via sys.dm_hadr_availability_replica_states. The DMV is referenced only inside OBJECT_ID-guarded dynamic SQL, so it is safe on Azure SQL Database and non-AG instances (both report Standalone). - GetRecommendationsAsync: on an Enterprise AG secondary it now emits an informational note - edition/licensing decisions apply to the whole AG and should be evaluated on the primary - instead of the downgrade recommendations and savings estimates. - GetServerPropertiesLiveAsync returns the replica role, surfaced as an "AG Role" column in the FinOps server inventory grid. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Split out from #976. Lite's FinOps determined the SQL Server edition with
SERVERPROPERTY('Edition')and nothing else. On an Availability Group readable secondary that returns "Enterprise Edition" just like the primary, so FinOps:Change
GetAgReplicaRoleAsync— detectsPrimary/Secondary/Standalonefromsys.dm_hadr_availability_replica_states. The DMV is referenced only insideOBJECT_ID-guarded dynamic SQL, so the batch stays valid on Azure SQL Database and non-AG instances (both returnStandalone).GetRecommendationsAsync— on an Enterprise instance that is an AG secondary, it now emits a single informationalLicensingnote ("edition/licensing decisions apply to the whole AG, evaluate on the primary; a passive secondary may be SA-covered") instead of the downgrade recommendations and savings estimates.GetServerPropertiesLiveAsync— also returns the replica role, surfaced as a new AG Role column in the FinOps server inventory grid (ServerPropertyRow.AgReplicaRole/AgReplicaRoleDisplay).Test plan
dotnet build Lite/PerformanceMonitorLite.csproj -c Debug— full rebuild, 0 warnings, 0 errors.GetServerPropertiesLiveAsyncbatch were run against SQL Server 2016, 2019, and 2022 — all returnStandaloneon these non-AG instances with no errors, confirming theOBJECT_IDguard and the combined batch are valid across versions.Secondarypath could not be exercised (no AG in the test environment); the role logic (MAX(CASE role = 1/2 …)overis_local = 1) is standard.🤖 Generated with Claude Code