Skip to content

Commit

Permalink
Allow Volume attach to retry if Volume is still attached to a Linode
Browse files Browse the repository at this point in the history
  • Loading branch information
thorner committed Jun 17, 2022
1 parent 6397a20 commit a46d912
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/linode-bs/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,11 @@ func (linodeCS *LinodeControllerServer) ControllerPublishVolume(ctx context.Cont
}

if _, err := linodeCS.CloudProvider.AttachVolume(ctx, volumeID, opts); err != nil {
return nil, status.Errorf(codes.Internal, "error attaching volume: %s", err)
retCode := codes.Internal
if apiErr, ok := err.(*linodego.Error); ok && strings.Contains(apiErr.Message, "is already attached") {
retCode = codes.Unavailable // Allow a retry if the volume is already attached: race condition can occur here
}
return nil, status.Errorf(retCode, "error attaching volume: %s", err)
}

glog.V(4).Infoln("waiting for volume to attach")
Expand Down

0 comments on commit a46d912

Please sign in to comment.