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

csi: document how to use existing volumes #87

Merged
merged 1 commit into from
Oct 8, 2018

Conversation

fatih
Copy link
Contributor

@fatih fatih commented Oct 3, 2018

  • Add Readme with examples on how to use existing volumes
  • Add an option to prevent formatting an existing volume (needs more
    testing)

KNOWN ISSUES:

  • Deleting a PVC will delete the volume if the reclaim policy is set
    to Delete, however the PV will be not deleted. This seems to be a
    bug in K8S
  • Using an existing, attached volume might cause confusion if the POD is
    scheduled to a different node. It's advised that user only use existing
    detached volumes

closes #85

// TODO(arslan): remove this logic once the bug is fixed in k8s
// https: //github.com/kubernetes/kubernetes/issues/65552
// volume is still attached, but we receive a delete request. Try to detach it.
ll.WithFields(logrus.Fields{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI: I'm going to remove the whole logic, it's not worth adding this and a wrong approach. Eventually the controllers will reconcile if all methods are idempotent (which is in our case). That's why we don't need this code yet. I'm doing some tests so pushed it here.

@@ -0,0 +1,146 @@
# Use an existing volume

Below you find the instruction on how to use an existing DigitalOcean Block
Copy link

@aybabtme aybabtme Oct 3, 2018

Choose a reason for hiding this comment

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

Below you will find the instructions

* `volumeAttributes` has a special, csi-digitalocean specific annotation called `com.digitalocean.csi/format`. If you add this key, the CSI plugin make sure to **not format** the volume. If you don't add this, it'll be formatted.
* `storage` make sure it's set to the same storage size as your existing DigitalOcean Block Storage volume.

Once everything is set, create this file called `pv.yaml` and deploy it:
Copy link

Choose a reason for hiding this comment

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

create a file with this content, naming it pv.yaml, and deploy it

@aybabtme
Copy link

aybabtme commented Oct 3, 2018

lgtm

@lxfontes
Copy link

lxfontes commented Oct 4, 2018

@fatih just to confirm on

Deleting a PVC will delete the volume if the reclaim policy is set
to Delete, however the PV will be not deleted. This seems to be a
bug in K8S

The expected behaviour here is reclaimPolicy: Delete to delete pvc & pv and that is not working, correct? If so, this explains an internal tester reporting it. otherwise we need to 🔍

}

// we assume it's deleted already for idempotency
if resp.StatusCode == http.StatusNotFound {
Copy link

@lxfontes lxfontes Oct 4, 2018

Choose a reason for hiding this comment

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

log here. mostly so we know this is happening. ( thinking of a case we end up returning a 404 on api for #reasons )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This also happens if the plugin receives two or more delete calls. The first one deletes it, the second one gets a StatusNotFound.

@lxfontes
Copy link

lxfontes commented Oct 4, 2018

lgtm
minor comments

@fatih
Copy link
Contributor Author

fatih commented Oct 4, 2018

@lxfontes

The expected behaviour here is reclaimPolicy: Delete to delete pvc & pv and that is not working, correct? If so, this explains an internal tester reporting it. otherwise we need to 🔍

For dynamic provisioning, such as when you set a storage class (Which is the case if you deployr our CSI plugin or in DigitalOcean Kubernetes), in this case, the reclaimPolicy is automatically set to Delete. If you created a volume dynamically, (by just using a PVC and POD), in this case, removing a PVCremoves thePV` as well.

However, in this case, if you manually create a PV and then create a PVC, you decide to delete the PVC, the PV will be not removed. The backed volume will be deleted though. The issue is, somehow the finalizer is not removed from the PV resource, so it's get stuck. If you do a kubectl edit pv ... and remove the finalizer (which is added by the storage controller), it's get deleted immediately.

I think this is a bug on K8S. I'll try to reproduce and open a bug issue if I can find something

// droplet is attached to a different node, return an error
if attachedID != 0 {
return nil, status.Errorf(codes.FailedPrecondition,
"volume is attached to a wrong droplet(%q), dettach the volume to fix it", attachedID)
Copy link

Choose a reason for hiding this comment

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

volume is attached to the wrong droplet(%q), detach the volume to fix it

@@ -50,7 +51,7 @@ Couple of things to note,
* `volumeAttributes` has a special, csi-digitalocean specific annotation called `com.digitalocean.csi/format`. If you add this key, the CSI plugin make sure to **not format** the volume. If you don't add this, it'll be formatted.
* `storage` make sure it's set to the same storage size as your existing DigitalOcean Block Storage volume.

Once everything is set, create this file called `pv.yaml` and deploy it:
Create a file with this content, naming it `pv.yaml` and deploy it:
Copy link

Choose a reason for hiding this comment

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

deploying

@aybabtme
Copy link

aybabtme commented Oct 8, 2018

lgtm

* Add Readme with examples on how to use existing volumes
* Add an option to prevent formatting an existing volume (needs more
testing)

KNOWN ISSUES:

* Deleting a `PVC` will delete the volume if the reclaim policy is set
to `Delete`, however the `PV` will be not deleted. This seems to be a
bug in K8S
* Using an existing, attached volume might cause confusion if the POD is
scheduled to a different node. It's advised that user only use existing
**detached** volumes
@fatih fatih force-pushed the handle-detach-during-delete branch from 00909a5 to 571c5c8 Compare October 8, 2018 14:51
@fatih fatih merged commit 7538aad into master Oct 8, 2018
@fatih fatih deleted the handle-detach-during-delete branch October 8, 2018 15:00
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.

Connect existing block storage volumes?
3 participants