sessionmount

package
v1.29.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 24 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sessionmount mounts a session's uploads and memory stores as file systems for bmaexecutor.SessionFiles (capabilities.session_files.mount, ADR-0111). It runs inside a root executor on Linux (go-fuse, direct mount(2), no fusermount): every mount is answered by this process, reads content through the session's anchor (bmaexecutor.SessionSource) and caches it by sha256. On other systems New fails and the executor copies.

Index

Constants

View Source
const (
	// ChunkBytes is the range a large file is fetched in.
	ChunkBytes = 8 << 20
	// DefaultCacheBytes bounds the cache.
	DefaultCacheBytes = 2 << 30
	// FetchTimeout bounds fetching one range (or one small file).
	FetchTimeout = 30 * time.Second
)

Content of mounted uploads is cached on the machine's disk by sha256 (ADR-0111): a file of at most ChunkBytes is fetched whole and checked before its first byte is returned; a larger one is fetched in ChunkBytes ranges as it is read and checked once every range is there. A file whose bytes do not match its digest is removed and every read of it fails. Objects nobody has open are evicted oldest first when the cache would exceed its limit. The cache is emptied when it is created: content is only trusted once this process checked it.

View Source
const FSName = "bma-session"

FSName is the file system type of the mounts ("fuse." + FSName in /proc/mounts).

Variables

View Source
var ErrDigest = errors.New("sessionmount: content does not match its digest")

ErrDigest reports content whose bytes are not its digest.

View Source
var ErrUnsupported = errors.New("sessionmount: mounting session files needs Linux")

ErrUnsupported: session files are mounted on Linux only; elsewhere New and Probe answer it and the executor copies.

Functions

func DetachStale

func DetachStale(root string) error

DetachStale detaches every mount of this package below root (left by an executor that ended without unmounting).

func Probe

func Probe(dir string) error

Probe mounts an empty read-only file system below dir, lists it and unmounts it: what the executor checks before it declares capabilities.session_files.mount.

Types

type Mounter

type Mounter struct {
	// contains filtered or unexported fields
}

Mounter keeps the mounts of every session of this executor.

func New

func New(opts Options) (*Mounter, error)

New returns a Mounter. The process must be root and /dev/fuse usable.

func (*Mounter) Mount

Mount implements bmaexecutor.SessionMounter.

func (*Mounter) Stats

Stats implements bmaexecutor.SessionMounter.

func (*Mounter) Unmount

func (m *Mounter) Unmount(sessionID string) error

Unmount implements bmaexecutor.SessionMounter.

type Options

type Options struct {
	// CacheDir holds the uploads content cache (root-only, emptied by New).
	CacheDir string
	// CacheBytes bounds it (DefaultCacheBytes when 0).
	CacheBytes int64
}

Options configures New.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL