Skip to content

Commit 6a5dbdc

Browse files
authored
Merge pull request #483 from carlory/release-1.12-cherry-pick
Cherry pick of #480: fix missing published target paths when republish the ephemeral volume
2 parents 06a54c6 + 261993a commit 6a5dbdc

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

pkg/hostpath/nodeserver.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,18 @@ func (hp *hostPath) NodePublishVolume(ctx context.Context, req *csi.NodePublishV
6969
if ephemeralVolume {
7070
volID := req.GetVolumeId()
7171
volName := fmt.Sprintf("ephemeral-%s", volID)
72-
kind := req.GetVolumeContext()[storageKind]
73-
// Configurable size would be nice. For now we use a small, fixed volume size of 100Mi.
74-
volSize := int64(100 * 1024 * 1024)
75-
vol, err := hp.createVolume(req.GetVolumeId(), volName, volSize, state.MountAccess, ephemeralVolume, kind)
76-
if err != nil && !os.IsExist(err) {
77-
glog.Error("ephemeral mode failed to create volume: ", err)
78-
return nil, err
72+
if _, err := hp.state.GetVolumeByName(volName); err != nil {
73+
// Volume doesn't exist, create it
74+
kind := req.GetVolumeContext()[storageKind]
75+
// Configurable size would be nice. For now we use a small, fixed volume size of 100Mi.
76+
volSize := int64(100 * 1024 * 1024)
77+
vol, err := hp.createVolume(req.GetVolumeId(), volName, volSize, state.MountAccess, ephemeralVolume, kind)
78+
if err != nil && !os.IsExist(err) {
79+
glog.Error("ephemeral mode failed to create volume: ", err)
80+
return nil, err
81+
}
82+
glog.V(4).Infof("ephemeral mode: created volume: %s", vol.VolPath)
7983
}
80-
glog.V(4).Infof("ephemeral mode: created volume: %s", vol.VolPath)
8184
}
8285

8386
vol, err := hp.state.GetVolumeByID(req.GetVolumeId())

0 commit comments

Comments
 (0)