From 69026badbe4ce8d6a72e1d2e278efd7219e9c214 Mon Sep 17 00:00:00 2001 From: Timo Reimann Date: Sun, 19 Dec 2021 23:49:30 +0100 Subject: [PATCH] Populate published node IDs in ListVolumesResponse According to [1], this "helps the CO [container orchestrator] reconcile the actual state when the volume may have been Unpublished from the node out of band from the CO". [1] https://github.com/container-storage-interface/spec/pull/374 --- driver/controller.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/driver/controller.go b/driver/controller.go index 143242fc..87ad9fc5 100644 --- a/driver/controller.go +++ b/driver/controller.go @@ -559,11 +559,19 @@ func (d *Driver) ListVolumes(ctx context.Context, req *csi.ListVolumesRequest) ( var entries []*csi.ListVolumesResponse_Entry for _, vol := range volumes { + attachedDropletIDs := make([]string, 0, len(vol.DropletIDs)) + for _, dropletID := range vol.DropletIDs { + attachedDropletIDs = append(attachedDropletIDs, strconv.Itoa(dropletID)) + } + entries = append(entries, &csi.ListVolumesResponse_Entry{ Volume: &csi.Volume{ VolumeId: vol.ID, CapacityBytes: vol.SizeGigaBytes * giB, }, + Status: &csi.ListVolumesResponse_VolumeStatus{ + PublishedNodeIds: attachedDropletIDs, + }, }) } @@ -609,6 +617,7 @@ func (d *Driver) ControllerGetCapabilities(ctx context.Context, req *csi.Control csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT, csi.ControllerServiceCapability_RPC_LIST_SNAPSHOTS, csi.ControllerServiceCapability_RPC_EXPAND_VOLUME, + csi.ControllerServiceCapability_RPC_LIST_VOLUMES_PUBLISHED_NODES, } { caps = append(caps, newCap(cap)) }