orchestrator

package
v0.0.0-...-5cac5d7 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2025 License: Apache-2.0, BSD-2-Clause, ISC, + 1 more Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const BugReportZipFileName = "cvd_bugreport.zip"
View Source
const ErrMsgLaunchCVDFailed = "failed to launch cvd"
View Source
const HeaderBuildAPICreds = "X-Cutf-Host-Orchestrator-BuildAPI-Creds"
View Source
const HeaderUserProject = "X-Cutf-Host-Orchestrator-BuildAPI-Creds-User-Project-ID"
View Source
const (
	URLQueryKeyIncludeAdbBugReport = "include_adb_bugreport"
)

Variables

This section is empty.

Functions

func CVDLogsDir

func CVDLogsDir(ctx hoexec.ExecContext, groupName, name string) (string, error)

func CreateCVD

func CreateCVD(ctx hoexec.ExecContext, p startCVDParams) (*cvd.Group, error)

func CvdGroupToAPIObject

func CvdGroupToAPIObject(group *cvd.Group) []*apiv1.CVD

func CvdInstanceToAPIObject

func CvdInstanceToAPIObject(instance *cvd.Instance, group string) *apiv1.CVD

func NewChunkState

func NewChunkState(fileSize int64) *chunkState

func ValidateCreateSnapshotRequest

func ValidateCreateSnapshotRequest(r *apiv1.CreateSnapshotRequest) error

func ValidateSnapshotID

func ValidateSnapshotID(v string) error

func ValidateStartCVDRequest

func ValidateStartCVDRequest(r *apiv1.StartCVDRequest) error

Types

type BuildAPICredentialsConfig

type BuildAPICredentialsConfig struct {
	UseGCEMetadata bool
}

type CVDBundleFetcher

type CVDBundleFetcher interface {
	// Fetches artifacts to launch a Cuttlefish device
	Fetch(outDir string, mainBuild cvd.AndroidBuild, opts ExtraCVDOptions) error
}

type Config

type Config struct {
	Paths                  IMPaths
	AndroidBuildServiceURL string
	BuildAPICredentials    BuildAPICredentialsConfig
}

type Controller

type Controller struct {
	Config                  Config
	OperationManager        OperationManager
	WaitOperationDuration   time.Duration
	UserArtifactsManager    UserArtifactsManager
	ImageDirectoriesManager ImageDirectoriesManager
	DebugVariablesManager   *debug.VariablesManager
}

func (*Controller) AddRoutes

func (c *Controller) AddRoutes(router *mux.Router)

type CreateCVDAction

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

func NewCreateCVDAction

func NewCreateCVDAction(opts CreateCVDActionOpts) *CreateCVDAction

func (*CreateCVDAction) Run

func (a *CreateCVDAction) Run() (apiv1.Operation, error)

type CreateCVDActionOpts

type CreateCVDActionOpts struct {
	Request                  *apiv1.CreateCVDRequest
	HostValidator            Validator
	Paths                    IMPaths
	OperationManager         OperationManager
	ExecContext              exec.ExecContext
	CVDBundleFetcher         CVDBundleFetcher
	UUIDGen                  func() string
	UserArtifactsDirResolver UserArtifactsDirResolver
	FetchCredentials         cvd.FetchCredentials
	BuildAPIBaseURL          string
}

type CreateCVDBugReportAction

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

func (*CreateCVDBugReportAction) Run

type CreateCVDBugReportActionOpts

type CreateCVDBugReportActionOpts struct {
	Group               string
	IncludeADBBugreport bool
	Paths               IMPaths
	OperationManager    OperationManager
	ExecContext         exec.ExecContext
	UUIDGen             func() string
}

type CreateSnapshotAction

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

func NewCreateSnapshotAction

func NewCreateSnapshotAction(opts CreateSnapshotActionOpts) *CreateSnapshotAction

func (*CreateSnapshotAction) Run

type CreateSnapshotActionOpts

type CreateSnapshotActionOpts struct {
	Request          *apiv1.CreateSnapshotRequest
	Selector         cvd.InstanceSelector
	Paths            IMPaths
	OperationManager OperationManager
	ExecContext      exec.ExecContext
}

type DisplayAddAction

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

func NewDisplayAddAction

func NewDisplayAddAction(opts DisplayAddActionOpts) *DisplayAddAction

func (*DisplayAddAction) Run

type DisplayAddActionOpts

type DisplayAddActionOpts struct {
	Request          *apiv1.DisplayAddRequest
	Selector         cvd.InstanceSelector
	Paths            IMPaths
	OperationManager OperationManager
	ExecContext      exec.ExecContext
}

type DisplayListAction

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

func NewDisplayListAction

func NewDisplayListAction(opts DisplayListActionOpts) *DisplayListAction

func (*DisplayListAction) Run

type DisplayListActionOpts

type DisplayListActionOpts struct {
	Selector         cvd.InstanceSelector
	Paths            IMPaths
	OperationManager OperationManager
	ExecContext      exec.ExecContext
}

type DisplayRemoveAction

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

func NewDisplayRemoveAction

func NewDisplayRemoveAction(opts DisplayRemoveActionOpts) *DisplayRemoveAction

func (*DisplayRemoveAction) Run

type DisplayRemoveActionOpts

type DisplayRemoveActionOpts struct {
	DisplayNumber    int
	Selector         cvd.InstanceSelector
	Paths            IMPaths
	OperationManager OperationManager
	ExecContext      exec.ExecContext
}

type DisplayScreenshotAction

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

func (*DisplayScreenshotAction) Run

type DisplayScreenshotActionOpts

type DisplayScreenshotActionOpts struct {
	Request          *apiv1.DisplayScreenshotRequest
	Selector         cvd.InstanceSelector
	Paths            IMPaths
	OperationManager OperationManager
	ExecContext      exec.ExecContext
}

type EmptyFieldError

type EmptyFieldError string

func (EmptyFieldError) Error

func (s EmptyFieldError) Error() string

type ExecCVDGroupCommandAction

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

func (*ExecCVDGroupCommandAction) Run

type ExecCVDGroupCommandActionOpts

type ExecCVDGroupCommandActionOpts struct {
	Command          execCvdGroupCommand
	Selector         cvd.GroupSelector
	OperationManager OperationManager
	ExecContext      exec.ExecContext
}

type ExecCVDInstanceCommandAction

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

func (*ExecCVDInstanceCommandAction) Run

type ExecCVDInstanceCommandActionOpts

type ExecCVDInstanceCommandActionOpts struct {
	Command          execCvdInstanceCommand
	Selector         cvd.InstanceSelector
	OperationManager OperationManager
	ExecContext      exec.ExecContext
}

type ExtraCVDOptions

type ExtraCVDOptions struct {
	KernelBuild      cvd.AndroidBuild
	BootloaderBuild  cvd.AndroidBuild
	SystemImageBuild cvd.AndroidBuild
}

type FetchArtifactsAction

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

func NewFetchArtifactsAction

func NewFetchArtifactsAction(opts FetchArtifactsActionOpts) *FetchArtifactsAction

func (*FetchArtifactsAction) Run

type FetchArtifactsActionOpts

type FetchArtifactsActionOpts struct {
	Request          *apiv1.FetchArtifactsRequest
	Paths            IMPaths
	OperationManager OperationManager
	CVDBundleFetcher CVDBundleFetcher
	UUIDGen          func() string
}

type HostValidator

type HostValidator struct {
	ExecContext hoexec.ExecContext
}

Validates whether the current host is valid to run CVDs.

func (*HostValidator) Validate

func (v *HostValidator) Validate() error

type IMPaths

type IMPaths struct {
	RootDir             string
	InstancesDir        string
	CVDBugReportsDir    string
	SnapshotsRootDir    string
	ImageDirectoriesDir string
}

type ImageDirectoriesManager

type ImageDirectoriesManager interface {
	// Create an empty image directory.
	CreateImageDirectory() (string, error)
	// List all image directories.
	ListImageDirectories() ([]string, error)
	// Update image directory with creating or modifying symlinks of all files
	// under specified directory.
	UpdateImageDirectory(imageDirName, dir string) error
	// Delete the specified image directory.
	DeleteImageDirectory(imageDirName string) error
}

type ImageDirectoriesManagerImpl

type ImageDirectoriesManagerImpl struct {
	ImageDirectoriesManagerOpts
}

An implementation of the ImageDirectoriesManager interface.

func (*ImageDirectoriesManagerImpl) CreateImageDirectory

func (m *ImageDirectoriesManagerImpl) CreateImageDirectory() (string, error)

func (*ImageDirectoriesManagerImpl) DeleteImageDirectory

func (m *ImageDirectoriesManagerImpl) DeleteImageDirectory(imageDirName string) error

func (*ImageDirectoriesManagerImpl) ListImageDirectories

func (m *ImageDirectoriesManagerImpl) ListImageDirectories() ([]string, error)

func (*ImageDirectoriesManagerImpl) UpdateImageDirectory

func (m *ImageDirectoriesManagerImpl) UpdateImageDirectory(imageDirName, dir string) error

type ImageDirectoriesManagerOpts

type ImageDirectoriesManagerOpts struct {
	// Root directory for storing image directories.
	RootDir string
}

Options for creating instances of ImageDirectoriesManager implementations.

type ListCVDsAction

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

func NewListCVDsAction

func NewListCVDsAction(opts ListCVDsActionOpts) *ListCVDsAction

func (*ListCVDsAction) Run

type ListCVDsActionOpts

type ListCVDsActionOpts struct {
	Group       string
	Paths       IMPaths
	ExecContext exec.ExecContext
}

type MapOM

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

func NewMapOM

func NewMapOM() *MapOM

func (*MapOM) Complete

func (m *MapOM) Complete(name string, result *OperationResult) error

func (*MapOM) Get

func (m *MapOM) Get(name string) (apiv1.Operation, error)

func (*MapOM) GetResult

func (m *MapOM) GetResult(name string) (*OperationResult, error)

func (*MapOM) ListRunning

func (m *MapOM) ListRunning() []apiv1.Operation

func (*MapOM) New

func (m *MapOM) New() apiv1.Operation

func (*MapOM) Wait

func (m *MapOM) Wait(name string, dt time.Duration) (*OperationResult, error)

type NotFoundOperationError

type NotFoundOperationError string

func (NotFoundOperationError) Error

func (s NotFoundOperationError) Error() string

type OperationManager

type OperationManager interface {
	New() apiv1.Operation

	Get(name string) (apiv1.Operation, error)

	ListRunning() []apiv1.Operation

	GetResult(name string) (*OperationResult, error)

	Complete(name string, result *OperationResult) error

	// Waits for the specified operation to be DONE within the passed deadline. If the deadline
	// is reached `OperationWaitTimeoutError` will be returned.
	// NOTE: if dt is zero there's no timeout.
	Wait(name string, dt time.Duration) (*OperationResult, error)
}

type OperationNotDoneError

type OperationNotDoneError string

func (OperationNotDoneError) Error

func (s OperationNotDoneError) Error() string

type OperationResult

type OperationResult struct {
	Error error
	Value interface{}
}

type OperationWaitTimeoutError

type OperationWaitTimeoutError struct{}

func (OperationWaitTimeoutError) Error

type ResetCVDAction

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

func NewResetCVDAction

func NewResetCVDAction(opts ResetCVDActionOpts) *ResetCVDAction

func (*ResetCVDAction) Run

func (a *ResetCVDAction) Run() (apiv1.Operation, error)

type ResetCVDActionOpts

type ResetCVDActionOpts struct {
	OperationManager OperationManager
	ExecContext      exec.ExecContext
}

type StartCVDAction

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

func NewStartCVDAction

func NewStartCVDAction(opts StartCVDActionOpts) *StartCVDAction

func (*StartCVDAction) Run

func (a *StartCVDAction) Run() (apiv1.Operation, error)

type StartCVDActionOpts

type StartCVDActionOpts struct {
	Request          *apiv1.StartCVDRequest
	Selector         cvd.GroupSelector
	Paths            IMPaths
	OperationManager OperationManager
	ExecContext      exec.ExecContext
}

type UserArtifactChunk

type UserArtifactChunk struct {
	Name          string
	File          io.Reader
	OffsetBytes   int64
	SizeBytes     int64
	FileSizeBytes int64
}

type UserArtifactsDirResolver

type UserArtifactsDirResolver interface {
	// Retrieve the full path where the updated artifact located
	UpdatedArtifactPath(checksum string) string
	// Retrieve the full path where the extracted artifact located
	ExtractedArtifactPath(checksum string) string
}

Resolves the user artifacts full directory.

type UserArtifactsManager

type UserArtifactsManager interface {
	// Update artifact with the passed chunk
	UpdateArtifact(checksum string, chunk UserArtifactChunk) error
	// Stat artifact whether artifact with given checksum exists or not.
	StatArtifact(checksum string) (*apiv1.StatArtifactResponse, error)
	// Extract artifact with the given checksum
	ExtractArtifact(checksum string) error

	UserArtifactsDirResolver
}

Abstraction for managing user artifacts for launching CVDs.

type UserArtifactsManagerImpl

type UserArtifactsManagerImpl struct {
	UserArtifactsManagerOpts
	WorkDir string
	// contains filtered or unexported fields
}

An implementation of the UserArtifactsManager interface.

func NewUserArtifactsManagerImpl

func NewUserArtifactsManagerImpl(opts UserArtifactsManagerOpts) (*UserArtifactsManagerImpl, error)

Creates a new instance of UserArtifactsManagerImpl.

func (*UserArtifactsManagerImpl) ExtractArtifact

func (m *UserArtifactsManagerImpl) ExtractArtifact(checksum string) error

func (*UserArtifactsManagerImpl) ExtractedArtifactPath

func (m *UserArtifactsManagerImpl) ExtractedArtifactPath(checksum string) string

func (*UserArtifactsManagerImpl) StatArtifact

func (m *UserArtifactsManagerImpl) StatArtifact(checksum string) (*apiv1.StatArtifactResponse, error)

func (*UserArtifactsManagerImpl) UpdateArtifact

func (m *UserArtifactsManagerImpl) UpdateArtifact(checksum string, chunk UserArtifactChunk) error

func (*UserArtifactsManagerImpl) UpdatedArtifactPath

func (m *UserArtifactsManagerImpl) UpdatedArtifactPath(checksum string) string

type UserArtifactsManagerOpts

type UserArtifactsManagerOpts struct {
	// Root directory for storing user artifacts. After Host Orchestrator moves user artifacts from
	// the working directory into here, it becomes immutable unless introducing any replacement
	// algorithm(e.g. LRU) on RootDir to manage the storage.
	RootDir string
}

Options for creating instances of UserArtifactsManager implementations.

type Validator

type Validator interface {
	Validate() error
}

Directories

Path Synopsis
cvd

Jump to

Keyboard shortcuts

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