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

Node service vs idempotency #307

Closed
bertinatto opened this issue Jun 11, 2019 · 13 comments · Fixed by #702
Closed

Node service vs idempotency #307

bertinatto opened this issue Jun 11, 2019 · 13 comments · Fixed by #702
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@bertinatto
Copy link
Member

/kind bug

I think our inFlight object isn't providing idempotency for the node service. For example:

  1. CO calls NodeStageVolume for a 500 GB volume.
  2. The driver starts formatting the volume.
  3. CO calls calls NodeStageVolume again for the same volume.
  4. The driver returns an error [0] because the first request NodeStageVolume call hasn't returned yet (the driver is still formatting the volume).

Since the call is supposed to be idempotent, we shouldn't return an error in step 4.

I believe the best option is to have a per-volume lock, so any operation (stage, publish, resize etc.) on a specific volume will be executed synchronously.

[0] https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/v0.3.0/pkg/driver/node.go#L84-L91

CC @leakingtapan @dkoshkin

@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Jun 11, 2019
@leakingtapan
Copy link
Contributor

The inFlight object locks around the NodeStageVolumeRequest which contains the volume ID with other fields like GetStagingTargetPath, what if there is an node request for the same volume but different path?

@bertinatto
Copy link
Member Author

bertinatto commented Jun 12, 2019

The inFlight object locks around the NodeStageVolumeRequest which contains the volume ID with other fields like GetStagingTargetPath

I think the inFlight object only locks when the key (which is a request's hash containing the volume ID and other fields, like you mentioned above) is being inserted and deleted:

func (db *InFlight) Insert(entry Idempotent) bool {
db.mux.Lock()
defer db.mux.Unlock()
hash := entry.String()
_, ok := db.inFlight[hash]
if ok {
return false
}
db.inFlight[hash] = true
return true
}

It won't lock until a NodeStageVolume call completes to start processing the second one, it'll return an error for the latter. Note that the responses of these two calls (which are the equally addressed to the same volume, path etc.) will be different (no idempotency).

what if there is an node request for the same volume but different path?

Currently the driver will process both requests at the same time, which is OK in this case. However, if the request is for the same volume and same path, it'll return an error, which is not correct.

Note that the problem is not about the key being used, but instead the error returned by the driver. According to the specs, the key should contain the volume ID, the path and the capabilities. We are mostly OK here, but we can't return an error if the same key is being processed:

This operation MUST be idempotent. If the volume corresponding to the volume_id is already staged to the staging_target_path, and is identical to the specified volume_capability the Plugin MUST reply 0 OK.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 10, 2019
@leakingtapan
Copy link
Contributor

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 11, 2019
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 10, 2019
@leakingtapan
Copy link
Contributor

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 8, 2020
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 7, 2020
@leakingtapan
Copy link
Contributor

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 13, 2020
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 12, 2020
@leakingtapan
Copy link
Contributor

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 2, 2020
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 31, 2020
@bertinatto
Copy link
Member Author

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 2, 2020
@AndyXiangLi
Copy link
Contributor

AndyXiangLi commented Jan 20, 2021

@bertinatto
I think idempotence already get handled here https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/master/pkg/driver/node.go#L193
Correct me if I'm wrong, as per https://github.com/container-storage-interface/spec/blob/master/spec.md#concurrency In the example, if CO make second NodeStageVolume call when the first NodeStageVolume call is still in progress and not yet returned. Driver should return error code ABORTED in this case (step 4). Feels like we only need to fix the error code we return.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants