Skip to content

Replace AttachDisk/DetachDisk with a single UpdateDisks RPC - #444

Merged
raghavendra-nataraj merged 1 commit into
mainfrom
raghavendra-nataraj/vm-updatedisks-rpc
Jul 22, 2026
Merged

Replace AttachDisk/DetachDisk with a single UpdateDisks RPC#444
raghavendra-nataraj merged 1 commit into
mainfrom
raghavendra-nataraj/vm-updatedisks-rpc

Conversation

@raghavendra-nataraj

Copy link
Copy Markdown
Contributor

What

Replace the two dedicated cloud-agent RPCs AttachDisk and DetachDisk (added in #441) with a single UpdateDisks RPC on the VirtualMachineAgent service. The direction is selected by a new VirtualMachineDiskOperation enum (ATTACH / DETACH) carried on VirtualMachineDiskRequest.

enum VirtualMachineDiskOperation {
  VIRTUAL_MACHINE_DISK_OPERATION_UNSPECIFIED = 0;
  VIRTUAL_MACHINE_DISK_OPERATION_ATTACH      = 1;
  VIRTUAL_MACHINE_DISK_OPERATION_DETACH      = 2;
}

message VirtualMachineDiskRequest {
  string groupName    = 1;
  string vmName       = 2;
  string locationName = 3;
  repeated Disk disks = 4;
  VirtualMachineDiskOperation operation = 5;
}

rpc UpdateDisks(VirtualMachineDiskRequest) returns (VirtualMachineDiskResponse);

Why

#441 introduced AttachDisk/DetachDisk as two RPCs, but no consumer implements or calls them yet (the wssdcloudagent handler is a follow-up), so this is a safe time to consolidate the surface:

  • Single-direction-per-call matches the actual caller. The azhcidisk CSI driver attaches/detaches exactly one disk per ControllerPublishVolume / ControllerUnpublishVolume (each maps to a single DiskAttach / DiskDetach). There is no caller that needs to attach and detach in one atomic request, so a two-list "attach these + detach those" API would be unused complexity. One RPC + an operation selector covers every real caller with a smaller surface.
  • Fail-safe default. operation defaults to UNSPECIFIED (proto3 zero value). The handler rejects UNSPECIFIED, so a caller that forgets to set the direction gets an error instead of a silent attach/detach.
  • Preserves the Add AttachDisk/DetachDisk RPCs to VirtualMachineAgent #441 intent. The follow-up handler still operates only on the passed disks and never (re)creates the VM (unlike Invoke/CreateOrUpdate, which can resurrect a concurrently-deleted VM).

Changes

  • rpc/cloudagent/compute/virtualmachine/moc_cloudagent_virtualmachine.proto: added the VirtualMachineDiskOperation enum and operation field; replaced the AttachDisk/DetachDisk RPCs with a single UpdateDisks.
  • rpc/cloudagent/compute/moc_cloudagent_virtualmachine.pb.go: regenerated with protoc 3.11.4 + protoc-gen-go v1.3.2 (matching the repo toolchain).

Testing

  • go build ./... and go vet ./rpc/cloudagent/compute/ pass.
  • Handler implementation validated out-of-band in wssdcloudagent (follow-up PR) against this branch.

Follow-up: microsoft/wssdcloudagent will add the UpdateDisks handler and bump its github.com/microsoft/moc dependency to the merged commit of this PR.

Relates to #441.

PR #441 added two dedicated cloud-agent RPCs (AttachDisk, DetachDisk) to the
VirtualMachineAgent service. Since no consumer implements or calls them yet
(the wssdcloudagent handler is a follow-up), collapse them into a single
UpdateDisks RPC whose VirtualMachineDiskRequest carries a
VirtualMachineDiskOperation (ATTACH/DETACH) selector.

- Single-direction per call matches the CSI driver, which attaches/detaches
  exactly one disk per ControllerPublish/UnpublishVolume call.
- operation field defaults to UNSPECIFIED (proto3 zero) so a caller that omits
  it is rejected rather than silently attaching/detaching.
- Preserves the #441 intent: operate only on the passed disks, never recreate
  the VM (unlike Invoke/CreateOrUpdate).

Regenerated moc_cloudagent_virtualmachine.pb.go with protoc 3.11.4 +
protoc-gen-go v1.3.2 (matching the repo toolchain).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4a902de7-e15e-494c-b590-1f9e94a5fadd
@azure-pipelines

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

@raghavendra-nataraj

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

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

@raghavendra-nataraj
raghavendra-nataraj merged commit 28be85a into main Jul 22, 2026
7 checks passed
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