Skip to content

Commit f4f3b14

Browse files
authored
Merge pull request #51 from zhucan/bugfix-50
Need to set VolumeContentSource if creating volume from snapshot
2 parents 670a96b + 9c047f5 commit f4f3b14

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

pkg/hostpath/controllerserver.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,26 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
193193
}
194194
}
195195

196-
return &csi.CreateVolumeResponse{
197-
Volume: &csi.Volume{
198-
VolumeId: volumeID,
199-
CapacityBytes: req.GetCapacityRange().GetRequiredBytes(),
200-
VolumeContext: req.GetParameters(),
201-
},
202-
}, nil
196+
createVolumeResponse := &csi.CreateVolumeResponse{}
197+
if req.GetVolumeContentSource() != nil {
198+
createVolumeResponse = &csi.CreateVolumeResponse{
199+
Volume: &csi.Volume{
200+
VolumeId: volumeID,
201+
CapacityBytes: req.GetCapacityRange().GetRequiredBytes(),
202+
VolumeContext: req.GetParameters(),
203+
ContentSource: req.GetVolumeContentSource(),
204+
},
205+
}
206+
} else {
207+
createVolumeResponse = &csi.CreateVolumeResponse{
208+
Volume: &csi.Volume{
209+
VolumeId: volumeID,
210+
CapacityBytes: req.GetCapacityRange().GetRequiredBytes(),
211+
VolumeContext: req.GetParameters(),
212+
},
213+
}
214+
}
215+
return createVolumeResponse, nil
203216
}
204217

205218
func (cs *controllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error) {

0 commit comments

Comments
 (0)