Documentation
¶
Index ¶
- Constants
- Variables
- func AcquireExclusiveGCPathLock(path string) (func(), error)
- func AcquireExclusivePathLock(path string) func()
- func AcquirePathLock(sourcePath string) func()
- func AcquirePathLockContext(ctx context.Context, path string) (func(), error)
- func AcquireRequiredExclusivePathLock(path string) (func(), error)
- func AcquireSharedGCPathLock(path string) (func(), error)
- func AcquireSharedGCPathLockContext(ctx context.Context, path string) (func(), error)
- func AcquireSharedPathLock(path string) func()
- func AcquireSharedSourceMaintenanceLock(path string) (func(), error)
- func HasNestedSourceStores(dir string) (bool, error)
- func IsReservedSourceName(name string) bool
- func IsReservedSourcePath(path string) bool
- func IsSourceGateLockFile(name string) bool
- func LastSourceUse(path string) (time.Time, error)
- func NewPathLocker(path string) sync.Locker
- func SetSourceRoot(root string) func()
- func TryAcquireExclusiveGCPathLock(path string) (func(), bool, error)
- func TryAcquireExclusivePathLock(path string) (func(), bool, error)
- func TryAcquireSourceEvictionLock(path string) (func(), bool, error)
Constants ¶
const TombstoneDirName = ".evicted"
TombstoneDirName is the directory directly below the source root that holds the tombstones of evicted source stores until they are purged (see internal/source/store). It is reserved: no source store may live in it, and everything in it is garbage.
Variables ¶
var ErrReservedSourcePath = errors.New("path is reserved for evicted source data")
ErrReservedSourcePath reports a source path in the tombstone namespace.
var ErrSourceRootNotSet = errors.New("source root is not set")
ErrSourceRootNotSet reports a source eviction without a registered source root.
Functions ¶
func AcquireExclusiveGCPathLock ¶ added in v0.120.0
AcquireExclusiveGCPathLock waits for exclusive access to a source store's GC gate.
func AcquireExclusivePathLock ¶ added in v0.120.0
func AcquireExclusivePathLock(path string) func()
AcquireExclusivePathLock takes an exclusive repository lock and excludes all other holders.
func AcquirePathLock ¶
func AcquirePathLock(sourcePath string) func()
AcquirePathLock takes an exclusive lock for a mutable source path, including across shared data volumes.
func AcquirePathLockContext ¶ added in v0.128.0
AcquirePathLockContext takes an exclusive source-path lock with cancelable acquisition. It fails if cross-process exclusion cannot be established.
func AcquireRequiredExclusivePathLock ¶ added in v0.120.0
AcquireRequiredExclusivePathLock takes an exclusive path lock and fails if cross-process exclusion cannot be established.
func AcquireSharedGCPathLock ¶ added in v0.120.0
AcquireSharedGCPathLock marks a source store as actively preparing or deploying without sharing a lock namespace with source mutation locks. Unlike ordinary source locks, it fails rather than silently dropping cross-process protection.
Below the source root (see SetSourceRoot), it also excludes the eviction of every store the path is nested in, and it records the store's use for source eviction once acquired and once released (see LastSourceUse). Paths in the tombstone namespace are rejected with ErrReservedSourcePath.
func AcquireSharedGCPathLockContext ¶ added in v0.128.0
AcquireSharedGCPathLockContext is AcquireSharedGCPathLock with cancelable acquisition.
func AcquireSharedPathLock ¶ added in v0.120.0
func AcquireSharedPathLock(path string) func()
AcquireSharedPathLock takes a shared repository lock and excludes exclusive holders.
func AcquireSharedSourceMaintenanceLock ¶ added in v0.124.0
AcquireSharedSourceMaintenanceLock takes the same shared gate as AcquireSharedGCPathLock without recording a use of the store, for maintenance such as manual mirror compaction that must neither race with nor delay source eviction.
func HasNestedSourceStores ¶ added in v0.124.0
HasNestedSourceStores reports whether a source store nested in dir has ever taken its GC gate, which leaves dir's tree lock file behind.
func IsReservedSourceName ¶ added in v0.124.0
IsReservedSourceName reports whether name, the path of a source store relative to the source root, is in the tombstone namespace.
func IsReservedSourcePath ¶ added in v0.124.0
IsReservedSourcePath reports whether path is in the tombstone namespace below the source root.
func IsSourceGateLockFile ¶ added in v0.124.0
IsSourceGateLockFile reports whether name is the name of a GC gate or tree lock file, which only exist next to the base directory of a source store or a directory a source store is nested in.
func LastSourceUse ¶ added in v0.124.0
LastSourceUse returns when the source store at path was last used by a holder of its GC gate (see AcquireSharedGCPathLock), or the zero time if it never was.
func NewPathLocker ¶ added in v0.120.0
NewPathLocker adapts the process-and-filesystem path lock to sync.Locker. It lets a callee lock multiple scoped phases without losing cross-process exclusion.
func SetSourceRoot ¶ added in v0.124.0
func SetSourceRoot(root string) func()
SetSourceRoot registers root, the data directory holding all source stores. Below it, source gates also coordinate with the stores their store is nested in, and the tombstone namespace is reserved. It returns a function restoring the previous root.
func TryAcquireExclusiveGCPathLock ¶ added in v0.120.0
TryAcquireExclusiveGCPathLock prevents new deployments from crossing their in-flight-to-labeled transition while a source store is scanned. Failure to obtain cross-process exclusion skips the sweep.
func TryAcquireExclusivePathLock ¶ added in v0.120.0
TryAcquireExclusivePathLock attempts to take an exclusive path lock without waiting. It returns false when another process or goroutine currently holds the path.
func TryAcquireSourceEvictionLock ¶ added in v0.124.0
TryAcquireSourceEvictionLock attempts to take everything needed to remove the source store at path, without waiting: its GC gate exclusively, so no deployment, scheduled run or artifact sweep uses it, its tree lock exclusively, so no store can be prepared below it, and the tree locks of the stores it is nested in shared, so none of them is evicted at the same time. It returns false if any of them is held.
path must be strictly below the source root (see SetSourceRoot) and outside the tombstone namespace.
Types ¶
This section is empty.