Skip to content

Add support for managing cluster capacity policy #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 44 commits into from
Jul 2, 2025

Conversation

ashleyvansp
Copy link
Contributor

@ashleyvansp ashleyvansp commented Jun 23, 2025

Overview

This pull request introduces the functionality to manage cluster configuration changes. Previously, KustoSchemaTools only managed database-level changes such as tables and permissions. The first supported cluster configuration feature is capacity policies.
See the README for more details about how it works.

Coming in follow-up PRs:

  • The KustoClusterOrchestrator apply() method which executes the scripts generated in the "diff" step
  • KustoSchemaToolsAction changes to make the orchestrator available in a GitHub Action
  • Managing cluster workload groups

https://github.com/github/data/issues/9010

@Copilot Copilot AI review requested due to automatic review settings June 23, 2025 20:29
Copilot

This comment was marked as outdated.

ashleyvansp and others added 3 commits July 2, 2025 16:23
….Combine

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@ashleyvansp ashleyvansp requested a review from Copilot July 2, 2025 17:44
Copy link

@Copilot 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 PR adds support for managing Kusto cluster capacity policies by extending the existing YAML and live-cluster handlers, models, and change orchestration to include capacityPolicy definitions and diff generation.

  • Introduces YamlClusterHandler and factory to parse capacityPolicy from YAML.
  • Adds KustoClusterHandler and factory to load live cluster capacity policies via control commands.
  • Extends orchestrator, change models, and tests to detect, report, and script capacityPolicy changes.

Reviewed Changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
KustoSchemaTools/Parser/YamlClusterHandlerFactory.cs Added factory class for YAML handler
KustoSchemaTools/Parser/YamlClusterHandler.cs Implemented async loading of clusters with capacityPolicy from YAML
KustoSchemaTools/Parser/KustoClusterHandlerFactory.cs Added factory using DI for creating live-cluster handler
KustoSchemaTools/Parser/IKustoClusterHandlerFactory.cs Introduced interface for Kusto handler factory
KustoSchemaTools/Parser/KustoClusterHandler.cs Implemented async loading of live cluster capacity policy
KustoSchemaTools/Model/ClusterCapacityPolicy.cs Added model and nested capacity classes for cluster policies
KustoSchemaTools/Model/Cluster.cs Extended Cluster to include optional CapacityPolicy
KustoSchemaTools/KustoClusterOrchestrator.cs Updated orchestrator to generate and sequence capacityPolicy diffs
KustoSchemaTools/Changes/PolicyChange.cs Added generic PolicyChange<T> type for policy diffs
KustoSchemaTools/Changes/ClusterChanges.cs Added reflection-based comparison and script generation for policies
KustoSchemaTools/Changes/ClusterChangeSet.cs Extended change set to aggregate policy change scripts
KustoSchemaTools.Tests/Parser/YamlClusterHandlerTests.cs Added tests covering YAML loading, missing/invalid files
KustoSchemaTools.Tests/KustoClusterOrchestratorTests.cs Extended orchestrator tests to cover capacityPolicy scenarios
KustoSchemaTools.Tests/DemoData/ClusterScopedChanges/multipleClusters.yml Sample YAML with multiple clusters and capacityPolicy definitions
KustoSchemaTools.Tests/Changes/ClusterChangesTest.cs Added tests for detecting policy changes in ClusterChanges
Comments suppressed due to low confidence (2)

KustoSchemaTools/Parser/KustoClusterHandler.cs:48

  • Add unit tests for KustoClusterHandler.LoadAsync to cover edge cases such as no rows returned, empty or malformed policy JSON, and ensure CapacityPolicy is set appropriately or remains null.
            catch (System.Exception ex)

KustoSchemaTools/Changes/ClusterChanges.cs:38

  • [nitpick] The entityName for policy changes is hardcoded as "default". Consider using a meaningful identifier or passing the actual policy name to improve clarity in change markdown.
                    "default",

@ashleyvansp ashleyvansp changed the title [WIP] manage cluster capacity policy via KST Add support for managing cluster capacity policy Jul 2, 2025
@ashleyvansp ashleyvansp merged commit 4e13ed2 into main Jul 2, 2025
5 checks passed
@ashleyvansp ashleyvansp deleted the ashleyvansp/capacityPolicy branch July 2, 2025 21:07
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.

2 participants