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

snapshot/diff : equivalent of rbd cli #829

Closed
maitredede opened this issue Feb 7, 2023 · 2 comments
Closed

snapshot/diff : equivalent of rbd cli #829

maitredede opened this issue Feb 7, 2023 · 2 comments

Comments

@maitredede
Copy link
Contributor

Hello,

I am working on a backup solution around backy2, and I am trying to reproduce the steps of the manual backup doc with go-ceph.

The full backup is pretty straightforward, but I have not yet managed to reproduce the diff backup.

The initial backup is documented as :

rbd snap create pool/vm1@backup1
rbd diff --whole-object pool/vm1@backup1 --format=json > /tmp/vm1.diff
backy2 backup -s backup1 -r /tmp/vm1.diff rbd://pool/vm1@backup1 vm1

It is equivalent as code :

conn = rados.NewConn()
ioctx = conn.OpenIOContext("pool")
image = rbd.OpenImage(ioctx, "vm1", rbd.NoSnapshot)
imageSize = image.GetSize()
image.CreateSnapshot("backup1")

diffCfg := rbd.DiffIterateConfig{
		Offset:      0,
		Length:      imageSize,
                SnapName: rbd.NoSnapshot,
		WholeObject: rbd.EnableWholeObject,
		Callback: func(o, l uint64, e int, x any){ /*removed*/ return 0 },
image.DiffIterate(diffCfg)
// save as json in  tmpfile
// call "backy2 backup"

But for the differential backup, the part that is a problem is :

rbd diff --whole-object pool/vm1@backup2 --from-snap backup1 --format=json > /tmp/vm1.diff

I don't know where the --from-snap argument should be placed in go code to get a real "diff" file. So far, I have only "full" files, with "exists": "false" entries.

The code :

conn = rados.NewConn()
ioctx = conn.OpenIOContext("pool")
image = rbd.OpenImage(ioctx, "vm1", rbd.NoSnapshot)
imageSize = image.GetSize()
image.CreateSnapshot("backup2")

diffCfg := rbd.DiffIterateConfig{
		Offset:      0,
		Length:      imageSize,
                SnapName: "backup1",
		WholeObject: rbd.EnableWholeObject,
		Callback: func(o, l uint64, e int, x any){ /*removed*/ return 0 },
image.DiffIterate(diffCfg)
// save as json in  tmpfile

Is that correct ? Should I only take "exists=true" entries ? Is it related to #279 ?

@phlogistonjohn
Copy link
Collaborator

Let me start out by saying that I'm not deeply familiar with this topic, but I want to reply before this falls off my radar. So take some of what I say with a grain of salt.

Based on a quick peek into the rbd command line tool's code I see that the the parameter --from-snap is passed into the diff_iterate2 call. That matches your Go example. What I don't see is the use of the snap name after the @ sign.

You call CreateSnapshot to make a snap of that name but to match what rbd does, I think you'd need to call SetSnapshot (see https://pkg.go.dev/github.com/ceph/[email protected]/rbd#Image.SetSnapshot)

See this utility function from ceph rbd that processes the CLI options to create the image object:
https://github.com/ceph/ceph/blob/9754cafc029e1da83f5ddd4332b69066fe6b3ffb/src/tools/rbd/Utils.cc#L909-L935

Is that correct ? Should I only take "exists=true" entries ? Is it related to #279 ?

I'm sorry to say I don't know what this means. I can say that #279 is specifically about the lack of hole detection. AFAIK this restriction (lack of hole detection) applies to any consumer of the API, so regardless of the tool being python/Go/C/C++ it would not be able to detect holes. Similarly, if the C++ based tool is using the same underlying (public) APIs you should be able to access those APIs via Go. The trick is frequently determining or verifying exactly what underlying APIs are being used.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contribution.

@github-actions github-actions bot added the Stale label Mar 10, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants