Conversation
Once the client logged in and IOs are done, one of the iscsi gateway nodes will hold the exclusive lock and be the lock owner in tcmu-runner. When we try rollback the snap shot of the image, it will become readonly and failed even DELETE the LUN from the client host. This patch will just get the lock owner and break it when doing the LUN's DELETE opration. Signed-off-by: Zhang Zhuoyu <zhangzhuoyu@cmss.chinamobile.com> Signed-off-by: Xiubo Li <lixiubo@cmss.chinamobile.com>
dillaman
reviewed
Apr 30, 2018
| with cluster.open_ioctx(pool_name) as ioctx: | ||
| with rbd.Image(ioctx, image_name) as image: | ||
|
|
||
| if len(image.list_lockers()): |
There was a problem hiding this comment.
Nit: no need, just invoke the line below but wrap it w/ a try/except clause to catch rbd.ImageNotFound and rbd.InvalidArgument.
| lun_list.remove(disk) | ||
|
|
||
| pool_name, image_name = disk.split('.') | ||
| with rados.Rados(conffile=settings.config.cephconf) as cluster: |
There was a problem hiding this comment.
Nit: could collapse into a single with:
with rados.Rados(conffile=settings.config.cephconf) as cluster, \
cluster.open_ioctx(pool_name) as ioctx, \
rbd.Image(ioctx, image_name) as image:
| lock_owners = list(image.lock_get_owners()) | ||
| eq(1, len(lock_owners)) | ||
| eq(rbd.RBD_LOCK_MODE_EXCLUSIVE, lock_owners[0]['mode']) | ||
| image.lock_break(rbd.RBD_LOCK_MODE_EXCLUSIVE, lock_owners[0]['owner']) |
There was a problem hiding this comment.
Nit: wrap w/ try/except to avoid race conditions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Once the client logged in and IOs are done, one of the iscsi
gateway nodes will hold the exclusive lock and be the lock
owner in tcmu-runner.
When we try rollback the snap shot of the image, it will become
readonly and failed even DELETE the LUN from the client host.
This patch will just get the lock owner and break it when doing
the LUN's DELETE opration.
Signed-off-by: Zhang Zhuoyu zhangzhuoyu@cmss.chinamobile.com
Signed-off-by: Xiubo Li lixiubo@cmss.chinamobile.com