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

mgr/volumes: fix dangling symlink in clone index #55838

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

neesingh-rh
Copy link
Contributor

@neesingh-rh neesingh-rh commented Feb 29, 2024

Fixes: https://tracker.ceph.com/issues/58090
Signed-off-by: Neeraj Pratap Singh neesingh@redhat.com

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

@neesingh-rh neesingh-rh marked this pull request as draft February 29, 2024 11:32
@github-actions github-actions bot added cephfs Ceph File System pybind labels Feb 29, 2024
@neesingh-rh neesingh-rh marked this pull request as ready for review March 4, 2024 06:07
@vshankar vshankar requested a review from a team March 14, 2024 17:44
with open_clone_index(self.fs, self.vol_spec) as index:
index_path = index.path.decode('utf-8')
except IndexException as e:
log.warning("failed to open clone index '{0}' for snapshot '{1}'".format(e, snapname))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: use f-string here

src/pybind/mgr/volumes/fs/volume.py Show resolved Hide resolved
@dparmar18
Copy link
Contributor

Having a test case here would be good IMO

def check_dangling_clone_index(self, snapname):
try:
if self.has_pending_clones(snapname):
pending_track_id_list = self.metadata_mgr.list_all_keys_with_specified_values_from_section('clone snaps', snapname)
Copy link
Contributor

Choose a reason for hiding this comment

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

such a long name... list_all_keys should've sufficed 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It makes it more descriptive, but I am on the fence here. @kotreshhr

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm for a descriptive function name!
This one specifically could be shortened to keys_with_value_from_section.
Another option in python would be using kwargs:

mgr.list_keys(section='section', value='value')

Copy link
Contributor

Choose a reason for hiding this comment

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

just thought that filter_keys(**kwargs) could be an even better alternative

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just thought that filter_keys(**kwargs) could be an even better alternative

I did update!

Comment on lines 851 to 856
try:
if self.has_pending_clones(snapname):
pending_track_id_list = self.metadata_mgr.list_all_keys_with_specified_values_from_section('clone snaps', snapname)
except MetadataMgrException as me:
if me.errno != -errno.ENOENT:
raise VolumeException(-me.args[0], me.args[1])
Copy link
Contributor

Choose a reason for hiding this comment

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

i'm a bit confused with this handling of exception here - has_pending_clones() already has ENOENT handled, for other exception that it would raise, you've tried to wrap it inside VolumeException, is there any other exception possible here? list_all_keys_with_specified_values_from_section() if no keys exists it returns empty list, are there exceptions possible there?

with open_clone_index(self.fs, self.vol_spec) as index:
index_path = index.path.decode('utf-8')
except IndexException as e:
log.warning("failed to open clone index '{0}' for snapshot '{1}'".format(e, snapname))
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be log.error()

Comment on lines 867 to 869
path = os.path.join(index_path, track_id)
if not os.path.exists(self.fs.readlink(path, 4096)):
self.fs.rmdir(path)
Copy link
Contributor

Choose a reason for hiding this comment

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

if it's a symlink, shouldn't unlink() be used here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess both will work. Anyways its better to use unlink()

If we come across situations where we encounter dangling
symlinks for clones due to any reason,like older versions
may have produced dangling clone symlinks which remained
post-upgrad,it needs to handled gracefully by deleting it,
presence of which may not allow deletion of the snapshot.
We are now cleaning those up in the snapshot info command.

Fixes: https://tracker.ceph.com/issues/58090
Signed-off-by: Neeraj Pratap Singh <neesingh@redhat.com>
Fixes: https://tracker.ceph.com/issues/58090
Signed-off-by: Neeraj Pratap Singh <neesingh@redhat.com>
Fixes: https://tracker.ceph.com/issues/58090
Signed-off-by: Neeraj Pratap Singh <neesingh@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants