runnerstate

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package runnerstate owns the private Linux runner directory and runtime lock.

Index

Constants

View Source
const ContentStoreName = "content-store.json"
View Source
const MaxContentStoreBytes = 2 << 10

Variables

View Source
var (
	ErrInvalid = errors.New("invalid_runner_state")
	ErrLocked  = errors.New("runner_already_running")
)
View Source
var ErrContentCorrupt = errors.New("invalid_runner_content")

Functions

This section is empty.

Types

type ContentFileIdentity

type ContentFileIdentity struct {
	IncarnationID string
	WitnessSHA256 string
	ChangeToken   string
}

type ContentReader

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

ContentReader is a verified, seekable private file. State.Close closes its descriptor; cancellation affects only this stream. Read and Seek reject a replaced file or state directory without rehashing the complete file.

func (*ContentReader) Check

func (reader *ContentReader) Check() error

func (*ContentReader) Close

func (reader *ContentReader) Close() error

func (*ContentReader) PhysicalIdentity

func (reader *ContentReader) PhysicalIdentity(storeID string) (ContentFileIdentity, error)

PhysicalIdentity binds the verified open file to its kernel birth identity. Unsupported filesystems fail explicitly; ctime never substitutes for btime.

func (*ContentReader) Read

func (reader *ContentReader) Read(buffer []byte) (int, error)

func (*ContentReader) Seek

func (reader *ContentReader) Seek(offset int64, whence int) (int64, error)

type ContentStoreIdentity

type ContentStoreIdentity struct {
	Contract       int       `json:"contract"`
	StoreID        string    `json:"store_id"`
	InstallationID string    `json:"installation_id"`
	CreatedAt      time.Time `json:"created_at"`
}

type ContentStoreMarker

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

func (*ContentStoreMarker) Check

func (marker *ContentStoreMarker) Check(ctx context.Context) error

func (*ContentStoreMarker) Identity

func (marker *ContentStoreMarker) Identity() ContentStoreIdentity

type State

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

func Open

func Open(path string) (*State, error)

Open holds an advisory runtime lock until Close. The inode is retained after release so another process cannot accidentally lock a replacement inode.

func (*State) AvailableBytes

func (state *State) AvailableBytes() (uint64, error)

func (*State) Close

func (state *State) Close() error

func (*State) ContentFiles

func (state *State) ContentFiles(ctx context.Context) (count uint64, err error)

ContentFiles counts retained complete files and scratch names, including malformed or failed content names. They continue consuming admission quota.

func (*State) EnsureContentStore

func (state *State) EnsureContentStore(
	ctx context.Context,
	installationID string,
	at time.Time,
) (*ContentStoreMarker, error)

func (*State) OpenContent

func (state *State) OpenContent(
	ctx context.Context,
	identity jobcontract.ContentIdentity,
) (reader *ContentReader, err error)

func (*State) Path

func (state *State) Path() string

func (*State) PutContent

func (state *State) PutContent(
	ctx context.Context,
	identity jobcontract.ContentIdentity,
	source io.Reader,
) (created bool, err error)

PutContent verifies every incoming body, including duplicate uploads. Only a nil error confirms durable publication; created then distinguishes a new file from existing identical content. Failed partials and corrupt files are kept. A blocking source reader must honor ctx itself, as an HTTP request body does.

func (*State) ReadPrivate

func (state *State) ReadPrivate(name string, limit int64) ([]byte, error)

func (*State) ReplacePrivate

func (state *State) ReplacePrivate(name string, document []byte) error

ReplacePrivate atomically replaces a mutable private control document. The runtime lock and its owning controller serialize writers; identities use WriteNew.

func (*State) SyncPrivate

func (state *State) SyncPrivate(name string) error

SyncPrivate confirms both file content and its directory entry are durable.

func (*State) UsedBytes

func (state *State) UsedBytes(ctx context.Context) (uint64, error)

func (*State) WriteNew

func (state *State) WriteNew(name string, document []byte) error

WriteNew commits one private file without replacing an existing identity.

Jump to

Keyboard shortcuts

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