Skip to content

Commit

Permalink
Merge pull request #99 from joonas/joonas/use-publish_info-for-volume…
Browse files Browse the repository at this point in the history
…-name

csi: use publish_info for storing and accessing the volume name
  • Loading branch information
fatih authored Nov 9, 2018
2 parents 277a3fd + dabbe9e commit 1858aa9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
20 changes: 17 additions & 3 deletions driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ const (
)

const (
PublishInfoVolumeName = "com.digitalocean.csi/volume-name"

defaultVolumeSizeInGB = 16 * GB

createdByDO = "Created by DigitalOcean CSI driver"
Expand Down Expand Up @@ -253,7 +255,11 @@ func (d *Driver) ControllerPublishVolume(ctx context.Context, req *csi.Controlle
attachedID = id
if id == dropletID {
ll.Info("volume is already attached")
return &csi.ControllerPublishVolumeResponse{}, nil
return &csi.ControllerPublishVolumeResponse{
PublishInfo: map[string]string{
PublishInfoVolumeName: vol.Name,
},
}, nil
}
}

Expand All @@ -273,7 +279,11 @@ func (d *Driver) ControllerPublishVolume(ctx context.Context, req *csi.Controlle
"error": err,
"resp": resp,
}).Warn("assuming volume is attached already")
return &csi.ControllerPublishVolumeResponse{}, nil
return &csi.ControllerPublishVolumeResponse{
PublishInfo: map[string]string{
PublishInfoVolumeName: vol.Name,
},
}, nil
}

if strings.Contains(err.Error(), "Droplet already has a pending event") {
Expand All @@ -297,7 +307,11 @@ func (d *Driver) ControllerPublishVolume(ctx context.Context, req *csi.Controlle
}

ll.Info("volume is attached")
return &csi.ControllerPublishVolumeResponse{}, nil
return &csi.ControllerPublishVolumeResponse{
PublishInfo: map[string]string{
PublishInfoVolumeName: vol.Name,
},
}, nil
}

// ControllerUnpublishVolume deattaches the given volume from the node
Expand Down
16 changes: 7 additions & 9 deletions driver/node.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1858aa9

Please sign in to comment.