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
@@ -5,11 +5,8 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func nativePath(p string) (string, error) {
|
||||
@@ -33,84 +30,22 @@ type Access interface {
|
||||
Release(context.Context, Config, string, string) error
|
||||
}
|
||||
|
||||
type mountedAccess struct{}
|
||||
|
||||
func (mountedAccess) Inspect(ctx context.Context, c Config, x Executor) (*Inspection, error) {
|
||||
return inspectMounted(ctx, c, x)
|
||||
}
|
||||
|
||||
func (mountedAccess) Empty(_ context.Context, p string) error { return emptyDirectory(p) }
|
||||
|
||||
func (mountedAccess) Claim(_ context.Context, c Config, fsid, id string) (io.Closer, error) {
|
||||
return claimTarget(c.Target.Mount, fsid, c.Target, id)
|
||||
}
|
||||
|
||||
func (mountedAccess) Release(_ context.Context, c Config, fsid, id string) error {
|
||||
dir := filepath.Join(c.Target.Mount, ".cephmig", "claims")
|
||||
p := filepath.Join(dir, claimName(fsid, c.Target))
|
||||
f, err := os.OpenFile(p, os.O_RDONLY|syscall.O_NOFOLLOW, 0)
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
return nil
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
b, err := io.ReadAll(io.LimitReader(f, 256))
|
||||
f.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if string(b) != id+"\n" {
|
||||
return errors.New("target claim belongs to a different job; not removed")
|
||||
}
|
||||
|
||||
if err = os.Remove(p); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, d := range []string{dir, filepath.Dir(dir)} {
|
||||
if err := os.Remove(d); err != nil && !errors.Is(err, os.ErrNotExist) && !errors.Is(err, syscall.ENOTEMPTY) && !errors.Is(err, syscall.EEXIST) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mountedAccess) Prepare(ctx context.Context, src, dst, scratch string) error {
|
||||
if err := clearQuotas(ctx, dst); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return hardlinkTopology(ctx, src, dst, scratch, true)
|
||||
}
|
||||
|
||||
func (mountedAccess) Apply(ctx context.Context, src, dst string) error {
|
||||
return quotas(ctx, src, dst, false)
|
||||
}
|
||||
|
||||
func (mountedAccess) Verify(ctx context.Context, src, dst, scratch string) error {
|
||||
if err := hardlinkTopology(ctx, src, dst, scratch, false); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return quotas(ctx, src, dst, true)
|
||||
}
|
||||
|
||||
func (e Engine) access() Access {
|
||||
if e.Access != nil {
|
||||
return e.Access
|
||||
}
|
||||
|
||||
return mountedAccess{}
|
||||
}
|
||||
func (e Engine) access() Access { return e.Access }
|
||||
|
||||
// Inspect checks both endpoints without changing them and reports what a
|
||||
// migration would transfer.
|
||||
func (e Engine) Inspect(ctx context.Context, c Config) (*Inspection, error) {
|
||||
return e.access().Inspect(ctx, c, e.Exec)
|
||||
if e.Access == nil {
|
||||
return nil, errors.New("missing access")
|
||||
}
|
||||
|
||||
return e.Access.Inspect(ctx, c, e.Exec)
|
||||
}
|
||||
|
||||
// Transport copies a source tree to the target and verifies the copy.
|
||||
type Transport interface {
|
||||
Copy(context.Context, string, string) error
|
||||
Verify(context.Context, string, string) error
|
||||
}
|
||||
|
||||
// Round describes one snapshot transfer handed to a RoundTransport.
|
||||
@@ -149,16 +84,9 @@ type TransferStats struct {
|
||||
Seconds float64 `json:"seconds"`
|
||||
}
|
||||
|
||||
// NewEngine returns an Engine for c.Backend and a Closer that releases its
|
||||
// connections. It never silently falls back from native I/O to mounted/rsync I/O.
|
||||
// NewEngine returns an Engine with the native libcephfs backend and a Closer
|
||||
// that releases its connections. Builds without the build tag ceph return an
|
||||
// error.
|
||||
func NewEngine(ctx context.Context, c Config, x Executor, log io.Writer) (Engine, io.Closer, error) {
|
||||
if c.Backend == "native" {
|
||||
return openNativeEngine(ctx, c, x, log)
|
||||
}
|
||||
|
||||
return Engine{Exec: x, Log: log, Transport: Rsync{Exec: x, Log: log, BandwidthKiB: c.BandwidthKiB}}, nopCloser{}, nil
|
||||
return openNativeEngine(ctx, c, x, log)
|
||||
}
|
||||
|
||||
type nopCloser struct{}
|
||||
|
||||
func (nopCloser) Close() error { return nil }
|
||||
Reference in new issue
Block a user