@@ -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