Documentation
¶
Index ¶
- Constants
- func CleanupByID(workspaceID string) error
- func FilesystemType(path string) string
- func HostActionRoots() []string
- func IsCommitHash(s string) bool
- func New(v *validator.Validate, opts ...workspaceOption) (*workspace, error)
- func ResolveHostActionRoot(l *zap.Logger) string
- func SweepStale(root string) ([]string, error)
- func WithGitSource(src *plantypes.GitSource) workspaceOption
- func WithLogger(l *zap.Logger) workspaceOption
- func WithTmpRoot(root string) workspaceOption
- func WithWorkspaceID(workspaceID string) workspaceOption
- type CloneErr
- type PathExistsErr
- type Source
- type Workspace
Constants ¶
const ( // DefaultTmpRootDir is the root used when no root is passed in. This allows a user of this workspace to create // workspaces in a different directory DefaultTmpRootDir string = "/tmp" // HostActionRootDir is the root the mng process uses for image-backed action // workspaces. mng runs natively on the VM host, where /tmp is tmpfs sized at // a fraction of RAM, so an action writing multi-GiB content there would // consume memory rather than disk. This path is on the root volume. HostActionRootDir string = "/opt/nuon/action-workspaces" // HostActionFallbackRootDir is used when the process can't create // HostActionRootDir, which happens when the mng unit's sandboxing leaves /opt // read-only. /var/tmp is on the root volume on a default VM image, unlike // /tmp, so it keeps action content on disk. HostActionFallbackRootDir string = "/var/tmp/nuon-action-workspaces" )
Variables ¶
This section is empty.
Functions ¶
func CleanupByID ¶
CleanupByID removes a single workspace directory by its ID. This is safe to call with parallel runner jobs since it only targets the specific workspace, not all workspace-prefixed dirs.
It sweeps every root a workspace can be created under, since the caller is a generic per-job backstop that doesn't know which root the handler chose. A missing directory is not an error.
func FilesystemType ¶ added in v0.19.1126
FilesystemType returns the filesystem backing path, resolved from the longest mount point that prefixes it. It returns an empty string where /proc/mounts isn't available (a macOS dev machine), so callers treat unknown as fine.
func HostActionRoots ¶ added in v0.19.1126
func HostActionRoots() []string
HostActionRoots are the roots an image-backed action workspace can land in, most preferred first. Cleanup has to sweep all of them, since which one a job used depends on what the process could write at the time.
func IsCommitHash ¶
IsCommitHash checks if a string matches the pattern of a git commit hash (5-40 hexadecimal characters).
func ResolveHostActionRoot ¶ added in v0.19.1126
ResolveHostActionRoot returns the first root the process can create that is not memory-backed, so a multi-GiB action writes to disk rather than RAM. Landing on a memory-backed root is the failure this exists to prevent, so it is reported rather than silently accepted.
func SweepStale ¶ added in v0.19.1126
SweepStale removes workspace directories left under root by a previous process, and returns the names it removed. A workspace is created per job execution and removed when that execution ends, so anything present before any job starts is the residue of a crash or a hard restart. Callers must only run this at startup, before the job loop claims work.
func WithGitSource ¶
WithGitSource sets a git source
func WithLogger ¶
func WithTmpRoot ¶
func WithTmpRoot(root string) workspaceOption
WithTmpRoot sets a root temp directory for the workspace
func WithWorkspaceID ¶
func WithWorkspaceID(workspaceID string) workspaceOption
WithWorkspaceID sets an ID on the workspace, prefixed for identification.
Types ¶
type PathExistsErr ¶
type PathExistsErr struct {
Path string
}
func (PathExistsErr) Error ¶
func (p PathExistsErr) Error() string