Skip to content

Commit 1858aa9

Browse files
authored
Merge pull request #99 from joonas/joonas/use-publish_info-for-volume-name
csi: use publish_info for storing and accessing the volume name
2 parents 277a3fd + dabbe9e commit 1858aa9

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

driver/controller.go

+17-3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ const (
4141
)
4242

4343
const (
44+
PublishInfoVolumeName = "com.digitalocean.csi/volume-name"
45+
4446
defaultVolumeSizeInGB = 16 * GB
4547

4648
createdByDO = "Created by DigitalOcean CSI driver"
@@ -253,7 +255,11 @@ func (d *Driver) ControllerPublishVolume(ctx context.Context, req *csi.Controlle
253255
attachedID = id
254256
if id == dropletID {
255257
ll.Info("volume is already attached")
256-
return &csi.ControllerPublishVolumeResponse{}, nil
258+
return &csi.ControllerPublishVolumeResponse{
259+
PublishInfo: map[string]string{
260+
PublishInfoVolumeName: vol.Name,
261+
},
262+
}, nil
257263
}
258264
}
259265

@@ -273,7 +279,11 @@ func (d *Driver) ControllerPublishVolume(ctx context.Context, req *csi.Controlle
273279
"error": err,
274280
"resp": resp,
275281
}).Warn("assuming volume is attached already")
276-
return &csi.ControllerPublishVolumeResponse{}, nil
282+
return &csi.ControllerPublishVolumeResponse{
283+
PublishInfo: map[string]string{
284+
PublishInfoVolumeName: vol.Name,
285+
},
286+
}, nil
277287
}
278288

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

299309
ll.Info("volume is attached")
300-
return &csi.ControllerPublishVolumeResponse{}, nil
310+
return &csi.ControllerPublishVolumeResponse{
311+
PublishInfo: map[string]string{
312+
PublishInfoVolumeName: vol.Name,
313+
},
314+
}, nil
301315
}
302316

303317
// ControllerUnpublishVolume deattaches the given volume from the node

driver/node.go

+7-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)