Skip to content

mgr/vol: make "snapshot getpath" cmd work with v1 and legacy#63127

Merged
rishabh-d-dave merged 4 commits intoceph:mainfrom
rishabh-d-dave:vols-snappath-v1-and-legacy
May 12, 2025
Merged

mgr/vol: make "snapshot getpath" cmd work with v1 and legacy#63127
rishabh-d-dave merged 4 commits intoceph:mainfrom
rishabh-d-dave:vols-snappath-v1-and-legacy

Conversation

@rishabh-d-dave
Copy link
Contributor

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

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

@rishabh-d-dave rishabh-d-dave requested review from a team and vshankar May 6, 2025 10:37
@rishabh-d-dave rishabh-d-dave force-pushed the vols-snappath-v1-and-legacy branch 2 times, most recently from 390a884 to 2b785d2 Compare May 6, 2025 12:02
@rishabh-d-dave rishabh-d-dave force-pushed the vols-snappath-v1-and-legacy branch from 2b785d2 to 222be9d Compare May 6, 2025 12:59
Signed-off-by: Rishabh Dave <ridave@redhat.com>
Signed-off-by: Rishabh Dave <ridave@redhat.com>
@rishabh-d-dave
Copy link
Contributor Author

jenkins test make check arm64

@vshankar
Copy link
Contributor

vshankar commented May 6, 2025

test_snap_schedules.py handcraft the snapshot path in _get_subvol_snapdir_path(). Suggest, changing that to use this new interface.

@rishabh-d-dave rishabh-d-dave force-pushed the vols-snappath-v1-and-legacy branch from 222be9d to b2213ec Compare May 6, 2025 14:20
@rishabh-d-dave
Copy link
Contributor Author

test_snap_schedules.py handcraft the snapshot path in _get_subvol_snapdir_path(). Suggest, changing that to use this new interface.

@vshankar There must be more such instances where such improvements can be made, let's do that on a separate PR?

@vshankar
Copy link
Contributor

vshankar commented May 6, 2025

test_snap_schedules.py handcraft the snapshot path in _get_subvol_snapdir_path(). Suggest, changing that to use this new interface.

@vshankar There must be more such instances where such improvements can be made, let's do that on a separate PR?

How many are such instances? It should be a straight-forward usage of the new API, isn't it?

@rishabh-d-dave
Copy link
Contributor Author

test_snap_schedules.py handcraft the snapshot path in _get_subvol_snapdir_path(). Suggest, changing that to use this new interface.

@vshankar There must be more such instances where such improvements can be made, let's do that on a separate PR?

How many are such instances? It should be a straight-forward usage of the new API, isn't it?

@vshankar
I think I've seen a few in test_volumes.py as well. Also, it's beyond scope of this PR, we only want to add tests for this command against v1 and legacy.

@vshankar
Copy link
Contributor

vshankar commented May 6, 2025

@vshankar
I think I've seen a few in test_volumes.py as well. Also, it's beyond scope of this PR, we only want to add tests for this command against v1 and legacy.

It's not entirely beyond the scope -- you get tests run for other uses. If its just test_volumes and test_snap_schedule, I suggest changing those to use the new interface.

@rishabh-d-dave
Copy link
Contributor Author

@vshankar
I think I've seen a few in test_volumes.py as well. Also, it's beyond scope of this PR, we only want to add tests for this command against v1 and legacy.

It's not entirely beyond the scope -- you get tests run for other uses. If its just test_volumes and test_snap_schedule, I suggest changing those to use the new interface.

@vshankar The more we make such changes in the tests, the higher will be chance that QA might fail due to some error in making those changes. And that will make it longer to merge this PR. I would really prefer to avoid it in interest of time.

@vshankar
Copy link
Contributor

vshankar commented May 6, 2025

@vshankar
I think I've seen a few in test_volumes.py as well. Also, it's beyond scope of this PR, we only want to add tests for this command against v1 and legacy.

It's not entirely beyond the scope -- you get tests run for other uses. If its just test_volumes and test_snap_schedule, I suggest changing those to use the new interface.

@vshankar The more we make such changes in the tests, the higher will be chance that QA might fail due to some error in making those changes. And that will make it longer to merge this PR. I would really prefer to avoid it in interest of time.

I understand that and I also understand the push that's required to get stuff merged. But when things break (and that has happened before), a lot many things have to be redone. So, let's spend a bit more time in ensuring nothing obvious breaks.

@rishabh-d-dave
Copy link
Contributor Author

But when things break (and that has happened before), a lot many things have to be redone.

@vshankar
AFAIU, test_snap_schedules.py and test_volumes.py will get refactored with this. Nothing will break if don't make that change. Anyways, will proceed to make the change.

@rishabh-d-dave
Copy link
Contributor Author

@vshankar I've made the changes in test_volumes.py. I also went through test_snap_schedules.py, specifically the method you mentioned (_get_subvol_snapdir_path()). This method constructs path for parent directory of snapshot prefix directory and not the path of a specific snapshot directory, therefore this command won't help.

@vshankar
Copy link
Contributor

vshankar commented May 6, 2025

@vshankar I've made the changes in test_volumes.py. I also went through test_snap_schedules.py, specifically the method you mentioned (_get_subvol_snapdir_path()). This method constructs path for parent directory of snapshot prefix directory and not the path of a specific snapshot directory, therefore this command won't help.

Really? If you see:

    def _get_subvol_snapdir_path(self, version, subvol, group):
	args = ['subvolume', 'getpath', 'cephfs', subvol]
        if group:
            args += ['--group_name', group]

        path = self.get_ceph_cmd_stdout("fs", *args).rstrip()
        if version >= 2:
            path += "/.."
        return path[1:]

It first fetches the subvolume path and then for v2 version where the snapshots are taken a level up, /.. is suffixed and for earlier versions, the subvolume path is used as snapshot path. Can you fault my logic here?

@rishabh-d-dave
Copy link
Contributor Author

@vshankar I've made the changes in test_volumes.py. I also went through test_snap_schedules.py, specifically the method you mentioned (_get_subvol_snapdir_path()). This method constructs path for parent directory of snapshot prefix directory and not the path of a specific snapshot directory, therefore this command won't help.

Really? If you see:

    def _get_subvol_snapdir_path(self, version, subvol, group):
	args = ['subvolume', 'getpath', 'cephfs', subvol]
        if group:
            args += ['--group_name', group]

        path = self.get_ceph_cmd_stdout("fs", *args).rstrip()
        if version >= 2:
            path += "/.."
        return path[1:]

It first fetches the subvolume path and then for v2 version where the snapshots are taken a level up, /.. is suffixed

Yes, so parent path of snapshot prefix directory is being derived (/volumes/_nogroup/subvol1) and what snapshot getpath returns is path to a specific snapshot (/volumes/_nogroup/subvol1/<uuid>/.snap/<snap-name>). Both are different. So latter can't replace former.

Also, snapshot getpath requires snap name to be passed. We neither have snap names passed to this method nor in code region that call this method.

and for earlier versions, the subvolume path is used as snapshot path. Can you fault my logic here?

Even for earlier version path derived is not snapshot path. Snapshot prefix directory is discovered and attached to it later.

Overall, goal in both the cases is to find the path to the snapshot prefix directory and not path to a specific snapshot.

/volumes/_nogroup/subvol1 vs /volumes/_nogroup/subvol1/<uuid>/.snap/<snap-name> or /volumes/_nogroup/subvol1/.snap/<snap-name>.

@rishabh-d-dave
Copy link
Contributor Author

jenkins test make check

@rishabh-d-dave
Copy link
Contributor Author

jenkins test make check arm64

@rishabh-d-dave
Copy link
Contributor Author

jenkins test api

@vshankar
Copy link
Contributor

vshankar commented May 6, 2025

@vshankar I've made the changes in test_volumes.py. I also went through test_snap_schedules.py, specifically the method you mentioned (_get_subvol_snapdir_path()). This method constructs path for parent directory of snapshot prefix directory and not the path of a specific snapshot directory, therefore this command won't help.

Really? If you see:

    def _get_subvol_snapdir_path(self, version, subvol, group):
	args = ['subvolume', 'getpath', 'cephfs', subvol]
        if group:
            args += ['--group_name', group]

        path = self.get_ceph_cmd_stdout("fs", *args).rstrip()
        if version >= 2:
            path += "/.."
        return path[1:]

It first fetches the subvolume path and then for v2 version where the snapshots are taken a level up, /.. is suffixed

Yes, so parent path of snapshot prefix directory is being derived (/volumes/_nogroup/subvol1) and what snapshot getpath returns is path to a specific snapshot (/volumes/_nogroup/subvol1/<uuid>/.snap/<snap-name>). Both are different. So latter can't replace former.

Also, snapshot getpath requires snap name to be passed. We neither have snap names passed to this method nor in code region that call this method.

and for earlier versions, the subvolume path is used as snapshot path. Can you fault my logic here?

Even for earlier version path derived is not snapshot path. Snapshot prefix directory is discovered and attached to it later.

Overall, goal in both the cases is to find the path to the snapshot prefix directory and not path to a specific snapshot.

/volumes/_nogroup/subvol1 vs /volumes/_nogroup/subvol1/<uuid>/.snap/<snap-name> or /volumes/_nogroup/subvol1/.snap/<snap-name>.

Ah! I see -- we need the snapshot name. I was thinking in terms of path to snapdir rather than paths to the exact snapshot. Makes sense.

@rishabh-d-dave
Copy link
Contributor Author

@vshankar Does rest of the PR look okay?

Copy link
Contributor

@vshankar vshankar left a comment

Choose a reason for hiding this comment

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

@rishabh-d-dave I'm seeing dup code from existing tests. Better to clean those up.

from .kernel_mount import KernelMount

if isinstance(self.mount_a, KernelMount):
return self.mount_a.client_config.get('snapdirname', '.snap')
Copy link
Contributor

Choose a reason for hiding this comment

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

why not use self.mount_a.snapdirname?

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 is available in KernelMount instances but not in FuseMount instances.

Copy link
Member

@batrick batrick left a comment

Choose a reason for hiding this comment

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

I guess since this only changes tests then the current code with v1 works?

@vshankar
Copy link
Contributor

vshankar commented May 7, 2025

I guess since this only changes tests then the current code with v1 works?

... and legacy too (which gets upgraded to v1 anyway). But yeh, I have that question too :)

legacy subvolumes.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
the path to a specific snapshot wherever possible.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
@rishabh-d-dave rishabh-d-dave force-pushed the vols-snappath-v1-and-legacy branch from e7744d5 to 3e70066 Compare May 8, 2025 11:13
@rishabh-d-dave
Copy link
Contributor Author

I guess since this only changes tests then the current code with v1 works?

Yes, wasn't that why we decided to switch from returning ENOTSUP to supporting it?

@rishabh-d-dave rishabh-d-dave requested review from batrick and vshankar May 8, 2025 11:27
@rishabh-d-dave
Copy link
Contributor Author

rishabh-d-dave commented May 8, 2025

@vshankar @batrick PTAL

@rishabh-d-dave
Copy link
Contributor Author

jenkins test make check arm64

@vshankar
Copy link
Contributor

vshankar commented May 8, 2025

I guess since this only changes tests then the current code with v1 works?

Yes, wasn't that why we decided to switch from returning ENOTSUP to supporting it?

That was not the question @batrick asked. @batrick wanted to confirm if the only thing required is to add tests since the snapshot getpath operation is also supported by v1/legacy.

@rishabh-d-dave
Copy link
Contributor Author

rishabh-d-dave commented May 8, 2025

I guess since this only changes tests then the current code with v1 works?

Yes, wasn't that why we decided to switch from returning ENOTSUP to supporting it?

That was not the question @batrick asked. @batrick wanted to confirm if the only thing required is to add tests since the snapshot getpath operation is also supported by v1/legacy.

Yes, only thing required is to add tests. That is, the current code for v1 and legacy already supports snapshot getpath command. This is exactly what led us to change our decision and close the previous PR.

@rishabh-d-dave
Copy link
Contributor Author

jenkins test make check

1 similar comment
@rishabh-d-dave
Copy link
Contributor Author

jenkins test make check

@batrick
Copy link
Member

batrick commented May 8, 2025

I guess since this only changes tests then the current code with v1 works?

Yes, wasn't that why we decided to switch from returning ENOTSUP to supporting it?

That was not the question @batrick asked. @batrick wanted to confirm if the only thing required is to add tests since the snapshot getpath operation is also supported by v1/legacy.

Yes, only thing required is to add tests. That is, the current code for v1 and legacy already supports snapshot getpath command. This is exactly what led us to change our decision and close the previous PR.

If this is only adding tests then, do we need the extreme urgency of getting this merged?

Copy link
Member

@batrick batrick left a comment

Choose a reason for hiding this comment

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

fine w/ me

@rishabh-d-dave
Copy link
Contributor Author

jenkins test make check

@rishabh-d-dave
Copy link
Contributor Author

jenkins test make check arm64

Copy link
Contributor Author

@rishabh-d-dave rishabh-d-dave left a comment

Choose a reason for hiding this comment

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

@rishabh-d-dave rishabh-d-dave dismissed vshankar’s stale review May 12, 2025 05:50

Requested changes were incorporated

@rishabh-d-dave rishabh-d-dave added the wip-rishabh-testing Rishabh's testing label label May 12, 2025
@rishabh-d-dave rishabh-d-dave merged commit beed49e into ceph:main May 12, 2025
18 checks passed
@rishabh-d-dave rishabh-d-dave deleted the vols-snappath-v1-and-legacy branch May 12, 2025 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants