Skip to content

Commit

Permalink
Merge pull request #82 from thorn3r/allowRetryAttach
Browse files Browse the repository at this point in the history
Allow Volume attach to retry if Volume is still attached to a Linode
  • Loading branch information
0xch4z authored Jun 17, 2022
2 parents 6397a20 + a46d912 commit dd537e1
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 dd537e1

Please sign in to comment.