Skip to content

Refactor AKS client credential configuration - #1305

Merged
Diamond (diamondpowell) merged 4 commits into
mainfrom
dipowell/refactor-aks-client-credential
Sep 2, 2026
Merged

Diamond (diamondpowell) merged 4 commits into
mainfrom
dipowell/refactor-aks-client-credential

Conversation

@diamondpowell

@diamondpowell Diamond (diamondpowell) commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Context

This refactor separates Azure credential construction from AKSClient so callers can explicitly provide the credential they need while the CRUD wrappers use one shared configuration path. It enables the workload CRUD package and pipelines to authenticate without relying on credentials created implicitly inside the client.

After this merges, PR #1231 will be updated to consume the new AKSClient credential contract. PR #1305 must merge first.

Summary

  • move Azure credential construction into a shared configure_credential helper
  • require callers to inject credentials into AKSClient
  • update node pool and Machine API wrappers and tests for the new dependency boundary

Validation

  • 782 tests passed, 1 skipped; coverage 82.91%; pylint 10.00/10
  • Open-source pipeline build 78625 passed
  • Node pool CRUD: create, scale up, scale down, and delete succeeded
  • Machine API: agent pool creation succeeded and all 10 scaled machines reached P100 readiness

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

For reviewers only: reply /run-tf-integration to trigger the terraform integration pipeline before approving the PR.

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.

🟢 Approval recommended

Changes are cohesive, well-covered by updated tests, and no functional issues were found beyond a small documentation nit.

Pull request overview

Refactors Azure authentication so AKSClient no longer constructs credentials internally; instead, callers must inject an Azure credential while higher-level CRUD wrappers use a shared configure_credential helper to build a consistent default.

Changes:

  • Added utils.azure_auth.configure_credential() to centralize Azure credential construction.
  • Updated AKSClient to require an injected credential (removing implicit credential creation inside the client).
  • Updated Azure CRUD wrappers and unit tests to use/pin the new credential injection boundary.
File summaries
File Description
modules/python/utils/azure_auth.py Introduces shared helper to construct DefaultAzureCredential or ManagedIdentityCredential.
modules/python/tests/utils/test_azure_auth.py Adds focused unit tests for the new credential helper behavior.
modules/python/clients/aks_client.py Requires caller-provided credential and removes implicit auth construction.
modules/python/crud/azure/node_pool_crud.py Uses shared credential helper when creating AKSClient.
modules/python/crud/azure/machine_crud.py Uses shared credential helper when creating AKSMachineClient.
modules/python/tests/crud/test_azure_node_pool_crud.py Updates NodePoolCRUD tests to assert credential injection via helper.
modules/python/tests/test_machine_crud.py Updates MachineCRUD tests to assert credential injection via helper.
modules/python/tests/test_aks_machine_client.py Updates AKSMachineClient tests to pass an injected credential.
modules/python/tests/clients/test_aks_client.py Updates AKSClient tests and adds coverage that credential is required.
Review details

Suppressed comments (1)

modules/python/clients/aks_client.py:109

  • operation_timeout_minutes is documented as minutes throughout the code (and passed to KubernetesClient as minutes), but the inline comment here says "seconds", which is misleading for callers.
        kube_config_file: Optional[str] = os.path.expanduser("~/.kube/config"),
        result_dir: Optional[str] = None,
        operation_timeout_minutes: int = 10,  # Timeout for each step in seconds
    ):
  • Files reviewed: 9/9 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@diamondpowell
Diamond (diamondpowell) merged commit 6b9fbaa into main Sep 2, 2026
5 checks passed
@diamondpowell
Diamond (diamondpowell) deleted the dipowell/refactor-aks-client-credential branch September 2, 2026 13:38
Diamond (diamondpowell) added a commit that referenced this pull request Sep 8, 2026
## Summary

Registers the open-source CRUD module as part of the
`telescope-benchmarks` Python package so callers can install and run
CRUD operations without source-tree `PYTHONPATH` routing.

## Why

The internal Telescope CRUD migration now uses the open-source Python
CRUD module as the source of truth for node-pool and workload
operations. This PR provides the package contract required by that
migration: installable modules, runtime workload manifests, a CLI entry
point, and explicit pipeline authentication and cluster selection
inputs.

## Changes

- Register `crud`, `crud.azure`, and `crud.aws` in `pyproject.toml`.
- Add the `telescope-crud` console entry point.
- Include deployment, Job, and StatefulSet YAML manifests in the
installed package.
- Consume the credential contract merged in [PR
#1305](#1305): shared
`configure_credential` handling and explicit credential injection into
`AKSClient`.
- Keep Azure credential creation in the CRUD callers and expose
managed-identity exclusion as an opt-in CLI flag.
- Add optional AKS cluster-name selection while preserving discovery
when omitted.
- Preserve the existing positional `NodePoolCRUD` constructor contract.
- Add focused tests for authentication behavior and constructor
compatibility.

## Related PRs

Credential refactor: [PR
#1305](#1305) merged on September
2, 2026 at merge commit `6b9fbaad7ae092d7b96fe7451f6b7987de314d22`. This
PR is rebased onto that contract at
`d41f41bf3536a0c1c4145c3aea127c4d67e10c61`.

Internal migration: [ADO PR
16193735](https://msazure.visualstudio.com/CloudNativeCompute/_git/telescope/pullrequest/16193735)

The two PRs are separated by ownership boundary:

- This PR owns the reusable open-source Python package and runtime
contract.
- The internal PR owns pipeline orchestration, cloud login, resource
validation, result publication, and production rollout.

The internal PR is intentionally open as this package's integration
consumer. It shows reviewers how the package is installed and invoked,
so review of both PRs can happen in parallel. The internal PR does not
need to merge before this package PR.

The internal validation pipeline cloned this draft branch directly and
installed `modules/python` with pip. Draft status does not affect branch
installation as long as the branch is pushed.

## Validation

- Final open-source head: `d41f41bf3536a0c1c4145c3aea127c4d67e10c61`.
- 797 tests passed, 1 skipped; coverage 82.99%; Pylint 10.00/10.
- GitHub Python Validation, YAML Validation, post-comment, and CLA
checks passed.

- 100 focused CRUD and AKS client unit tests passed before pipeline
validation.
- 81 focused CRUD tests passed after the constructor-compatibility fix.
- Python Validation: passed.
- YAML Validation: passed.
- CLA: passed.
- Feature-to-feature pip-install validation: [ADO build
177409535](https://msazure.visualstudio.com/CloudNativeCompute/_build/results?buildId=177409535).
- Five of five Azure regions passed: `westcentralus`, `westus2`,
`eastasia`, `eastus2euap`, and `centraluseuap`.
  - No failed or canceled records.
  - Internal commit: `c18584d6`.
  - Open-source package commit: `3e335184`.

### Post-Refactor `new-pipeline-test.yml` Validation

- [ADO build
179423290](https://msazure.visualstudio.com/CloudNativeCompute/_build/results?buildId=179423290)
passed using the temporary `new-pipeline-test.yml` configuration at
internal test commit `b9460721`.
- The run installed and validated open-source package commit `d41f41bf`,
which includes the merged PR #1305 credential refactor.
- Cleanup commit `3730f654` restored `new-pipeline-test.yml` after
validation; the temporary pipeline YAML is not part of this open-source
PR.

## Review and Merge Sequence

1. Review this package PR and internal PR #16193735 in parallel.
2. Merge this package PR first. Package registration remains separate
and is not blocked on workload timing.
3. Review and merge the planned workload-timing PR against the updated
open-source `main`.
4. Revalidate the already-reviewed internal migration against the
resulting open-source `main` from a disposable validation branch.
5. Merge internal PR #16193735 last, after required workload telemetry
and consumer compatibility pass.
6. Run a post-merge production smoke test and validate ADX output.



## Final Follow-up Validation

- Earlier open-source commit: `9f96c3e0`; superseded by post-refactor
validation at `d41f41bf`.
- 123 focused tests passed after the VirtualMachines scale-state,
exit-code, and helper/test extraction changes.
- Pylint: `10.00/10`.
- Final file sizes: `aks_client.py` 974 lines, `test_aks_client.py` 838
lines, and `test_main.py` 1564 lines.
- Targeted VirtualMachines lifecycle: [ADO build
177546874](https://msazure.visualstudio.com/CloudNativeCompute/_build/results?buildId=177546874).
  - Internal test commit: `00c99b90`.
  - Open-source package commit: `9f96c3e0`.
- Create, scale up, Deployment, StatefulSet, Job, scale down, delete,
collect, upload, and cleanup all passed.
  - No failed, canceled, or succeeded-with-issues records.

Build `177409535` remains the five-region VMSS installation validation;
build `177546874` is the targeted VirtualMachines validation.

### Earlier Authoritative Multi-Region Validation

- **Earlier Build:** [ADO build
177701638](https://msazure.visualstudio.com/CloudNativeCompute/_build/results?buildId=177701638)
(Aug 21, 2026)
- **Commits:** Internal test commit `b9460721` and open-source tested
commit `9f96c3e0`. Internal cleanup commit `3730f654` restored
`new-pipeline-test.yml` (cleanup commit itself was not tested by build).
- **Regions:** `westcentralus`, `westus2`, `eastasia`, `eastus2euap`,
and `centraluseuap`. Both small VMSS and VirtualMachines cases ran in
every region; 5/5 stages and 10/10 matrix jobs passed.
- **Scope:** Package install, create, scale up, Deployment, StatefulSet,
Job, scale down, delete, collect/upload/cleanup passed.
- **Status:** No failed, canceled, abandoned, or succeeded-with-issues
records.
- **Distinction:** Clearly retain build `177409535` as earlier
five-region VMSS package-installation evidence and build `177546874` as
earlier one-region targeted VirtualMachines evidence; do not call either
final-head all-type regional evidence.
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