Skip to content

Make Lite FinOps AG-aware (#980)#985

Merged
erikdarlingdata merged 1 commit into
devfrom
feature/980-finops-ag-secondary
May 22, 2026
Merged

Make Lite FinOps AG-aware (#980)#985
erikdarlingdata merged 1 commit into
devfrom
feature/980-finops-ag-secondary

Conversation

@erikdarlingdata
Copy link
Copy Markdown
Owner

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:

  • recommended "Enterprise → Standard would save ~$X/mo" on a replica whose edition can't be changed independently — every replica in an AG must run the same edition; and
  • gave no indication in the inventory that the instance was a secondary at all.

Change

  • GetAgReplicaRoleAsync — detects Primary / Secondary / Standalone from sys.dm_hadr_availability_replica_states. The DMV is referenced only inside OBJECT_ID-guarded dynamic SQL, so the batch stays valid on Azure SQL Database and non-AG instances (both return Standalone).
  • GetRecommendationsAsync — on an Enterprise instance that is an AG secondary, it now emits a single informational Licensing note ("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.
  • The AG-role T-SQL and the full modified GetServerPropertiesLiveAsync batch were run against SQL Server 2016, 2019, and 2022 — all return Standalone on these non-AG instances with no errors, confirming the OBJECT_ID guard and the combined batch are valid across versions.
  • The Secondary path could not be exercised (no AG in the test environment); the role logic (MAX(CASE role = 1/2 …) over is_local = 1) is standard.

🤖 Generated with Claude Code

…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>
@erikdarlingdata erikdarlingdata merged commit 58eaada into dev May 22, 2026
2 checks passed
@erikdarlingdata erikdarlingdata deleted the feature/980-finops-ag-secondary branch May 22, 2026 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant