Skip to content

librbd: create rbd_trash object during pool initialization and namespace creation - #56310

Merged
idryomov merged 3 commits into
ceph:mainfrom
ajarr:wip-64800
May 18, 2024
Merged

idryomov merged 3 commits into
ceph:mainfrom
ajarr:wip-64800

Conversation

@ajarr

@ajarr ajarr commented Mar 19, 2024 •

Copy link
Copy Markdown
Contributor
It was not possible to remove a RBD image when OSDs were full and the
'rbd_trash' object was not already created in the image's pool or pool
namespace. The 'rbd_trash' object was created in a pool or namespace
during the first instance of image removal from the pool or namespace.
If no images were ever removed from a RBD pool or namespace and the
OSDs became full, removal of images using the CLI failed. The failure
occured when trying to move the images to trash since the 'rbd_trash'
object was missing in the pool or namespace.

Fix this issue by creating the rbd_trash object in a pool when
initializing the pool as a RBD pool and when creating a RBD namespace.

Fixes: https://tracker.ceph.com/issues/64800

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows
  • jenkins test rook e2e

@ajarr
ajarr requested a review from a team as a code owner March 19, 2024 18:52
Comment thread src/librbd/image/ValidatePoolRequest.h Resolved
Comment thread src/cls/rbd/cls_rbd.cc Resolved
Comment thread src/librbd/image/ValidatePoolRequest.cc Resolved

@idryomov idryomov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These changes to ValidatePoolRequest look fine, but we aren't handling the case of images in namespaces here. RBD trash is per-namespace, so I think we are also going to need to create the trash object as part of creating a namespace in src/librbd/api/Namespace.cc and cover that with additional RemoveFullTry-like tests.

@ajarr ajarr changed the title librbd/image: create rbd_trash object during RBD pool validation librbd/image: create rbd_trash object during RBD pool validation and RBD namespace creation Mar 21, 2024
@ajarr

ajarr commented Mar 21, 2024

Copy link
Copy Markdown
Contributor Author

These changes to ValidatePoolRequest look fine, but we aren't handling the case of images in namespaces here. RBD trash is per-namespace, so I think we are also going to need to create the trash object as part of creating a namespace in src/librbd/api/Namespace.cc and cover that with additional RemoveFullTry-like tests.

Thanks! I didn't think about this case earlier.

@ajarr
ajarr requested a review from idryomov March 21, 2024 22:35
@idryomov idryomov changed the title librbd/image: create rbd_trash object during RBD pool validation and RBD namespace creation librbd: create rbd_trash object during pool validation and namespace creation Mar 22, 2024
Comment thread src/librbd/api/Namespace.cc Resolved
Comment thread src/test/librbd/test_librbd.cc Resolved
Comment thread src/test/librbd/test_librbd.cc Resolved
Comment thread src/test/librbd/test_librbd.cc Resolved
Comment thread src/librbd/api/Namespace.cc Resolved
Comment thread src/librbd/api/Namespace.cc Resolved
... of rbd namespace creation.

During rbd namespace creation, the image directory object may leak if
the initalization of the image directory fails. Initialization of image
directory involves creation of the rbd_directory object and a state
being set in the object's omap. After creation of the object, error
can occur when setting the state in the object's omap. This would fail
the rbd namespace creation and leave behind the rbd_directory object.
So try to remove the rbd_directory object when rolling back namespace
creation.

Signed-off-by: Ramana Raja <[email protected]>
Comment thread src/librbd/api/Namespace.cc Resolved
@nbalacha

nbalacha commented Apr 3, 2024 •

Copy link
Copy Markdown
Contributor

ValidatePoolRequest will not be called if rbd_validate_pool is set to false. Would be better to do this as part of the Pool->init method itself?

@ajarr

ajarr commented Apr 3, 2024

Copy link
Copy Markdown
Contributor Author

ValidatePoolRequest will not be called if rbd_validate_pool is set to false. Would be better to do this as part of the Pool->init method itself?

Good point! I think your suggestion makes sense to me. OTOH, wondering if "rbd_validate_pool" is still a useful config option? The config option was introduced in 2015, #6925 . Not sure if we want to bypass the pool validations (snapshot and overwrite support validations) anymore.

Let's check with @idryomov next week

@idryomov

idryomov commented Apr 8, 2024 •

Copy link
Copy Markdown
Contributor

OTOH, wondering if "rbd_validate_pool" is still a useful config option? The config option was introduced in 2015, #6925 . Not sure if we want to bypass the pool validations (snapshot and overwrite support validations) anymore.

It's used in tests, beyond that I don't expect it to ever be set to false. The config option is marked as advanced, but to signify that it's there purely for testing purposes, we could bump it to level: dev.

Let's check with @idryomov next week

The reasons I suggested to place rbd_trash object creation in ValidatePoolRequest:

  • The user isn't required to run rbd pool init command. When they don't, assuming rbd_validate_pool is true, ValidatePoolRequest gets invoked as part of creating the first image. If we were to do this in Pool::init(), we would miss that scenario.
  • Despite the name, ValidatePoolRequest does more than just validation -- it permanently moves the pool into self-managed snapshot mode, which acts as an important safety measure. Pre-creating rbd_trash object seemed to lie along the same lines in the robustness department to me.

@github-actions github-actions Bot added the common label Apr 9, 2024
@ajarr

ajarr commented Apr 9, 2024

Copy link
Copy Markdown
Contributor Author

OTOH, wondering if "rbd_validate_pool" is still a useful config option? The config option was introduced in 2015, #6925 . Not sure if we want to bypass the pool validations (snapshot and overwrite support validations) anymore.

It's used in tests, beyond that I don't expect it to ever be set to false. The config option is marked as advanced, but to signify that it's there purely for testing purposes, we could bump it to level: dev.

Added a commit to fix this in the latest update.

Let's check with @idryomov next week

The reasons I suggested to place rbd_trash object creation in ValidatePoolRequest:

  • The user isn't required to run rbd pool init command. When they don't, assuming rbd_validate_pool is true, ValidatePoolRequest gets invoked as part of creating the first image. If we were to do this in Pool::init(), we would miss that scenario.
  • Despite the name, ValidatePoolRequest does more than just validation -- it permanently moves the pool into self-managed snapshot mode, which acts as an important safety measure. Pre-creating rbd_trash object seemed to lie along the same lines in the robustness department to me.

Thanks a lot for the explanation. Makes sense to me.

@idryomov

Copy link
Copy Markdown
Contributor

The reasons I suggested to place rbd_trash object creation in ValidatePoolRequest:

  • The user isn't required to run rbd pool init command. When they don't, assuming rbd_validate_pool is true, ValidatePoolRequest gets invoked as part of creating the first image. If we were to do this in Pool::init(), we would miss that scenario.

Sigh, what I missed is that when ValidatePoolRequest gets invoked as part of creating the first image, it gets invoked on the data pool, not on the metadata pool and as a result we create a bogus rbd_trash object in the data pool. I guess I was trying to account for the "user hasn't run rbd pool init command" case too hard...

rbd pool init command is pretty old at this point and we raise a cluster health warning if it's not run, so going out of the way to cover that case isn't really worth it. Let's drop changes to ValidatePoolRequest and do it in Pool::init() after all.

Comment thread src/librbd/api/Namespace.cc Resolved
@idryomov

idryomov commented Apr 12, 2024 •

Copy link
Copy Markdown
Contributor

[...] when ValidatePoolRequest gets invoked as part of creating the first image, it gets invoked on the data pool, not on the metadata pool and as a result we create a bogus rbd_trash object in the data pool.

This wasn't caught by RemoveFullTryDataPool test because only the data pool is driven into the full condition there, not the metadata pool. In addition to adding rbd_pool_init() calls, it would be good to expand data pool tests to do that.

@ajarr

ajarr commented May 3, 2024 •

Copy link
Copy Markdown
Contributor Author

[...] when ValidatePoolRequest gets invoked as part of creating the first image, it gets invoked on the data pool, not on the metadata pool and as a result we create a bogus rbd_trash object in the data pool.

This wasn't caught by RemoveFullTryDataPool test because only the data pool is driven into the full condition there, not the metadata pool. In addition to adding rbd_pool_init() calls, it would be good to expand data pool tests to do that.

Made changes to remove_full_try() to also fill up the metadata pool when using a separate data pool

@ajarr
ajarr requested a review from idryomov May 3, 2024 02:08
@ajarr ajarr changed the title librbd: create rbd_trash object during pool validation and namespace creation librbd: create rbd_trash object during pool initialization and namespace creation May 3, 2024
Comment thread src/librbd/api/Namespace.cc Resolved
Comment thread src/test/librbd/test_librbd.cc Resolved
Comment thread src/test/librbd/test_librbd.cc Resolved
Comment thread src/test/librbd/test_librbd.cc Resolved
Comment thread src/test/librbd/test_librbd.cc Resolved
Comment thread src/test/librbd/test_librbd.cc Resolved
Comment thread src/librbd/api/Pool.cc Resolved
Comment thread src/librbd/api/Pool.cc Resolved
Comment thread src/test/librbd/test_librbd.cc Resolved
Comment thread src/test/librbd/test_librbd.cc Resolved
ajarr added 2 commits May 15, 2024 15:32
... and RBD namespace creation.

It was not possible to remove a RBD image when OSDs were full and the
'rbd_trash' object was not already created in the image's pool or pool
namespace. The 'rbd_trash' object was created in a pool or namespace
during the first instance of image removal from the pool or namespace.
If no images were ever removed from a RBD pool or namespace and the
OSDs became full, removal of images using the CLI failed. The failure
occured when trying to move the images to trash since the 'rbd_trash'
object was missing in the pool or namespace.

Fix this issue by creating the rbd_trash object in a pool when
initalizing the pool as a RBD pool and when creating a RBD namespace.

Fixes: https://tracker.ceph.com/issues/64800
Signed-off-by: Ramana Raja <[email protected]>
'rbd_validate_pool' option is for testing purposes only. So change
its level appropriately to 'dev'.

Signed-off-by: Ramana Raja <[email protected]>
@ajarr
ajarr requested a review from idryomov May 15, 2024 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants