Skip to content

Commit

Permalink
Rackspace Get Volumes Attachment States Fix
Browse files Browse the repository at this point in the history
This patch fixes an issue where the Rackspace storage driver always
assumed that the local devices information should be available when
inspecting a volume or that a volume's attachment information should
always be fetched.
  • Loading branch information
akutz committed Nov 12, 2016
1 parent 6d3474b commit 5428d7a
Showing 1 changed file with 12 additions and 22 deletions.
34 changes: 12 additions & 22 deletions drivers/storage/rackspace/storage/rackspace_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (d *driver) Volumes(
ctx types.Context,
opts *types.VolumesOpts) ([]*types.Volume, error) {
// always return attachments to align against other drivers for now
return d.getVolume(ctx, "", "", types.VolAttReqTrue)
return d.getVolume(ctx, "", "", opts.Attachments)
}

// // VolumeInspect inspects a single volume.
Expand Down Expand Up @@ -592,31 +592,21 @@ func (d *driver) createVolume(
//Reformats from volumes.Volume to types.Volume credit to github.com/MatMaul
func translateVolume(
volume *volumes.Volume,
includeAttachments types.VolumeAttachmentsTypes) *types.Volume {
attachments types.VolumeAttachmentsTypes) *types.Volume {

var attachments []*types.VolumeAttachment
if includeAttachments.Requested() {
for _, attachment := range volume.Attachments {
libstorageAttachment := &types.VolumeAttachment{
VolumeID: attachment["volume_id"].(string),
var atts []*types.VolumeAttachment
if attachments.Requested() {
for _, att := range volume.Attachments {
lsAtt := &types.VolumeAttachment{
VolumeID: att["volume_id"].(string),
InstanceID: &types.InstanceID{
ID: attachment["server_id"].(string),
ID: att["server_id"].(string),
Driver: rackspace.Name},
DeviceName: attachment["device"].(string),
Status: "",
}
attachments = append(attachments, libstorageAttachment)
}
} else {
for _, attachment := range volume.Attachments {
libstorageAttachment := &types.VolumeAttachment{
VolumeID: attachment["volume_id"].(string),
InstanceID: &types.InstanceID{ID: attachment["server_id"].(string), Driver: rackspace.Name},
DeviceName: "",
Status: "",
if attachments.Devices() {
lsAtt.DeviceName = att["device"].(string)
}
attachments = append(attachments, libstorageAttachment)
break
atts = append(atts, lsAtt)
}
}

Expand All @@ -628,7 +618,7 @@ func translateVolume(
Type: volume.VolumeType,
IOPS: 0,
Size: int64(volume.Size),
Attachments: attachments,
Attachments: atts,
}
}

Expand Down

0 comments on commit 5428d7a

Please sign in to comment.