Skip to content

Commit

Permalink
Merge pull request #334 from akutz/bugfix/isilon-attachment-fix
Browse files Browse the repository at this point in the history
Isilon Get Volumes Attachment States Fix
  • Loading branch information
akutz authored Nov 12, 2016
2 parents 6d3474b + 610ddd3 commit 5606ff0
Showing 1 changed file with 40 additions and 22 deletions.
62 changes: 40 additions & 22 deletions drivers/storage/isilon/storage/isilon_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,23 +167,37 @@ func (d *driver) NextDeviceInfo(
return nil, nil
}

func (d *driver) getVolumeAttachments(ctx types.Context) (
func (d *driver) getVolumeAttachments(
ctx types.Context,
attachments types.VolumeAttachmentsTypes) (
[]*types.VolumeAttachment, error) {

if !attachments.Requested() {
return nil, nil
}

exports, err := d.getVolumeExports(ctx)
if err != nil {
return nil, err
}

iid, iidOK := context.InstanceID(ctx)
ld, ldOK := context.LocalDevices(ctx)
var (
ld *types.LocalDevices
ldOK bool
)
if attachments.Devices() {
ld, ldOK = context.LocalDevices(ctx)
}

var atts []*types.VolumeAttachment
for _, export := range exports {
var dev string
var status string
var (
dev string
status string
)
for _, c := range export.Clients {
if iidOK && ldOK && c == iid.ID {
if iidOK && ldOK && strings.EqualFold(c, iid.ID) {
dev = d.nfsMountPath(export.ExportPath)
if _, ok := ld.DeviceMap[dev]; ok {
status = "Exported and Mounted"
Expand Down Expand Up @@ -542,21 +556,23 @@ func (d *driver) getVolume(
return nil, nil
}

var atts []*types.VolumeAttachment
var (
err error
atts []*types.VolumeAttachment
attMap map[string][]*types.VolumeAttachment
)

if attachments.Requested() {
var err error
atts, err = d.getVolumeAttachments(ctx)
if err != nil {
if atts, err = d.getVolumeAttachments(ctx, attachments); err != nil {
return nil, err
}
}

attMap := make(map[string][]*types.VolumeAttachment)
for _, att := range atts {
if attMap[att.VolumeID] == nil {
attMap[att.VolumeID] = make([]*types.VolumeAttachment, 0)
attMap = map[string][]*types.VolumeAttachment{}
for _, att := range atts {
if attMap[att.VolumeID] == nil {
attMap[att.VolumeID] = []*types.VolumeAttachment{}
}
attMap[att.VolumeID] = append(attMap[att.VolumeID], att)
}
attMap[att.VolumeID] = append(attMap[att.VolumeID], att)
}

var volumesSD []*types.Volume
Expand All @@ -565,13 +581,15 @@ func (d *driver) getVolume(
if err != nil {
return nil, err
}

vatts, _ := attMap[volume.Name]
volumeSD := &types.Volume{
Name: volume.Name,
ID: volume.Name,
Size: volSize,
Attachments: vatts,
Name: volume.Name,
ID: volume.Name,
Size: volSize,
}
if attachments.Requested() {
if vatts, ok := attMap[volume.Name]; ok {
volumeSD.Attachments = vatts
}
}
volumesSD = append(volumesSD, volumeSD)
}
Expand Down

0 comments on commit 5606ff0

Please sign in to comment.