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: handle non existing volumes and nodes #60

Merged
merged 3 commits into from
Aug 22, 2018
Merged

Conversation

fatih
Copy link
Contributor

@fatih fatih commented Aug 21, 2018

According to the spec we should return a NOT_FOUND in various method.
We always assume the volume or node exist, however this might not the
case.

For example the user might delete the volume externally from the
UI or make a HTTP call to the DigitalOcean API to delete the volume.
Actions like this are outside the Kubernetes system, so the plugin needs
to handle these edge cases by signaling back that the resources don't
exist.

We return NOT_FOUND for any creation actions, such as creating a
volume, attaching a volume, formatting, etc.. Because we really need to
return an error as there is no way to recover from this

We don't return NOT_FOUND for any destroy actions, such as deleting,
detaching, unmounting, etc.. Because in all these cases it doesn't
matter if the volume doesn't exist. There is not much to do and assuming
it's "done" makes the overall system more stable

According to the spec we should return a `NOT_FOUND` in various method.
We always assume the volume or node exist, however this might not the
case.

For example the user might delete the volume externally from the
UI or make a HTTP call to the DigitalOcean API to delete the volume.
Actions like this are outside the Kubernetes system, so the plugin needs
to handle these edge cases by signaling back that the resources don't
exist.

We return `NOT_FOUND` for any creation actions, such as creating a
volume, attaching a volume, formatting, etc.. Because we really need to
return an error as there is no way to recover from this

We don't return `NOT_FOUND` for any destroy actions, such as deleting,
detaching, unmounting, etc.. Because in all these cases it doesn't
matter if the volume doesn't exist. There is not much to do and assuming
it's "done" makes the overall system more stable
driver/node.go Outdated
// Invalid argument is returned by the `mount` command in this container
// image when a path is already umounted. We only return an error for
// anything else
if err != nil && !strings.Contains(err.Error(), "Invalid argument") {
Copy link
Member

Choose a reason for hiding this comment

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

Mhmm this string comparison feels like it’s a little fragile, is there another way to determine the error case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, as I said I'll use IsMounted that doesn't rely on the Source so it's a safe bet

@nanzhong
Copy link
Member

lgtm, one question about checking the error.

@fatih
Copy link
Contributor Author

fatih commented Aug 21, 2018

The Invalid argument check will be removed and replaces. Please don't take that into account.

@lxfontes
Copy link

🚀

@fatih fatih merged commit e4142fa into master Aug 22, 2018
@fatih fatih deleted the handle-not-found branch August 22, 2018 05:05
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.

3 participants