orchestrator

package
v0.0.0-...-1a7b9dc Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: Apache-2.0, MIT Imports: 29 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 cvd.CVDExecContext, groupName, name string) (string, error)

func CreateCVD

func CreateCVD(ctx cvd.CVDExecContext, p startCVDParams) error

func SliceItoa

func SliceItoa(s []uint32) []string

func Untar

func Untar(dst string, src string, owner *user.User) error

func Unzip

func Unzip(dstDir string, src string, owner *user.User) error

Types

type AndroidBuild

type AndroidBuild struct {
	ID     string
	Target string
}

type BuildAPICredentials

type BuildAPICredentials struct {
	AccessToken string
	// The credential for exchanging access tokens should be generated from a GCP project that
	// has the Build API enabled. If it isn't, UserProjectID is required for successful API usage.
	// The value of UserProjectID is expected to be the project ID of a GCP project that has the
	// Build API enabled. This project ID can differ from the one used to generate OAuth credentials.
	UserProjectID string
}

type CVDSelector

type CVDSelector struct {
	Group string
	Name  string
}

func (*CVDSelector) ToCVDCLI

func (s *CVDSelector) ToCVDCLI() []string

type Config

type Config struct {
	Paths                  IMPaths
	AndroidBuildServiceURL string
	CVDUser                *user.User
}

type Controller

type Controller struct {
	Config                Config
	OperationManager      OperationManager
	WaitOperationDuration time.Duration
	UserArtifactsManager  UserArtifactsManager
	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              ExecContext
	BuildAPI                 artifacts.BuildAPI
	ArtifactsFetcher         artifacts.Fetcher
	CVDBundleFetcher         artifacts.CVDBundleFetcher
	UUIDGen                  func() string
	CVDUser                  *user.User
	UserArtifactsDirResolver UserArtifactsDirResolver
	BuildAPICredentials      BuildAPICredentials
}

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         cvd.CVDExecContext
	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 {
	Selector         CVDSelector
	Paths            IMPaths
	OperationManager OperationManager
	ExecContext      ExecContext
	CVDUser          *user.User
}

type EmptyFieldError

type EmptyFieldError string

func (EmptyFieldError) Error

func (s EmptyFieldError) Error() string

type ExecCVDCommandAction

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

func NewExecCVDCommandAction

func NewExecCVDCommandAction(opts ExecCVDCommandActionOpts) *ExecCVDCommandAction

func (*ExecCVDCommandAction) Run

type ExecCVDCommandActionOpts

type ExecCVDCommandActionOpts struct {
	Command          string
	Selector         CVDSelector
	Paths            IMPaths
	OperationManager OperationManager
	ExecContext      ExecContext
	CVDUser          *user.User
}

type ExecContext

type ExecContext = func(ctx context.Context, name string, arg ...string) *exec.Cmd

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
	BuildAPI         artifacts.BuildAPI
	CVDBundleFetcher artifacts.CVDBundleFetcher
	ArtifactsFetcher artifacts.Fetcher
	UUIDGen          func() string
}

type HostValidator

type HostValidator struct {
	ExecContext 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
	ArtifactsRootDir string
	CVDBugReportsDir string
	SnapshotsRootDir string
}

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 ExecContext
	CVDUser     *user.User
}

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 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         CVDSelector
	Paths            IMPaths
	OperationManager OperationManager
	ExecContext      ExecContext
	CVDUser          *user.User
}

type UserArtifactChunk

type UserArtifactChunk struct {
	Name           string
	ChunkNumber    int
	ChunkTotal     int
	ChunkSizeBytes int64
	File           io.Reader
}

type UserArtifactsDirResolver

type UserArtifactsDirResolver interface {
	// Given a directory name returns its full path.
	GetDirPath(name string) string
}

Resolves the user artifacts full directory.

type UserArtifactsManager

type UserArtifactsManager interface {
	UserArtifactsDirResolver
	// Creates a new directory for uploading user artifacts in the future.
	NewDir() (*apiv1.UploadDirectory, error)
	// List existing directories
	ListDirs() (*apiv1.ListUploadDirectoriesResponse, error)
	// Update artifact with the passed chunk.
	UpdateArtifact(dir string, chunk UserArtifactChunk) error
	// Extract artifact
	ExtractArtifact(dir, name string) error
}

Abstraction for managing user artifacts for launching CVDs.

type UserArtifactsManagerImpl

type UserArtifactsManagerImpl struct {
	UserArtifactsManagerOpts
}

An implementation of the UserArtifactsManager interface.

func NewUserArtifactsManagerImpl

func NewUserArtifactsManagerImpl(opts UserArtifactsManagerOpts) *UserArtifactsManagerImpl

Creates a new instance of UserArtifactsManagerImpl.

func (*UserArtifactsManagerImpl) ExtractArtifact

func (m *UserArtifactsManagerImpl) ExtractArtifact(dir, name string) error

func (*UserArtifactsManagerImpl) GetDirPath

func (m *UserArtifactsManagerImpl) GetDirPath(name string) string

func (*UserArtifactsManagerImpl) GetFilePath

func (m *UserArtifactsManagerImpl) GetFilePath(dir, filename string) string

func (*UserArtifactsManagerImpl) ListDirs

func (*UserArtifactsManagerImpl) NewDir

func (*UserArtifactsManagerImpl) UpdateArtifact

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

type UserArtifactsManagerOpts

type UserArtifactsManagerOpts struct {
	// The root directory where to store the artifacts.
	RootDir string
	// Artifact owner. If nil, the owner will be the process's owner.
	Owner *user.User
}

Options for creating instances of UserArtifactsManager implementations.

type Validator

type Validator interface {
	Validate() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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