@@ -202,8 +202,7 @@ func (cs *controllerServer) ControllerPublishVolume(ctx context.Context, req *cs
202202 if * getVolume .Status == "in-use" {
203203 klog .Infof ("ControllerPublishVolume: Volume %s is already in use" , * getVolume .Name )
204204 if len (* getVolume .Attachments ) > 0 {
205- attachedInstanceIdStr := * (* getVolume .Attachments )[0 ].InstanceId
206- attachedInstanceId , err := strconv .Atoi (attachedInstanceIdStr )
205+ attachedInstanceId := * (* getVolume .Attachments )[0 ].InstanceId
207206 if err != nil {
208207 klog .Errorf ("ControllerPublishVolume: Failed to convert attached instance ID to int: %v" , err )
209208 return nil , status .Errorf (codes .Internal , "Failed to convert attached instance ID to int: %v" , err )
@@ -266,8 +265,7 @@ func (cs *controllerServer) ControllerPublishVolume(ctx context.Context, req *cs
266265 }
267266 if * v .Status == "in-use" && len (* v .Attachments ) > 0 {
268267 attachment := (* v .Attachments )[0 ]
269- attachedId , err := strconv .Atoi (* attachment .InstanceId )
270- if err == nil && attachedId == vmId && attachment .Device != nil {
268+ if err == nil && * attachVolume .Id == vmId && attachment .Device != nil {
271269 klog .Infof ("ControllerPublishVolume: Volume attached to correct node with device %s" , * attachment .Device )
272270 return & csi.ControllerPublishVolumeResponse {
273271 PublishContext : map [string ]string {
0 commit comments