Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSI: add missing fields to HTTP API response #12178

Merged
merged 1 commit into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/12178.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
csi: Fixed a bug where fields were missing from the Read Volume API response
```
28 changes: 24 additions & 4 deletions command/agent/csi_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,17 +475,25 @@ func structsCSIVolumeToApi(vol *structs.CSIVolume) *api.CSIVolume {
allocCount := len(vol.ReadAllocs) + len(vol.WriteAllocs)

out := &api.CSIVolume{
ID: vol.ID,
Name: vol.Name,
ExternalID: vol.ExternalID,
Namespace: vol.Namespace,
ID: vol.ID,
Name: vol.Name,
ExternalID: vol.ExternalID,
Namespace: vol.Namespace,

Topologies: structsCSITopolgiesToApi(vol.Topologies),
AccessMode: structsCSIAccessModeToApi(vol.AccessMode),
AttachmentMode: structsCSIAttachmentModeToApi(vol.AttachmentMode),
MountOptions: structsCSIMountOptionsToApi(vol.MountOptions),
Secrets: structsCSISecretsToApi(vol.Secrets),
Parameters: vol.Parameters,
Context: vol.Context,
Capacity: vol.Capacity,

RequestedCapacityMin: vol.RequestedCapacityMin,
RequestedCapacityMax: vol.RequestedCapacityMax,
RequestedCapabilities: structsCSICapabilityToApi(vol.RequestedCapabilities),
CloneID: vol.CloneID,
SnapshotID: vol.SnapshotID,

// Allocations is the collapsed list of both read and write allocs
Allocations: make([]*api.AllocationListStub, 0, allocCount),
Expand Down Expand Up @@ -772,6 +780,18 @@ func structsCSIAttachmentModeToApi(mode structs.CSIVolumeAttachmentMode) api.CSI
return api.CSIVolumeAttachmentModeUnknown
}

// structsCSICapabilityToApi converts capabilities, part of structsCSIVolumeToApi
func structsCSICapabilityToApi(caps []*structs.CSIVolumeCapability) []*api.CSIVolumeCapability {
out := make([]*api.CSIVolumeCapability, len(caps))
for i, cap := range caps {
out[i] = &api.CSIVolumeCapability{
AccessMode: api.CSIVolumeAccessMode(cap.AccessMode),
AttachmentMode: api.CSIVolumeAttachmentMode(cap.AttachmentMode),
}
}
return out
}

// structsCSIMountOptionsToApi converts mount options, part of structsCSIVolumeToApi
func structsCSIMountOptionsToApi(opts *structs.CSIMountOptions) *api.CSIMountOptions {
if opts == nil {
Expand Down