feat!: remove the rsync backend
The native libcephfs backend is the only transfer path. The rsync transport, the mounted-filesystem access and its helpers (mount check, path resolution below a mount, mount claim, quota and hardlink repair through the mount) are removed, together with the rsync lab test and the client image that only added rsync. The claim and release tests now exercise the native claim through a local test file system with real flock locks. BREAKING CHANGE: "backend": "rsync" and the endpoint field "mount" are rejected. "backend" is optional and only accepts "native"; jobs created with "native" resume without it. Journals of rsync jobs cannot be resumed. Builds without the build tag ceph only support doctor and status. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f0ea1fd7cd
commit
330a3ec12c
31 files changed
+263
-1522
No files matched your search
@@ -0,0 +1,126 @@
|
||||
package migration
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
"git.zb-server.de/Sebi/CephfsMig/internal/storage"
|
||||
)
|
||||
|
||||
// rootFS is a storage.FS rooted at a local directory, with real flock
|
||||
// locks, for the claim operations.
|
||||
type rootFS struct {
|
||||
storage.FS
|
||||
root string
|
||||
}
|
||||
|
||||
func (f rootFS) path(p string) string { return filepath.Join(f.root, p) }
|
||||
|
||||
func (f rootFS) Stat(p string) (storage.Node, error) { return diskFS{}.Stat(f.path(p)) }
|
||||
func (f rootFS) Mkdir(p string, mode uint32) error { return os.Mkdir(f.path(p), os.FileMode(mode)) }
|
||||
func (f rootFS) Unlink(p string) error { return syscall.Unlink(f.path(p)) }
|
||||
func (f rootFS) Rmdir(p string) error { return syscall.Rmdir(f.path(p)) }
|
||||
func (f rootFS) Close() error { return nil }
|
||||
|
||||
func (f rootFS) Open(p string, flags int, mode uint32) (storage.File, error) {
|
||||
file, err := os.OpenFile(f.path(p), flags, os.FileMode(mode))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return lockingFile{diskFile{file}}, nil
|
||||
}
|
||||
|
||||
type lockingFile struct{ diskFile }
|
||||
|
||||
func (f lockingFile) Lock(uint64) error {
|
||||
return syscall.Flock(int(f.Fd()), syscall.LOCK_EX|syscall.LOCK_NB)
|
||||
}
|
||||
|
||||
func claimAccess(root string) nativeAccess {
|
||||
fs := rootFS{root: root}
|
||||
return nativeAccess{&nativeTransport{target: fs, openTarget: func() (storage.FS, error) { return fs, nil }}}
|
||||
}
|
||||
|
||||
func TestNativeClaimExcludesOtherJobsAndSurvivesStateLoss(t *testing.T) {
|
||||
ctx, c := context.Background(), testConfig()
|
||||
a := claimAccess(t.TempDir())
|
||||
first, err := a.Claim(ctx, c, "fsid", "job-one")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if second, err := a.Claim(ctx, c, "fsid", "job-one"); err == nil {
|
||||
second.Close()
|
||||
t.Fatal("concurrent use allowed")
|
||||
}
|
||||
|
||||
if err := first.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if other, err := a.Claim(ctx, c, "fsid", "job-two"); err == nil {
|
||||
other.Close()
|
||||
t.Fatal("different job stole target")
|
||||
}
|
||||
|
||||
resumed, err := a.Claim(ctx, c, "fsid", "job-one")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resumed.Close()
|
||||
}
|
||||
|
||||
func TestNativeReleaseRemovesOnlyOwnClaim(t *testing.T) {
|
||||
ctx, root := context.Background(), t.TempDir()
|
||||
a := claimAccess(root)
|
||||
c := testConfig()
|
||||
other := c
|
||||
other.Target.Subvolume = "other"
|
||||
for _, x := range []struct {
|
||||
c Config
|
||||
id string
|
||||
}{{c, "job-one"}, {other, "job-two"}} {
|
||||
f, err := a.Claim(ctx, x.c, "fsid", x.id)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
f.Close()
|
||||
}
|
||||
|
||||
if err := a.Release(ctx, c, "fsid", "job-two"); err == nil {
|
||||
t.Fatal("removed the claim of a different job")
|
||||
}
|
||||
|
||||
if err := a.Release(ctx, c, "fsid", "job-one"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
claims := filepath.Join(root, ".cephmig", "claims")
|
||||
if _, err := os.Stat(filepath.Join(claims, claimName("fsid", c.Target))); !errors.Is(err, os.ErrNotExist) {
|
||||
t.Fatalf("own claim still present: %v", err)
|
||||
}
|
||||
|
||||
if _, err := os.Stat(filepath.Join(claims, claimName("fsid", other.Target))); err != nil {
|
||||
t.Fatalf("claim of another job removed: %v", err)
|
||||
}
|
||||
|
||||
if err := a.Release(ctx, other, "fsid", "job-two"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := os.Stat(filepath.Join(root, ".cephmig")); !errors.Is(err, os.ErrNotExist) {
|
||||
t.Fatalf("empty claim directories kept: %v", err)
|
||||
}
|
||||
|
||||
// Releasing again is a no-op.
|
||||
if err := a.Release(ctx, c, "fsid", "job-one"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user