Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

csi-wrapper: pass PublishContext from ControllerPublishVolume to NodeStageVolume #2108

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/csi-wrapper/pkg/wrapper/podvmservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,22 @@ func (s *PodVMNodeService) ReproduceNodeStageVolume(peerPodVolume *peerpodvolume
if err := (&jsonpb.Unmarshaler{}).Unmarshal(bytes.NewReader([]byte(wrapperRequest)), &modifiedRequest); err != nil {
glog.Errorf("Failed to convert to NodeStageVolumeRequest, err: %v", err.Error())
} else {
modifiedRequest.PublishContext["device-path"] = peerPodVolume.Spec.DevicePath
// The cached NodeStageVolumeRequest contains a faked PublishContext from [ControllerService.ControllerPublishVolume].
// Since a CSI driver may depend on PublishContext to pass required information from ControllerPublishVolume to NodeStageVolume,
// we need to replace the PublishContext in the cached NodeStageVolumeRequest with the real one from
// the cached ControllerPublishVolumeResponse.
publishContext := make(map[string]string)
controllerPublishVolumeResJSON := peerPodVolume.Spec.WrapperControllerPublishVolumeRes
var controllerPublishVolumeRes csi.ControllerPublishVolumeResponse
if err := (&jsonpb.Unmarshaler{}).Unmarshal(bytes.NewReader([]byte(controllerPublishVolumeResJSON)), &controllerPublishVolumeRes); err != nil {
glog.Errorf("Failed to convert to ControllerPublishVolumeResponse, err: %s", err)
}
for k, v := range controllerPublishVolumeRes.PublishContext {
publishContext[k] = v
}
publishContext["device-path"] = peerPodVolume.Spec.DevicePath
modifiedRequest.PublishContext = publishContext

glog.Infof("The modified NodeStageVolumeRequest is :%v", modifiedRequest)
ctx := context.Background()
count := 0
Expand Down
Loading