Skip to content

Commit

Permalink
add resource cleanup for fusemanager
Browse files Browse the repository at this point in the history
Signed-off-by: abushwang <[email protected]>
  • Loading branch information
wswsmao committed Dec 9, 2024
1 parent 2453b95 commit 5a4c3ff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/stargz-fuse-manager/fusemanager/fusemanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ func runFuseManager(ctx context.Context) error {
sig := <-sigCh
log.G(ctx).Infof("Got %v", sig)
fm.server.Stop()
os.Remove(address)
}()

if err = server.Serve(l); err != nil {
Expand Down
8 changes: 8 additions & 0 deletions cmd/stargz-fuse-manager/fusemanager/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ type Server struct {
// curFs is filesystem created by latest config
curFs snapshot.FileSystem
ms *bolt.DB

fuseStoreAddr string
}

func NewFuseManager(ctx context.Context, listener net.Listener, server *grpc.Server, fuseStoreAddr string) (*Server, error) {
Expand All @@ -91,6 +93,7 @@ func NewFuseManager(ctx context.Context, listener net.Listener, server *grpc.Ser
ms: db,
listener: listener,
server: server,
fuseStoreAddr: fuseStoreAddr,
}

return fm, nil
Expand Down Expand Up @@ -278,6 +281,11 @@ func (fm *Server) Close(ctx context.Context) error {
return err
}

if err := os.Remove(fm.fuseStoreAddr); err != nil {
log.G(ctx).WithError(err).Errorf("failed to remove fusestore file %s", fm.fuseStoreAddr)
return err
}

return nil
}

Expand Down

0 comments on commit 5a4c3ff

Please sign in to comment.