Skip to content

[k8s-extension] ChaosStudio built-in role migration and namespace retention (1.9.5) - #10542

Open
Frank Li (franklixuefei) wants to merge 7 commits into
Azure:mainfrom
franklixuefei:dev/xuefl/promote0cf69326
Open

Frank Li (franklixuefei) wants to merge 7 commits into
Azure:mainfrom
franklixuefei:dev/xuefl/promote0cf69326

Conversation

@franklixuefei

@franklixuefei Frank Li (franklixuefei) commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

🤖 PR Validation — ️✔️ All clear

Breaking Changes Suppressions
️✔️ None ️✔️ None

Summary and explicit scope decision

Promote AzureArcForKubernetes#35 once, with the explicitly approved review corrections below. Its duplicate predecessor, AzureArcForKubernetes#34, is not applied as a second patch set.

Version 1.9.5 intentionally retains namespaces. This PR delivers built-in role migration and safe extension uninstall, not automatic clean-namespace removal. Namespace garbage collection and its fenced/recoverable protocol are deferred.

Task 40054123 and Bug 40051963 remain Active. This change does not complete their clean-namespace acceptance or establish GA cleanup proof. Ready for review is not approval to merge, publish a wheel or close those items.

Related commands: az k8s-extension create, update, and delete for Microsoft.ChaosStudio.

Current uninstall and ownership contract

  • Create/update reconcile the built-in operator assignment and preserve owned legacy assignments until uninstall. Legacy cleanup IDs are validated before persistence/teardown and cannot be added or replaced during ordinary update. Malformed stored IDs halt before any deletion; no grant ownership is guessed.
  • Synchronous uninstall removes the matching owned connection/role assignments, requires raw ARM delete-poller success, then reports namespace retention. Failed HTTP 404 monitor results are not hidden by the CLI progress helper.
  • PostDelete performs logging only: no ARM or Kubernetes client acquisition, inventory, namespace DELETE or finalization. --no-wait and --force do not run namespace cleanup either.
  • An initial ARM 404 remains idempotent for the absent extension; it is not namespace-absence evidence. No Kubernetes mutation remains to resume after the extension is gone.
  • Installation namespaceLifecycle.createdByInstall inputs and chart ownership compatibility are preserved. Ownership is not treated as proof that all namespace writers are stopped.
  • Role definitions, customer Kubernetes resources, learned-key state and retained engines are not erased by this CLI.

Review disposition

Current source: b776f112317f0ae0eca687cc12582867bedc19e6.

The inventory/delete race and post-delete recovery gap are addressed by withdrawing automatic namespace mutation, not by claiming namespace resourceVersion is a write fence or an ARM 404 reconstructs ownership.

The intermediate root-CA classifier is removed with the now-unused inventory/default/finalization helpers. All namespace contents are retained, so no customized ConfigMap is classified as disposable. Earlier legacy-ID and pending-role reconciliation fixes remain intact.

This adds no admission drain, checkpoint, new recovery command, cluster-wide permission or cleanup authority. The documentation and tests now assert the explicit retention contract.

Provenance and overlap

Accepted team-fork head: e9d1a249291e61903bd968c75e39b45c7d31a92f; merge: 901ca85f39c28272090fe295f240f83148910d93.

Initial promotion e778d669 replayed only #35's five commits onto upstream d79d5bc724e7701a03ad7a74c064d06c260ad417, preserving original authors/dates and all eight accepted blobs. The two explicitly approved review follow-ups modify only original PR paths. The fork's 37 pre-existing testing/ assets are excluded and unrelated upstream changes retained.

Open upstream PR #10528 overlaps the initial non-404 lookup guard and version 1.9.5. That guard was already in accepted #35; no commits or extra files from #10528 are imported. Maintainers should coordinate merge/version order rather than publish the same version twice.

Validation and release boundary

  • 61 normal unit methods passed. Three retention regressions fail on the prior automatic-removal source; they cover no post-delete API access, no cleanup mutation to resume, and customer-resource preservation through confirmed ARM deletion plus an idempotent 404 retry.
  • The method count changed because tests for the intentionally withdrawn automatic-removal feature were replaced, not weakened to accept unsafe deletion. Creation ownership checks, legacy-role validation, pending-role reconciliation and strict poller-failure controls remain covered.
  • Repository-configured Flake8 passed; private 1.9.5 wheel source parity and packaged logging-only PostDelete verified. Wheel SHA-256: b6b15433ac83f577abb50020bcbef67392dafbb2ff6eb5e8b6c1732a2bbb3863.
  • Initial upstream index gate: 9 total tests, 2 non-CI skips. Generated src/index.json remains unchanged.
  • Full local azdev style remains unverified because the pinned tool rejects Git worktree registration. Prior-head upstream style/linter results are not transferred to this source; new-head CI/review remain required.

No live uninstall, Azure/cluster-policy operation, upstream merge, fork sync, generated-index edit or wheel publication was performed. No EV2 producer or dependency/version change is required.

General guidelines

  • Run full azdev style k8s-extension locally (limitation disclosed above).
  • Run the existing upstream index gate; leave generated index untouched.
  • Keep the existing extension version schema (1.9.5) and update only its unreleased history.

AB#40054123

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Promotion source: AzureArcForKubernetes#35
Original commit: 268fa2d

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1bf68851-0503-4249-a0ca-464fb560d529
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Promotion source: AzureArcForKubernetes#35
Original commit: a6855bd

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1bf68851-0503-4249-a0ca-464fb560d529
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Promotion source: AzureArcForKubernetes#35
Original commit: 240b73d

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1bf68851-0503-4249-a0ca-464fb560d529
Keep learned-key state protected; document the chart 0.1.13+ live-proof dependency.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Promotion source: AzureArcForKubernetes#35
Original commit: 1becc7c

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1bf68851-0503-4249-a0ca-464fb560d529
The CLI progress helper can suppress a failed 404 delete poller result.
Require the raw result to succeed before entering PostDelete and exercise
the actual helper in a focused regression. Model an already-completed poller
without recording a second operation completion in the existing ordering test.

The regression fails on the original source and passes with this guard.
The normal Chaos unit module passes all 62 tests.

Promotion source: AzureArcForKubernetes#35
Original commit: e9d1a24

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1bf68851-0503-4249-a0ca-464fb560d529
Copilot AI balanced review requested due to automatic review settings October 30, 2026 22:09
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

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.

🟡 Changes recommended

Outstanding issues include namespace cleanup paths that can delete customer resources, leave role grants active, or fail to complete safely on retry.

5 open issues
What changed in this PR

Promotes the accepted ChaosStudio changes from the Arc fork into k8s-extension 1.9.5, covering built-in role migration and stricter uninstall behavior.

Changes:

  • Assigns the built-in operator role while retaining owned legacy assignments until uninstall.
  • Requires confirmed synchronous deletion before ownership-checked namespace cleanup, with regression tests and updated documentation.
  • Updates the package version and uses $GITHUB_WORKSPACE for CI repository setup.
File Description
src/​k8s-extension/​setup.py Bumps the package version to 1.9.5.
src/​k8s-extension/​README.rst Documents migration, cleanup safeguards, prerequisites and pending live validation.
src/​k8s-extension/​HISTORY.rst Records the 1.9.5 behavior changes.
src/​k8s-extension/​azext_k8s_extension/​tests/​latest/​test_chaos_studio.py Adds role-migration, namespace-inventory and deletion regression coverage.
src/​k8s-extension/​azext_k8s_extension/​partner_extensions/​ChaosStudio.py Implements built-in role reconciliation and ownership-gated namespace cleanup.
src/​k8s-extension/​azext_k8s_extension/​custom.py Propagates lookup failures and verifies deletion before namespace cleanup.
.github/​workflows/​VersionCalPRComment.yml Resolves the extension checkout through $GITHUB_WORKSPACE.
.github/​actions/​env-setup/​action.yml Uses $GITHUB_WORKSPACE in shared environment setup.

Review effort: Balanced

Retain root CA ConfigMaps with customer metadata, allowing only the known
controller description annotation. Validate legacy cleanup role IDs before
persistence or teardown, reject updates that add/change the original ID, and
preserve the original value for equivalent input.

Reconcile the existing built-in workspace role after a pending active install
successfully completes. Keep failed/no-wait paths non-mutating and retain the
legacy assignment.

Addresses approved review comments 4428934501, 4428934560 and 4428934634 on
Azure/azure-cli-extensions PR 10542. Seven focused regression methods expose
16 failures on the old source; the normal module now passes 69 tests.

Namespace inventory/delete concurrency and post-delete recovery remain open
design decisions (4428934530 and 4428934588). Their flows are unchanged and
the PR remains Draft. No drain, checkpoint, new cleanup authority or live
resource operation is introduced.

All four changed files were already in the PR; no generated/vendor/ripple
files or duplicate predecessor patch set. Client behavior only: no EV2
producer, dependency, package version, index or publication changes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1bf68851-0503-4249-a0ca-464fb560d529
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

Apply the explicitly approved uninstall ownership boundary: delete only the
ARM extension and its owned connection/grants. PostDelete now reports namespace
retention without acquiring clients, reading cluster state, deleting namespaces
or waiting for finalization. Keep strict raw delete-poller success checks.

Remove the unused namespace inventory/default-classifier/finalization helpers
and tests for the withdrawn automatic-removal feature. Add regressions proving
no post-delete API access, no cleanup mutation to resume, and preservation of
customer resources created during ARM deletion, including an idempotent 404 retry.
Retain chart installation ownership inputs and earlier role-state fixes.

Update README/HISTORY to state the narrower 1.9.5 contract. Automatic namespace
removal is deferred; Task 40054123 and Bug 40051963 remain open. No admission
drain, durable checkpoint, new cleanup authority or GA cleanup proof is claimed.
This supersedes review blockers 4428934530 and 4428934588 by removing the
automatic mutation, not by pretending namespace resourceVersion is a write fence.

All five files were already in upstream PR 10542. No duplicate predecessor
patch set, generator/vendor output, dependency/version/index, EV2 or live-resource
changes. No merge, sync or publication is performed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1bf68851-0503-4249-a0ca-464fb560d529
@franklixuefei Frank Li (franklixuefei) changed the title [k8s-extension] ChaosStudio built-in role migration and strict uninstall (1.9.5) [k8s-extension] ChaosStudio built-in role migration and namespace retention (1.9.5) Oct 30, 2026
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

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.

Comment on lines +124 to +126
self.client = config.new_client_from_config_dict(
yaml.safe_load(base64.b64decode(configs[0]["value"]).decode("utf-8"))
)
Comment on lines +133 to +148
def request(self, method, path, body=None, allow_not_found=False):
remaining = self.deadline - time.monotonic()
if remaining <= 0:
raise AzureResponseError("Namespace inspection exceeded its 210-second API budget.")
try:
return self.client.call_api(
path, method, body=body, response_type="object",
auth_settings=["BearerToken"], _return_http_data_only=True,
_request_timeout=min(30, remaining),
)
except ApiException as error:
if allow_not_found and error.status == 404:
return None
raise AzureResponseError(
"Target-cluster {} {} failed; namespace inspection was not confirmed: {}".format(method, path, error)
) from error
* Microsoft.ChaosStudio: intentionally retain release namespaces and their remaining Kubernetes resources on uninstall. Automatic namespace removal and its fenced/recoverable cleanup contract are deferred, not claimed as clean-namespace or GA cleanup acceptance.
* Microsoft.ChaosStudio: validate and retain immutable legacy-role cleanup IDs before any teardown, and reconcile the built-in assignment after a pending active installation completes successfully.
* Microsoft.ChaosStudio: assign the built-in Chaos Kubernetes Extension Operator role instead of provisioning or validating custom roles. Create and update add a separate built-in assignment; existing owned legacy assignments stay until uninstall to avoid interrupting authorization during migration. Delete removes both owned assignments but never role definitions.
* Microsoft.ChaosStudio: require the persisted namespaceLifecycle.createdByInstall assertion as well as the matching namespace marker before post-uninstall namespace removal.
Comment on lines +191 to +201
It exposed the create-only ``bindings`` discovery gap fixed here. Retrying
namespace inspection preserved an unmarked ``durable-broker-learned-keys``
ConfigMap and Kubernetes Events rather than erasing them. AKS also returned a
pristine default ServiceAccount without managedFields, now covered by a regression.
This wasn't live proof of clean namespace removal. This CLI version now
intentionally retains namespaces; a chart release alone does not provide the
concurrent-writer fence or durable recovery contract required for automatic
removal. The compatible chart's learned-key owner marker and pre-delete cleanup
remain separate from that deferred capability. The CLI doesn't
special-case learned-key state; preserving the unmarked ConfigMap on 0.1.12 is
correct. Events no longer block namespace removal. The built-in role
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Auto-Assign Auto assign by bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants