Add UpdateDisks SDK method for safe disk attach/detach - #387
Open
Microsoft Corporation (raghavendra-nataraj) wants to merge 2 commits into
Open
Add UpdateDisks SDK method for safe disk attach/detach#387Microsoft Corporation (raghavendra-nataraj) wants to merge 2 commits into
Microsoft Corporation (raghavendra-nataraj) wants to merge 2 commits into
Conversation
Wrap the cloud-agent UpdateDisks RPC (moc #444, v0.43.4) so callers can attach/detach VM data disks without the read-modify-write CreateOrUpdate path used by DiskAttach/DiskDetach, which can recreate a VM that was deleted concurrently. - compute: add public VirtualMachineDiskOperation enum (Unspecified/Attach/ Detach) mirroring the wire enum values. - client: add UpdateDisks to the Service interface and a VirtualMachineClient .UpdateDisks wrapper. A missing VM returns NotFound (no recreate); only the supplied disks are acted on. - wssd: implement client.UpdateDisks with getVirtualMachineDiskRequest (reuses getWssdVirtualMachineStorageConfigurationDataDisk) and getVirtualMachineFromDiskResponse. - revendor github.com/microsoft/moc v0.43.3 -> v0.43.4 (brings grpc 1.82.1). DiskAttach/DiskDetach are left unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4a902de7-e15e-494c-b590-1f9e94a5fadd
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Reimplement the existing DiskAttach/DiskDetach to delegate to the new UpdateDisks method instead of the read-modify-write Get -> mutate -> CreateOrUpdate loop. UpdateDisks resolves the VM and routes through the cloud-agent Update path (never Create), so a request that races with a delete returns NotFound instead of resurrecting the VM. Attaching an already-attached disk and detaching an absent disk are now idempotent no-ops (dedup/removal handled agent-side), and the stale-version retry loop is dropped since Update handles versioning. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4a902de7-e15e-494c-b590-1f9e94a5fadd
Madhan Raj Mookkandy (madhanrm)
approved these changes
Jul 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a new
UpdateDisksmethod to the VirtualMachine SDK service so callers (e.g. the azhcidisk CSI driver viamocctl) can attach/detach VM data disks through the cloud-agentUpdateDisksRPC instead of the legacy read-modify-writeDiskAttach/DiskDetach→CreateOrUpdatepath.Why
The existing
DiskAttach/DiskDetachdoGet→ mutateStorageProfile→CreateOrUpdate. If the VM is concurrently deleted between theGetand theCreateOrUpdate, theCreateOrUpdateresurrects the deleted VM. The new path routes through the cloud-agentUpdateDisksRPC, which resolves the VM by lookup and only everUpdates it — a missing/deleted VM returnsNotFound, never a recreate.Changes
services/compute/compute.go: publicVirtualMachineDiskOperationenum (Unspecified/Attach/Detach) mirroring the wire enum values.services/compute/virtualmachine/client.go:UpdateDisksadded to theServiceinterface +VirtualMachineClient.UpdateDiskspublic wrapper.services/compute/virtualmachine/wssd.go:client.UpdateDisksimplementation + request/response converters, reusing the existing DataDisk converter.go.mod/go.sum: bumpgithub.com/microsoft/mocv0.43.3 → v0.43.4 (contains theUpdateDisksRPC).DiskAttach/DiskDetachare left untouched.Dependency chain
v0.43.4)Validation
go build ./...clean againstmoc v0.43.4. (Pre-existing, unrelated: a brokenplacementgroup_test.goand a format-string vet invirtualmachine_test.goexist onmainindependent of this change.)