Documentation
¶
Overview ¶
Package store defines the cache-volume contract shared by storage backends.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrConflict = errors.New("store: publication conflict")
ErrConflict means the expected generation or fencing token is no longer current.
var ErrMiss = errors.New("store: cache miss")
ErrMiss means a site has no published generation for a cache key.
Functions ¶
This section is empty.
Types ¶
type ActiveLease ¶
ActiveLease prevents eviction while a job can still read a generation.
type Candidate ¶
type Candidate struct {
Key string
Generation string
Handle string
Filesystem Filesystem
}
Candidate is an immutable generation that has passed filesystem verification.
type FencingToken ¶
type FencingToken uint64
FencingToken orders writers of one key. The zero value authorises nothing.
type Filesystem ¶
Filesystem is the metadata proved immediately before a candidate is published.
UUID distinguishes the filesystem that was checked from an empty or substituted device. Clean means a read-only filesystem check completed without finding a journal or structural repair to make; non-empty alone proves neither property.
func (Filesystem) Valid ¶
func (f Filesystem) Valid() error
Valid refuses metadata that cannot identify a checked filesystem.
type KeyMatcher ¶
type KeyMatcher interface {
Match(ctx context.Context, exact string, restorePrefixes []string) (key, generation string, err error)
}
KeyMatcher finds the exact cache key or the newest current key under the first restore prefix that has a match. Stores used by transparent Actions caching implement it; ordinary sticky disks need only Store.
type Store ¶
type Store interface {
// Current reports the site's published generation for a key. ErrMiss means
// there is no pointer. Publication policies use this only after a CAS conflict.
Current(ctx context.Context, key string) (string, error)
// Create maps a new, unformatted writable volume for a cold key.
Create(ctx context.Context, key string, sizeBytes int64) (Volume, error)
// Clone maps a writable clone of generation. Empty generation means the
// site's current pointer; ErrMiss is a cold cache and never a job failure.
Clone(ctx context.Context, key, generation string) (Volume, error)
// RenewActive keeps a mounted generation out of eviction.
RenewActive(ctx context.Context, volume Volume, until time.Time) error
// AcquireWriter issues a separate storage lease and monotonically newer fence.
// While another writer's lease is live it refuses with a *WriterHeldError.
AcquireWriter(
ctx context.Context, key, holder string, ttl time.Duration,
) (WriterLease, FencingToken, error)
// ReleaseWriter gives back a writer whose publication is not going to
// happen, so the next writer need not wait out its lease. It removes exactly
// the lease it is handed — matched by identity, expiry and fence — and
// leaves anything else standing: a lease PublishCAS already consumed, one
// that expired and was replaced, one this caller never held. Nothing else
// moves: not the pointer, not a candidate, and never the fence, so a
// released lease can publish no more than an expired one can.
ReleaseWriter(ctx context.Context, lease WriterLease, fence FencingToken) error
// Snapshot verifies an already-quiesced, unmounted volume and creates an
// immutable candidate. The current pointer is unchanged on every failure.
Snapshot(ctx context.Context, volume Volume) (Candidate, error)
// PublishCAS advances the pointer only if expected, lease and fence are still
// current. A caller not permitted to publish never calls this method.
PublishCAS(
ctx context.Context,
key, expected string,
candidate Candidate,
lease WriterLease,
fence FencingToken,
) error
// Discard releases a clone. It is idempotent.
Discard(ctx context.Context, volume Volume) error
// Evict removes inactive generations and abandoned candidates while preserving
// every generation protected by a live active-clone lease.
Evict(ctx context.Context, olderThan time.Duration) error
}
Store owns cache generations at one site.
type Volume ¶
type Volume struct {
Key string
Generation string
Handle string
Device string
Lease ActiveLease
// Filesystem is proof collected after the cooperative guest unmounts a
// remotely attached volume. A host-mapped backend verifies the device itself;
// a remote EBS backend has no block path on the orchestrator and requires this.
Filesystem Filesystem
}
Volume is one writable, per-job clone mapped on the node that owns it.
Device is the concrete host path a compute backend can attach. Handle is the storage backend's stable identity and is never interpreted by a provider.
type WriterHeldError ¶
WriterHeldError is AcquireWriter's refusal while another writer's lease is live. It unwraps to ErrConflict, so a caller asking only "conflict?" is unchanged, and carries what a waiting writer has to say out loud: who holds the key and when the lease ends if nothing releases it first.
func (*WriterHeldError) Error ¶
func (e *WriterHeldError) Error() string
func (*WriterHeldError) Unwrap ¶
func (e *WriterHeldError) Unwrap() error
type WriterLease ¶
WriterLease is the short-lived right to attempt a publication for one key.
It is deliberately separate from a capacity lease. Compute remains charged until teardown is proved; a cache writer needs authority only across quiesce, verification and pointer commit, and conflating those lifetimes would make a stalled cache commit retain a machine's capacity.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ceph reaches the RBD pools a site keeps.
|
Package ceph reaches the RBD pools a site keeps. |
|
Package ebss3 implements site-local cache generations with EBS snapshots and S3 state.
|
Package ebss3 implements site-local cache generations with EBS snapshots and S3 state. |