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

implement fuse over arpc to replace nfs instead #202

Merged
merged 3 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ jobs:
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
go test -v -race ./internal/agent/nfs/... -tags=windows -count=1 -timeout 1m
go test -v -race ./internal/agent/vssfs/... -tags=windows -count=1 -timeout 1m

4 changes: 3 additions & 1 deletion cmd/windows_agent/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,9 @@ func (p *agentService) connectARPC() error {
router.Handle("ping", func(req arpc.Request) (arpc.Response, error) {
return arpc.Response{Status: 200, Data: map[string]string{"version": Version, "hostname": clientId}}, nil
})
router.Handle("backup", controllers.BackupStartHandler)
router.Handle("backup", func(req arpc.Request) (arpc.Response, error) {
return controllers.BackupStartHandler(req, router)
})
router.Handle("cleanup", controllers.BackupCloseHandler)

go func() {
Expand Down
30 changes: 1 addition & 29 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module github.com/sonroyaalmerol/pbs-plus
go 1.24

require (
bazil.org/fuse v0.0.0-20200524192727-fb710f7dfd05
github.com/alexflint/go-filemutex v1.3.0
github.com/billgraziano/dpapi v0.5.0
github.com/cockroachdb/pebble v1.1.4
github.com/cyphar/filepath-securejoin v0.4.1
github.com/fsnotify/fsnotify v1.8.0
github.com/getlantern/systray v1.2.2
Expand All @@ -15,61 +15,33 @@ require (
github.com/kardianos/service v1.2.2
github.com/mxk/go-vss v1.2.0
github.com/stretchr/testify v1.10.0
github.com/willscott/go-nfs v0.0.3
github.com/xtaci/smux v1.5.34
github.com/zeebo/xxh3 v1.0.2
golang.org/x/crypto v0.33.0
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
golang.org/x/sys v0.30.0
golang.org/x/time v0.10.0
)

require (
github.com/DataDog/zstd v1.4.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cockroachdb/errors v1.11.3 // indirect
github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/getlantern/context v0.0.0-20220418194847-3d5e7a086201 // indirect
github.com/getlantern/errors v1.0.4 // indirect
github.com/getlantern/golog v0.0.0-20230503153817-8e72de7e0a65 // indirect
github.com/getlantern/hex v0.0.0-20220104173244-ad7e4b9194dc // indirect
github.com/getlantern/hidden v0.0.0-20220104173330-f221c5a24770 // indirect
github.com/getlantern/ops v0.0.0-20231025133620-f368ab734534 // indirect
github.com/getsentry/sentry-go v0.27.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.12.0 // indirect
github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/rasky/go-xdr v0.0.0-20170124162913-1a41d1a06c93 // indirect
github.com/rogpeppe/go-internal v1.13.1 // indirect
github.com/willscott/go-nfs-client v0.0.0-20240104095149-b44639837b00 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/otel v1.34.0 // indirect
go.opentelemetry.io/otel/metric v1.34.0 // indirect
go.opentelemetry.io/otel/trace v1.34.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/text v0.22.0 // indirect
google.golang.org/protobuf v1.36.3 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
500 changes: 11 additions & 489 deletions go.sum

Large diffs are not rendered by default.

50 changes: 14 additions & 36 deletions internal/agent/controllers/arpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"sync"

"github.com/sonroyaalmerol/pbs-plus/internal/agent"
"github.com/sonroyaalmerol/pbs-plus/internal/agent/nfs"
"github.com/sonroyaalmerol/pbs-plus/internal/agent/snapshots"
"github.com/sonroyaalmerol/pbs-plus/internal/agent/vssfs"
"github.com/sonroyaalmerol/pbs-plus/internal/arpc"
"github.com/sonroyaalmerol/pbs-plus/internal/syslog"
)
Expand All @@ -21,19 +21,19 @@ var (
)

type backupSession struct {
drive string
ctx context.Context
cancel context.CancelFunc
store *agent.BackupStore
snapshot *snapshots.WinVSSSnapshot
nfsSession *nfs.NFSSession
once sync.Once
drive string
ctx context.Context
cancel context.CancelFunc
store *agent.BackupStore
snapshot *snapshots.WinVSSSnapshot
fs *vssfs.VSSFSServer
once sync.Once
}

func (s *backupSession) Close() {
s.once.Do(func() {
if s.nfsSession != nil {
s.nfsSession.Close()
if s.fs != nil {
s.fs.Close()
}
if s.snapshot != nil {
s.snapshot.Close()
Expand All @@ -48,7 +48,7 @@ func (s *backupSession) Close() {
})
}

func BackupStartHandler(req arpc.Request) (arpc.Response, error) {
func BackupStartHandler(req arpc.Request, router *arpc.Router) (arpc.Response, error) {
var drive string
if err := json.Unmarshal(req.Payload, &drive); err != nil {
return arpc.Response{Status: 400, Message: "invalid payload"}, err
Expand Down Expand Up @@ -97,31 +97,9 @@ func BackupStartHandler(req arpc.Request) (arpc.Response, error) {
}
session.snapshot = snapshot

nfsSession := nfs.NewNFSSession(session.ctx, snapshot, drive)
if nfsSession == nil {
session.Close()
err = fmt.Errorf("NFS session failed")
return arpc.Response{Status: 500, Message: err.Error()}, err
}
session.nfsSession = nfsSession

if err := store.StartNFS(drive); err != nil {
session.Close()
return arpc.Response{Status: 500, Message: err.Error()}, err
}

go func() {
defer func() {
if r := recover(); r != nil {
syslog.L.Errorf("Panic in NFS session for drive %s: %v", drive, r)
}
session.Close()
}()
err = nfsSession.Serve()
if err != nil {
syslog.L.Errorf("Error encountered while trying to serve NFS: %v", err)
}
}()
fs := vssfs.NewVSSFSServer(drive, snapshot.SnapshotPath)
fs.RegisterHandlers(router)
session.fs = fs

return arpc.Response{Status: 200, Message: "success"}, nil
}
Expand Down
101 changes: 0 additions & 101 deletions internal/agent/nfs/auth_handler.go

This file was deleted.

73 changes: 0 additions & 73 deletions internal/agent/nfs/logging.go

This file was deleted.

Loading
Loading