Repository navigation
feat(crud): add AKSMachineClient subclass for AKS Machine API - #1178
Karen Chen (karenychen) wants to merge 2 commits into
Conversation
First slice of the AKS Machine API CRUD perf-test port from ado-telescope
to gh-telescope. Adds a new `AKSMachineClient(AKSClient)` subclass that
adds raw REST methods for the AKS Machine API (not yet exposed in the
Azure SDK). Subsequent PRs will add the CRUD orchestrator
(`crud/azure/machine_crud.py`), the CLI subcommands in `crud/main.py`,
scenario terraform inputs, and the pipeline templates.
## What this PR adds
- `modules/python/clients/aks_machine_client.py`:
- `class AKSMachineClient(AKSClient)`: subclass to inherit auth,
ContainerServiceClient, KubernetesClient, `get_cluster_name`,
`get_cluster_data`, and the existing node-pool CRUD methods.
- `create_machine_agentpool(agentpool_name, vm_size, cluster_name=None, timeout=300) -> bool`:
converts an existing agentpool to Machines mode via PUT.
- `scale_machine(agentpool_name, vm_size, scale_machine_count, ...) -> bool`:
adds N machines to a machine-mode agentpool, supports both
per-machine PUTs and the AKS BatchPutMachine header pattern.
- Both methods wrap their work in `OperationContext` exactly like
`AKSClient.create_node_pool` / `scale_node_pool`: opens context,
enriches with `op.add_metadata` along the way, returns True on
success, re-raises on failure so the context records the trace.
- `_wait_for_machine_node_readiness`: baseline-aware percentile
watcher returning ado-parity nested envelope keyed
P50/P70/P90/P99/P100. Each entry carries
`{target_nodes, elapsed_time_seconds, percentage, success}`.
- `modules/python/tests/test_aks_machine_client.py`: 9 tests covering
successful create/scale (batch and non-batch), PUT failure, agentpool
provisioning timeout, partial machine landing (raises RuntimeError),
baseline-count propagation to the readiness watcher, and the
ado-compatible machine-name prefix generator.
## Schema for downstream Kusto consumers
When `scale_machine` runs through `OperationContext`, the persisted
metadata dict includes:
`successful_machines`, `batch_command_execution_times` (when batch),
`percentile_node_readiness_times` (nested envelope),
`node_readiness_time` (= P100.elapsed_time_seconds),
`cluster_info`.
## Verification
- `pylint modules/python/clients/aks_machine_client.py modules/python/tests/test_aks_machine_client.py` -> 10.00/10.
- `pytest modules/python/tests/test_aks_machine_client.py` -> 9 passed.
- Full `modules/python/ pytest --cov=. --cov-fail-under=80` -> 702 passed, 81.24% coverage.
## Subsequent PRs
2. `feat(crud): add MachineCRUD orchestrator`
3. `feat(crud): add create-machine + scale-machine CLI subcommands`
4. `feat(crud-machine): scenario terraform inputs`
5. `feat(crud-machine): pipeline templates + production pipeline`
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a new AKSMachineClient to support raw REST CRUD operations against the AKS Machine API (not yet in Azure SDK), plus unit tests covering create/scale flows (batch + non-batch) and readiness/baseline behaviors.
Changes:
- Introduces
AKSMachineClient(AKSClient)with token caching, REST helpers, create-machine-agentpool, and scale-machine (batch + concurrent PUT paths). - Adds readiness percentile watcher that accounts for baseline ready-node count.
- Adds a new unit test suite validating success/failure scenarios and metadata enrichment.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| modules/python/clients/aks_machine_client.py | New Machine API client with REST plumbing, batch/non-batch scale, and readiness watcher. |
| modules/python/tests/test_aks_machine_client.py | New unit tests validating create/scale behaviors and helper parity. |
Changes: - scale_machine: raise RuntimeError on !agentpool_ok or P100 success=False instead of silently returning True - PUT machine status check: accept 202 Accepted (ARM async semantics) in addition to 200/201 - _scale_machine_individually: clamp ThreadPoolExecutor workers to max(1, request.machine_workers) to prevent ValueError on <=0 - _scale_machine_individually docstring: clarify per-machine provisioningState is intentionally not polled (parity with batch path) - tests: replace hardcoded /tmp/test_results + os.makedirs with tempfile.TemporaryDirectory + tearDown cleanup - strip provenance/mirroring comments across both files; keep only WHY-rationale comments
Changes: - scale_machine: raise RuntimeError on !agentpool_ok or P100 success=False instead of silently returning True - PUT machine status check: accept 202 Accepted (ARM async semantics) in addition to 200/201 - _scale_machine_individually: clamp ThreadPoolExecutor workers to max(1, request.machine_workers) to prevent ValueError on <=0 - _scale_machine_individually docstring: clarify per-machine provisioningState is intentionally not polled (parity with batch path) - tests: replace hardcoded /tmp/test_results + os.makedirs with tempfile.TemporaryDirectory + tearDown cleanup - strip provenance/mirroring comments across both files; keep only WHY-rationale comments
|
Closing in favor of #1179, which splits this work into smaller reviewable pieces. #1179 contains the scaffolding half of this PR: Thanks for the review here — all five substantive findings have been preserved and are already merged into the scaffolding branch / queued for PR-2. |
First slice of the AKS Machine API CRUD perf-test port from ado-telescope to gh-telescope. Adds a new `AKSMachineClient(AKSClient)` subclass with raw REST methods for the AKS Machine API (not yet exposed in the Azure SDK).
Subsequent PRs will add: (2) the CRUD orchestrator `crud/azure/machine_crud.py`, (3) the CLI subcommands in `crud/main.py`, (4) scenario terraform inputs, and (5) the pipeline templates / production pipeline.
What this PR adds
`modules/python/clients/aks_machine_client.py` (new)
`modules/python/tests/test_aks_machine_client.py` (new, 9 tests)
Persisted metadata schema
When `scale_machine` runs through `OperationContext`, the persisted operation_info metadata dict includes:
`successful_machines`, `batch_command_execution_times` (when batch), `percentile_node_readiness_times` (nested envelope), `node_readiness_time` (= P100.elapsed_time_seconds), `cluster_info`.
Verification
Subsequent PRs in this stack
End-to-end validated on staging pipeline 23 against AKS sub `854c9ddb-...` in westus2.