Skip to content

Add AttachDisk/DetachDisk RPCs to VirtualMachineAgent - #441

Merged
raghavendra-nataraj merged 1 commit into
mainfrom
natarajr/vhd-attach-detach-api
Jul 20, 2026
Merged

Add AttachDisk/DetachDisk RPCs to VirtualMachineAgent#441
raghavendra-nataraj merged 1 commit into
mainfrom
natarajr/vhd-attach-detach-api

Conversation

@raghavendra-nataraj

Copy link
Copy Markdown
Contributor

Summary

Adds two dedicated cloud-agent gRPC RPCs to the VirtualMachineAgent service for attaching and detaching virtual hard disks on an existing virtual machine:

rpc AttachDisk(VirtualMachineDiskRequest) returns (VirtualMachineDiskResponse) {}
rpc DetachDisk(VirtualMachineDiskRequest) returns (VirtualMachineDiskResponse) {}

New messages:

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

message VirtualMachineDiskResponse {
    VirtualMachine virtualMachine = 1;
    google.protobuf.BoolValue Result = 2;
    string  Error = 3;
}

Why

Today, CSI attaches/detaches disks by calling VirtualMachineAgent.Invoke with Operation_POST (CreateOrUpdate). That path can recreate a VM after it has been deleted (a create/delete race), which is unintended, and it validates/reconciles the VM's entire disk set.

VirtualMachineDiskRequest carries the target VM identity plus only the disks to act on (not the VM's full storage configuration). This lets the cloud agent:

  • verify the VM exists and refuse to (re)create it, and
  • operate on exactly the passed disks.

Scope

This PR is the proto + generated code foundation only. The cloud-agent handler/provider/client implementation (VM-existence guard, per-disk attach/detach) will land in a follow-up wssdcloudagent PR once this change is released and the module version is bumped there.

RBAC: the follow-up handler will reuse ProviderAccessOperation_Unspecified (as RunCommand does), so no moc_common_common.proto enum change is needed here.

Codegen

moc_cloudagent_virtualmachine.pb.go regenerated with protoc 3.11.4 + protoc-gen-go v1.3.2 (matching the repo toolchain; a no-op baseline regen was byte-identical to the previous generated file before this change). go build ./... and go vet ./rpc/cloudagent/compute/ pass.

Introduce two dedicated cloud-agent RPCs for attaching and detaching
specific virtual hard disks on an existing virtual machine:

  rpc AttachDisk(VirtualMachineDiskRequest) returns (VirtualMachineDiskResponse)
  rpc DetachDisk(VirtualMachineDiskRequest) returns (VirtualMachineDiskResponse)

VirtualMachineDiskRequest carries the target VM (groupName, vmName,
locationName) and only the disks to act on, rather than the VM's full
storage configuration. This lets the agent operate on exactly the passed
disks and verify the VM exists before proceeding, instead of routing disk
attach/detach through CreateOrUpdate (Invoke/POST), which can recreate a
VM after it was deleted.

Regenerated moc_cloudagent_virtualmachine.pb.go with protoc 3.11.4 and
protoc-gen-go v1.3.2.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7af05a8a-88fb-475d-abd2-c17953abf477
@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 a5c8523 into main Jul 20, 2026
7 checks passed
raghavendra-nataraj added a commit that referenced this pull request Jul 22, 2026
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).


Copilot-Session: 4a902de7-e15e-494c-b590-1f9e94a5fadd

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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