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

driver: make sure to handle concurrent calls to the droplet #61

Merged
merged 1 commit into from
Aug 23, 2018

Conversation

fatih
Copy link
Contributor

@fatih fatih commented Aug 22, 2018

The DigitalOcean API doesn't process actions for a given resource in
async manner. Calls needs to be done sequentially. This means, if there
is an ongoing process, say an "attach" process, another "attach" or
"detach" will fail.

We return a ABORTED error, which makes sure the csi-attacher to retry
again in the next backoff tick (see:
https://github.com/kubernetes-csi/external-attacher/blob/5a4cc3b1af15966cdb9b8ca1af6ab3adade877b0/pkg/controller/csi_handler.go#L307
and
https://github.com/kubernetes-csi/external-attacher/blob/5a4cc3b1af15966cdb9b8ca1af6ab3adade877b0/pkg/connection/connection.go#L223-L227
)

fixes #32

The DigitalOcean API doesn't process actions for a given resource in
async manner. Calls needs to be done sequentially. This means, if there
is an ongoing process, say an "attach" process, another "attach" or
"detach" will fail.

We return a `ABORTED` error, which makes sure the csi-attacher to retry
again in the next backoff tick (see:
https://github.com/kubernetes-csi/external-attacher/blob/5a4cc3b1af15966cdb9b8ca1af6ab3adade877b0/pkg/controller/csi_handler.go#L307
and
https://github.com/kubernetes-csi/external-attacher/blob/5a4cc3b1af15966cdb9b8ca1af6ab3adade877b0/pkg/connection/connection.go#L223-L227
)
@fatih fatih force-pushed the multiple-volumes branch from 4ef90b9 to 4438af4 Compare August 22, 2018 11:46
@nanzhong
Copy link
Contributor

lgtm

"resp": resp,
}).Warn("assuming volume is attached already")
return &csi.ControllerPublishVolumeResponse{}, nil
if resp != nil && resp.StatusCode == http.StatusUnprocessableEntity {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's some code duplication in regards to the checks here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peter how exactly? I don't see any duplication. Can you give a more concrete example?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the way the check is bein done. The conditional checks on line 205 are ( except for the string being checked ) exactly the same as the ones on line 278. Not that that's an issue though :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, a little copy is ok I guess :) I'll refactor if needed though.

return &csi.ControllerPublishVolumeResponse{}, nil
}

if strings.Contains(err.Error(), "Droplet already has a pending event") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't digitalocean return a specific error code for this? What if the string itself changes

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

such as for example the rate limit return message has the following as body :

{
        id: "too_many_requests",
        message: "API Rate limit exceeded."
}

for which the id would be a prime use case here :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for now, this is the only way we can deal with it. But we'll have some internal todo's to make this better :)

@fatih
Copy link
Contributor Author

fatih commented Aug 23, 2018

I'll merge this as I want to continue on debugging and also release a new version so we can make sure people are up to date. Follow up fixes will be opened.

@fatih fatih merged commit c984688 into master Aug 23, 2018
@fatih fatih deleted the multiple-volumes branch August 23, 2018 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Intermittent MountVolume.MountDevice errors on Pod creation
3 participants