Skip to content

[SCVMM] Clear retained machine kind before VM deletion - #10385

Open
xingf-msft wants to merge 9 commits into
Azure:mainfrom
xingf-msft:xingf-msft-scvmm-delete-kind
Open

xingf-msft wants to merge 9 commits into
Azure:mainfrom
xingf-msft:xingf-msft-scvmm-delete-kind

Conversation

@xingf-msft

@xingf-msft xingf-msft commented Sep 23, 2026 •

Copy link
Copy Markdown

🤖 PR Validation — ️✔️ All clear

Breaking Changes
️✔️ None

This checklist is used to make sure that common guidelines for a pull request are followed.

Related command

az scvmm vm delete

Summary

This is the SCVMM offboarding CLI update for az scvmm vm delete. It supports removing SCVMM management from a VM while retaining the parent Microsoft.HybridCompute/machines resource for Azure Arc-enabled Servers.

Request clearing of the retained HybridCompute machine's top-level SCVMM kind before starting VMI deletion. --no-wait still sends the update and only disables VMI polling. As in create-from-machines, the machine_client.update() return value is ignored: normal return proceeds to VMI deletion, while SDK exceptions propagate. No additional returned-kind check or custom exception is introduced. Later VMI failures are reported without rolling back the earlier update; --delete-machine paths remain unchanged.

The existing test_scvmm scenario now reads the retained HybridCompute machine after each of its two delete commands and asserts that kind is null or empty. This covers ordinary offboarding and --delete-from-host without adding a test file, helper or client mock. Production logic is unchanged by this test update. Help and the original HTTP cassette remain unchanged.

Recording update still required. The original cassette lacks the new cleanup interactions. No live Azure PATCH or DELETE was performed; a normal SDK return is not independent verification that the service changed kind.

Related

Validation

  • The existing scenario's two new post-delete assertions accept null/empty kind and reject nonempty kind; 8 local assertion cases passed. This validates assertion semantics only, not an Azure interaction.
  • Test discovery still collects the same single scenario; no independent suite was added.
  • azdev style scvmm: pylint and flake8 passed; git diff --check is clean.
  • Live recording and complete scenario replay are not yet validated. The existing cassette still needs the production cleanup GET/PATCH and the two new verification GET responses from an authorized scenario run. No generated success responses, live resource changes or green-CI claim are included in this update.

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install azdev required)
  • My extension version conforms to the Extension version schema

For new extensions:

N/A: existing extension.

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update src/index.json automatically.
You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify src/index.json.


Compound Engineering
GitHub Copilot

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@azure-client-tools-bot-prd

Copy link
Copy Markdown

Hi xingf-msft,
Please write the description of changes which can be perceived by customers into HISTORY.rst.
If you want to release a new extension version, please update the version in pyproject.toml (or setup.py, if the extension has not migrated yet) as well.

@azure-pipelines

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

@microsoft-github-policy-service microsoft-github-policy-service Bot added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Sep 23, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Thank you for your contribution xingf-msft! We will review the pull request and get back to you soon.

@yonzhan

Copy link
Copy Markdown
Collaborator

SCVMM

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

Cover the retained-machine clear/relink lifecycle in the existing scenario with explicitly labeled synthetic HTTP contract fixtures. Exercise real SDK response deserialization and cleanup retry behavior, and clarify partial-success recovery guidance. Live service-side kind clearing remains unverified.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5197fc05-89af-40ce-b80f-4097f81d506c
@xingf-msft

Copy link
Copy Markdown
Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Commenter does not have sufficient privileges for PR 10385 in repo Azure/azure-cli-extensions

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

Restore the original recording and remove added HybridCompute GET/state assertions. Isolate the cleanup client only during historical playback of the two delete commands; recording/live execution, production cleanup and CLI contract unit coverage remain unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5197fc05-89af-40ce-b80f-4097f81d506c
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

Remove the additional standalone VM deletion test suite rather than introducing another test structure. Keep the existing scenario and its historical-playback dependency isolation; production cleanup and recorded interactions are unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5197fc05-89af-40ce-b80f-4097f81d506c
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

xingf-msft and others added 2 commits September 24, 2026 14:01
Remove the playback-only client mock helper and restore the original self.cmd deletion calls. The test tree and cassette now match the base branch. The new production cleanup requests still require an authentic recording before scenario playback can pass; do not fabricate responses or mask the missing interactions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5197fc05-89af-40ce-b80f-4097f81d506c
Remove the added long summary and recovery example. Keep the established short-summary and examples pattern; the remaining PR is limited to kind cleanup, its release notes and the extension version.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5197fc05-89af-40ce-b80f-4097f81d506c
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

Handle retained-machine kind cleanup before the VMI request, including --no-wait, following the existing create flow. Preserve delete-machine behavior; propagate HCRP failures before starting VMI deletion and do not roll back cleanup if the VMI operation later fails. Remove the skip warning and update the release note without changing help or tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5197fc05-89af-40ce-b80f-4097f81d506c
@xingf-msft xingf-msft changed the title [SCVMM] Clear retained machine kind after VM deletion [SCVMM] Clear retained machine kind before VM deletion Sep 24, 2026
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

Discard the machine update return value as create-from-machines does. Continue VMI deletion when the SDK call returns normally and preserve SDK exception propagation; remove the additional kind postcondition and its exception import.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5197fc05-89af-40ce-b80f-4097f81d506c
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

@xingf-msft
xingf-msft marked this pull request as ready for review September 24, 2026 06:23
Copilot AI lite review requested due to automatic review settings September 24, 2026 06:23
@xingf-msft

Copy link
Copy Markdown
Author

Hi Ethan Yang (@necusjz) , I just finalize the change for this pr. Sorry I was raising this as draft at first stage.
Would you please review, and feel free to direct message me (alias fanxing) via teams if I need to make any further update.
Thanks

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.

Copilot review overview

🟡 Changes recommended

Add an authentic recording or equivalent isolated test covering the new GET, PATCH, and deletion ordering.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Updates az scvmm vm delete to clear the retained HybridCompute machine kind before deleting the VM instance.

Changes:

  • Added parent-machine GET/PATCH cleanup before VMI deletion.
  • Bumped the extension version to 1.2.2.
  • Documented the behavior change in release history.
File Summary
src/​scvmm/​setup.py Updates the extension version.
src/​scvmm/​HISTORY.rst Documents the new deletion behavior.
src/​scvmm/​azext_scvmm/​custom.py Clears the machine kind before VMI deletion.

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

Comment thread src/scvmm/azext_scvmm/custom.py
Read the retained HybridCompute machine after each existing VM delete and assert its kind is empty. Reuse the current scenario without a new test suite, client mocks or synthetic HTTP recordings.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5197fc05-89af-40ce-b80f-4097f81d506c
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

@xingf-msft

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Microsoft"

@yonzhan

Copy link
Copy Markdown
Collaborator

Please fix CI issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants