nvmeof: Add GroupLock to coordinate stage and unstage operations and e2e tests#6210
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a cross-volume “group mutual exclusion” lock to the NVMe-oF node server to prevent NodeStageVolume and NodeUnstageVolume from running concurrently, avoiding races that can lead to premature NVMe controller disconnects.
Changes:
- Introduces a
stageUnstageLock(lock.GroupLock) field on the NVMe-oFNodeServer. - Wraps
NodeStageVolume()with Group A acquire/release andNodeUnstageVolume()with Group B acquire/release. - Adds the
internal/util/lockimport to support the new locking behavior.
3b71e31 to
fe2a852
Compare
fe2a852 to
96907dc
Compare
|
/test ci/centos/mini-e2e/k8s-1.35/nvmeof |
2928da4 to
c2c15b1
Compare
|
/test ci/centos/mini-e2e/k8s-1.35/nvmeof |
a214c1b to
6519c04
Compare
|
/test ci/centos/mini-e2e/k8s-1.35/nvmeof |
6519c04 to
9094db7
Compare
|
/test ci/centos/mini-e2e/k8s-1.35/nvmeof |
Merge Queue Status
This pull request spent 39 minutes 51 seconds in the queue, with no time running CI. Required conditions to merge
ReasonThe merge conditions cannot be satisfied due to failing checks HintYou may have to fix your CI before adding the pull request to the queue again. |
added group mutual lock into `NodeStageVolume()` and `NodeUnStageVolume()` , because these 2 operations cannot run together. but few calls of same type can run together. Signed-off-by: gadi-didi <gadi.didi@ibm.com>
Add e2e tests to validate nvmeof NodeServer GroupLock implementation under concurrent NodeStage (Group A) and NodeUnstage (Group B) operations. The tests ensure no deadlock occurs when multiple PVCs and Pods are created and deleted simultaneously. New helper file (nvmeof_helper.go) provides reusable functions for concurrent PVC/Pod operations with proper error tracking. Two test cases cover: 1) sequential concurrent batches (create all, then delete all) 2) mixed operations with pre-created batch to guarantee continuous Group A/B switching.. Signed-off-by: gadi-didi <gadi.didi@ibm.com>
f04bd14 to
5aa1797
Compare
|
/test ci/centos/upgrade-tests-cephfs |
|
/test ci/centos/k8s-e2e-external-storage/1.35 |
|
/test ci/centos/mini-e2e-helm/k8s-1.35 |
|
/test ci/centos/upgrade-tests-rbd |
|
/test ci/centos/k8s-e2e-external-storage/1.33 |
|
/test ci/centos/mini-e2e/k8s-1.35 |
|
/test ci/centos/k8s-e2e-external-storage/1.34 |
|
/test ci/centos/mini-e2e-helm/k8s-1.33 |
|
/test ci/centos/mini-e2e-helm/k8s-1.34 |
|
/test ci/centos/mini-e2e/k8s-1.33 |
|
/test ci/centos/mini-e2e/k8s-1.34 |
|
@Mergifyio rebase |
☑️ Nothing to do, the required conditions are not metDetails
|
|
/retest ci/centos/k8s-e2e-external-storage/1.34 |
Failed with something related to CephFS: |
Merge Queue Status
This pull request spent 21 seconds in the queue, including 4 seconds running CI. Required conditions to merge
|
Describe what this PR does
This PR adds a GroupLock to prevent race conditions between stage and unstage operations that could lead to premature NVMe controller disconnects.
Added group mutual lock into
NodeStageVolume()andNodeUnStageVolume(), because these 2 operations cannot run together. but few calls of same type can run together.The Problem
Without coordination, a stage operation can connect to NVMe controllers while an unstage operation is simultaneously checking if it's safe to disconnect them. This creates a race:
Result: Stage fails with "device not found" errors.
The Solution
Add a GroupLock that allows:
Three Levels of Locking
(after the PR: nvmeof: Add mount cache and locking for safe nvme disconnect will be merged)
The code will have three levels of locks working together:
Level 1: volumeLocks (per-volume mutex)
this already exists in the code.
Level 2: stageUnstageLock (GroupLock)
the current PR introduces it.
Level 3: mountCache.mu (cache mutex)
this PR nvmeof: Add mount cache and locking for safe nvme disconnect
Lock Acquisition Order
Both NodeStageVolume and NodeUnstageVolume follow the same order:
There are unit tests for group locking here: https://github.com/ceph/ceph-csi/blob/devel/internal/util/lock/group_lock_test.go
Also, e2e tests were added.
Checklist:
guidelines in the developer
guide.
Request
notes
updated with breaking and/or notable changes for the next major release.
Show available bot commands
These commands are normally not required, but in case of issues, leave any of
the following bot commands in an otherwise empty comment in this PR:
/retest ci/centos/<job-name>: retest the<job-name>after unrelatedfailure (please report the failure too!)