Skip to content

feat(crud-machine): AKS Machine API client + CRUD layer + CLI - #1187

Merged
Karen Chen (karenychen) merged 3 commits into
mainfrom
feat/aks-machine-client
May 22, 2026
Merged

Karen Chen (karenychen) merged 3 commits into
mainfrom
feat/aks-machine-client

Conversation

@karenychen

@karenychen Karen Chen (karenychen) commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

Port the k8s-cluster-crud-machine perf-test code path from ado-telescope.

This PR is the Python-only foundation. Scenario YAMLs, step templates, terraform inputs, and the staging pipeline land in follow-up PRs.

Layers in this change

AKSMachineClient (modules/python/clients/aks_machine_client.py)

Subclasses AKSClient. Drives the AKS Machine API (api-version=2025-06-02-preview):

  • create_machine_agentpool (mode=Machines)
  • PUT machine (single) and BatchPutMachine (multi)
  • Agentpool provisioning wait
  • Percentile-based node-readiness wait

BatchPutMachine uses the HEADER pattern with a shared requests.Session + sized urllib3 pool (HTTPAdapter(pool_maxsize=64)) so 64 concurrent workers do not starve. 429 retries with exponential backoff (1s / 2s / 4s / 8s, max 5). Per-request timeout cap.

Hard gate: all nodes must reach Ready within readiness_wait_timeout. All reached percentiles (P50/P70/P90/P99/P100) are recorded in percentile_node_readiness_times metadata for trending.

MachineCRUD (modules/python/crud/azure/machine_crud.py)

Thin facade that constructs an AKSMachineClient and exposes create_machine_agentpool / scale_machine for the CLI.

CLI (modules/python/crud/main.py)

New create-machine and scale-machine subcommands. Azure-only today; AWS/GCP do not expose an equivalent Machine API. Existing CRUD subcommands are unchanged.

Tests (43 new)

  • tests/test_aks_machine_client.py — 28 tests: single-PUT, batch chunking, 429 retry, pool sizing, percentile envelope
  • tests/test_machine_crud.py — 15 tests on the facade
  • tests/test_crud_main.py — CLI dispatch coverage for both new subcommands

CI gates (local)

  • pylint 10.00/10 on all touched files
  • pytest --cov=. --cov-fail-under=80 from modules/python/: 736 passed, 1 skipped, 83.47% coverage

Integration evidence

The full stack (this PR + follow-up YAML/tfvars PRs) was exercised on staging pipeline Run 67988, all 3 stages green (1×1 non-batch, 50×50 non-batch, 200×4 batch).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Python-based foundation for AKS “Machine API” perf-test operations by introducing a dedicated Machine API client, a thin CRUD facade, and CLI wiring, along with unit tests validating key behaviors (including P99 readiness gating and HTTP session pool sizing).

Changes:

  • Introduces AKSMachineClient to drive Machine API create/scale flows, including a sized requests connection pool and P99-based readiness gating (P100 recorded but not a hard failure gate).
  • Adds MachineCRUD as a thin Azure CRUD facade and extends crud/main.py with create-machine and scale-machine subcommands plus dispatch logic.
  • Adds unit tests covering the new client behaviors, CRUD facade forwarding/error-swallowing, and CLI dispatch/tag parsing.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
modules/python/clients/aks_machine_client.py Adds HTTP session pool sizing and changes readiness hard-gate from P100 to P99 (logging P100 as best-effort).
modules/python/crud/azure/machine_crud.py New Azure Machine CRUD facade wrapping AKSMachineClient for CLI consumption.
modules/python/crud/main.py Adds Machine API CLI subcommands and dispatch path.
modules/python/tests/test_aks_machine_client.py Adds tests for P99/P100 readiness semantics and session adapter pool sizing.
modules/python/tests/test_machine_crud.py Adds tests for MachineCRUD forwarding/defaults/exception swallowing.
modules/python/tests/test_crud_main.py Adds tests for Machine CLI dispatch, exit-code semantics, and --tags JSON parsing.

Comment thread modules/python/crud/main.py Resolved
Comment thread modules/python/crud/main.py Resolved
Comment thread modules/python/crud/main.py Resolved
Comment thread modules/python/crud/main.py Resolved
@karenychen

Copy link
Copy Markdown
Contributor Author

Code review

Found 1 issue:

  1. The PR removes the existing deployment subcommand registration while handle_workload_operations() still expects to handle command == "deployment". Existing crud/main.py deployment ... invocations will now fail argparse as an unknown command instead of reaching the workload CRUD path.

all_parser.set_defaults(func=handle_node_pool_operation)
# Create-machine command (AKS Machine API)
create_machine_parser = subparsers.add_parser(
"create-machine",
parents=[common_parser],
help="Create a machine-mode agent pool via the AKS Machine API",
)
create_machine_parser.add_argument(
"--node-pool-name", required=True, help="Agent pool name"
)
create_machine_parser.add_argument(
"--vm-size", required=True, help="VM size for the agent pool"
)
create_machine_parser.set_defaults(func=handle_machine_operation)
# Scale-machine command (AKS Machine API)
scale_machine_parser = subparsers.add_parser(
"scale-machine",
parents=[common_parser],
help="Add N machines to a machine-mode agent pool via the AKS Machine API",
)
scale_machine_parser.add_argument(
"--node-pool-name", required=True, help="Agent pool name"
)
scale_machine_parser.add_argument(
"--vm-size", required=True, help="VM size for the new machines"
)
scale_machine_parser.add_argument(
"--scale-machine-count",
type=int,
default=0,
help="Number of machines to add to the agent pool",
)
scale_machine_parser.add_argument(
"--machine-workers",
type=int,
default=1,
help="Concurrent worker count for individual machine PUTs",
)
scale_machine_parser.add_argument(
"--use-batch-api",
action="store_true",
help="Use the BatchPutMachine API (chunked, single PUT per chunk)",
)
scale_machine_parser.add_argument(
"--readiness-wait-timeout",
type=int,
default=1200,
help="Seconds to wait for nodes to become Ready after PUT",
)
scale_machine_parser.add_argument(
"--tags",
default=None,
help="JSON-encoded tag map (currently ignored by the Machine API)",
)
scale_machine_parser.add_argument(
"--region",
default=None,
help="Region label (used only for telemetry)",
)
scale_machine_parser.set_defaults(func=handle_machine_operation)
# Arguments provided, run node pool operations and collect benchmark results

Port the k8s-cluster-crud-machine perf-test code path from
ado-telescope. This PR is the Python-only foundation; scenario YAMLs,
step templates, terraform inputs, and the staging pipeline land in
follow-up PRs.

Layers in this change:

* AKSMachineClient (modules/python/clients/aks_machine_client.py)
  Subclasses AKSClient. Drives the AKS Machine API
  (api-version 2025-06-02-preview): create-machine agentpool,
  PUT/BatchPutMachine, agentpool provisioning wait, percentile-based
  node-readiness wait. BatchPutMachine HEADER pattern with shared
  Session + sized urllib3 pool (HTTPAdapter pool_maxsize=64) so 64
  concurrent workers do not starve. 429 retries with exponential
  backoff (1s/2s/4s/8s, max 5). Per-request timeout cap. Hard gate
  requires all nodes Ready within readiness_wait_timeout; all
  reached percentiles (P50/P70/P90/P99/P100) are emitted to
  metadata ('percentile_node_readiness_times') for trending.

* MachineCRUD (modules/python/crud/azure/machine_crud.py)
  Thin facade that constructs an AKSMachineClient and exposes
  create_machine_agentpool / scale_machine for the CLI.

* CLI (modules/python/crud/main.py)
  New 'create-machine' and 'scale-machine' subcommands. Azure-only
  today; AWS/GCP do not expose an equivalent Machine API.
  Existing CRUD subcommands are unchanged.

Tests (43 new):
  - tests/test_aks_machine_client.py: 28 tests covering single-PUT,
    batch chunking, 429 retry, pool sizing, percentile envelope.
  - tests/test_machine_crud.py: 15 tests on the facade.
  - tests/test_crud_main.py: CLI dispatch coverage for both new
    subcommands.

CI gates (local):
  - pylint 10.00/10 on all touched files
  - pytest --cov=. --cov-fail-under=80 from modules/python/:
    736 passed, 1 skipped, 83.47% coverage
Comment thread modules/python/crud/main.py Resolved
- Make --scale-machine-count required (no default=0)
- Remove unused --region flag (REGION env var already feeds telemetry)
- Refactor handle_machine_operation to kwargs-dict pattern
  matching handle_node_pool_operation
- Extract scale-machine subparser into _add_scale_machine_subparser
  helper
- Explicit return True in create_machine_agentpool and scale_machine
  wrappers to match docstring contract
@karenychen
Karen Chen (karenychen) merged commit 8b5eae4 into main May 22, 2026
3 checks passed
@karenychen
Karen Chen (karenychen) deleted the feat/aks-machine-client branch May 22, 2026 07:39
Karen Chen (karenychen) added a commit that referenced this pull request May 27, 2026
…eline

Add scenario, topology, engine step, and pipeline file to exercise the
AKS Machine API CLI (`create-machine` and `scale-machine`, shipped
in PR #1187) end-to-end in the Telescope CI.

Design choices (Option 2 hybrid, intentional divergence from
ado-telescope):
  * Reuse the existing `crud` engine instead of introducing a new
    `raw` engine path; mirror PR #1187's separate subcommands so
    create and scale are two discrete observable pipeline steps.
  * New scenario `scenarios/perf-eval/k8s-cluster-crud-machine/`
    with `default_node_pool = null` (the Machines-mode pool is
    born via the ARM PUT performed by `create-machine`).
  * System pool is injected at job time via the existing
    `SYSTEM_NODE_POOL` plumbing in
    `steps/terraform/set-input-variables-azure.yml`.
  * New topology folder `steps/topology/k8s-crud-machine/` mirroring
    the `k8s-crud-gpu` shape (validate-resources / execute-crud /
    collect-crud).
  * New sibling engine step `steps/engine/crud/k8s/execute-machine.yml`
    that does NOT modify the existing `execute.yml`.
  * Teardown via terraform destroy only (no CLI delete step today).
  * Region: westus2.
  * `use_batch_api` is gated at the bash level (matching the
    ado-telescope idiom) because the matrix value is a runtime variable
    and ADO template conditionals run at compile time.
Karen Chen (karenychen) added a commit that referenced this pull request May 27, 2026
…eline

Add scenario, topology, engine step, and pipeline file to exercise the
AKS Machine API CLI (`create-machine` and `scale-machine`, shipped
in PR #1187) end-to-end in the Telescope CI.

Design choices (Option 2 hybrid, intentional divergence from
ado-telescope):
  * Reuse the existing `crud` engine instead of introducing a new
    `raw` engine path; mirror PR #1187's separate subcommands so
    create and scale are two discrete observable pipeline steps.
  * New scenario `scenarios/perf-eval/k8s-cluster-crud-machine/`
    with `default_node_pool = null` (the Machines-mode pool is
    born via the ARM PUT performed by `create-machine`).
  * System pool is injected at job time via the existing
    `SYSTEM_NODE_POOL` plumbing in
    `steps/terraform/set-input-variables-azure.yml`.
  * New topology folder `steps/topology/k8s-crud-machine/` mirroring
    the `k8s-crud-gpu` shape (validate-resources / execute-crud /
    collect-crud).
  * New sibling engine step `steps/engine/crud/k8s/execute-machine.yml`
    that does NOT modify the existing `execute.yml`.
  * Teardown via terraform destroy only (no CLI delete step today).
  * Region: westus2.
  * `use_batch_api` is gated at the bash level (matching the
    ado-telescope idiom) because the matrix value is a runtime variable
    and ADO template conditionals run at compile time.
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.

3 participants