Documentation
¶
Overview ¶
Copyright (C) The Arvados Authors. All rights reserved.
SPDX-License-Identifier: AGPL-3.0
Copyright (C) The Arvados Authors. All rights reserved.
SPDX-License-Identifier: AGPL-3.0
Index ¶
- Constants
- Variables
- func Detach(uuid string, prog string, args []string, stdin io.Reader, ...) int
- func KillProcess(uuid string, signal syscall.Signal, stdout, stderr io.Writer) int
- func ListProcesses(stdin io.Reader, stdout, stderr io.Writer) int
- type ConfigData
- type ContainerRunner
- func (runner *ContainerRunner) ArvMountCmd(cmdline []string, token string) (c *exec.Cmd, err error)
- func (runner *ContainerRunner) CaptureOutput(bindmounts map[string]bindmount) error
- func (runner *ContainerRunner) CleanupDirs()
- func (runner *ContainerRunner) CommitLogs() error
- func (runner *ContainerRunner) ContainerToken() (string, error)
- func (runner *ContainerRunner) CreateContainer(imageID string, bindmounts map[string]bindmount) error
- func (runner *ContainerRunner) IsCancelled() bool
- func (runner *ContainerRunner) LoadImage() (string, error)
- func (runner *ContainerRunner) LogContainerRecord() error
- func (runner *ContainerRunner) LogHostInfo() (err error)
- func (runner *ContainerRunner) LogNodeRecord() error
- func (runner *ContainerRunner) Run() (err error)
- func (runner *ContainerRunner) SetupArvMountPoint(prefix string) (err error)
- func (runner *ContainerRunner) SetupMounts() (map[string]bindmount, error)
- func (runner *ContainerRunner) StartContainer() error
- func (runner *ContainerRunner) UpdateContainerFinal() error
- func (runner *ContainerRunner) UpdateContainerRunning(logId string) error
- func (runner *ContainerRunner) WaitFinish() error
- type Gateway
- type GatewayTarget
- type GatewayTargetStub
- type IArvadosClient
- type IKeepClient
- type MkTempDir
- type PsProcess
- type RunArvMount
Constants ¶
const DockerAPIVersion = "1.35"
DockerAPIVersion is the API version we use to communicate with the docker service. The oldest OS we support is Ubuntu 18.04 (bionic) which originally shipped docker 1.17.12 / API 1.35 so there is no reason to use an older API version. See https://dev.arvados.org/issues/15370#note-38 and https://docs.docker.com/engine/api/.
Variables ¶
var Command = command{}
ErrCancelled is the error returned when the container is cancelled.
Functions ¶
func Detach ¶
Detach acquires a lock for the given uuid, and starts the current program as a child process (with -no-detach prepended to the given arguments so the child knows not to detach again). The lock is passed along to the child process.
Stdout and stderr in the child process are sent to the systemd journal using the systemd-cat program.
func KillProcess ¶
KillProcess finds the crunch-run process corresponding to the given uuid, and sends the given signal to it. It then waits up to 1 second for the process to die. It returns 0 if the process is successfully killed or didn't exist in the first place.
Types ¶
type ConfigData ¶
type ConfigData struct { Env map[string]string KeepBuffers int EC2SpotCheck bool Cluster *arvados.Cluster }
ConfigData contains environment variables and (when needed) cluster configuration, passed from dispatchcloud to crunch-run on stdin.
type ContainerRunner ¶
type ContainerRunner struct { DispatcherArvClient IArvadosClient DispatcherKeepClient IKeepClient ContainerArvClient IArvadosClient ContainerKeepClient IKeepClient Container arvados.Container ExitCode *int CrunchLog *logWriter LogCollection arvados.CollectionFileSystem LogsPDH *string RunArvMount RunArvMount MkTempDir MkTempDir ArvMount *exec.Cmd ArvMountPoint string HostOutputDir string Volumes map[string]struct{} OutputPDH *string SigChan chan os.Signal ArvMountExit chan error SecretMounts map[string]arvados.Mount MkArvClient func(token string) (IArvadosClient, IKeepClient, *arvados.Client, error) // contains filtered or unexported fields }
ContainerRunner is the main stateful struct used for a single execution of a container.
func NewContainerRunner ¶
func NewContainerRunner(dispatcherClient *arvados.Client, dispatcherArvClient IArvadosClient, dispatcherKeepClient IKeepClient, containerUUID string) (*ContainerRunner, error)
NewContainerRunner creates a new container runner.
func (*ContainerRunner) ArvMountCmd ¶
func (*ContainerRunner) CaptureOutput ¶
func (runner *ContainerRunner) CaptureOutput(bindmounts map[string]bindmount) error
CaptureOutput saves data from the container's output directory if needed, and updates the container output accordingly.
func (*ContainerRunner) CleanupDirs ¶
func (runner *ContainerRunner) CleanupDirs()
func (*ContainerRunner) CommitLogs ¶
func (runner *ContainerRunner) CommitLogs() error
CommitLogs posts the collection containing the final container logs.
func (*ContainerRunner) ContainerToken ¶
func (runner *ContainerRunner) ContainerToken() (string, error)
ContainerToken returns the api_token the container (and any arv-mount processes) are allowed to use.
func (*ContainerRunner) CreateContainer ¶
func (runner *ContainerRunner) CreateContainer(imageID string, bindmounts map[string]bindmount) error
CreateContainer creates the docker container.
func (*ContainerRunner) IsCancelled ¶
func (runner *ContainerRunner) IsCancelled() bool
IsCancelled returns the value of Cancelled, with goroutine safety.
func (*ContainerRunner) LoadImage ¶
func (runner *ContainerRunner) LoadImage() (string, error)
LoadImage determines the docker image id from the container record and checks if it is available in the local Docker image store. If not, it loads the image from Keep.
func (*ContainerRunner) LogContainerRecord ¶
func (runner *ContainerRunner) LogContainerRecord() error
LogContainerRecord gets and saves the raw JSON container record from the API server
func (*ContainerRunner) LogHostInfo ¶
func (runner *ContainerRunner) LogHostInfo() (err error)
LogHostInfo logs info about the current host, for debugging and accounting purposes. Although it's logged as "node-info", this is about the environment where crunch-run is actually running, which might differ from what's described in the node record (see LogNodeRecord).
func (*ContainerRunner) LogNodeRecord ¶
func (runner *ContainerRunner) LogNodeRecord() error
LogNodeRecord logs the current host's InstanceType config entry, if running via arvados-dispatch-cloud.
func (*ContainerRunner) Run ¶
func (runner *ContainerRunner) Run() (err error)
Run the full container lifecycle.
func (*ContainerRunner) SetupArvMountPoint ¶
func (runner *ContainerRunner) SetupArvMountPoint(prefix string) (err error)
func (*ContainerRunner) SetupMounts ¶
func (runner *ContainerRunner) SetupMounts() (map[string]bindmount, error)
func (*ContainerRunner) StartContainer ¶
func (runner *ContainerRunner) StartContainer() error
StartContainer starts the docker container created by CreateContainer.
func (*ContainerRunner) UpdateContainerFinal ¶
func (runner *ContainerRunner) UpdateContainerFinal() error
UpdateContainerFinal updates the container record state on API server to "Complete" or "Cancelled"
func (*ContainerRunner) UpdateContainerRunning ¶
func (runner *ContainerRunner) UpdateContainerRunning(logId string) error
UpdateContainerRunning updates the container state to "Running"
func (*ContainerRunner) WaitFinish ¶
func (runner *ContainerRunner) WaitFinish() error
WaitFinish waits for the container to terminate, capture the exit code, and close the stdout/stderr logging.
type Gateway ¶
type Gateway struct { ContainerUUID string // Caller should set Address to "", or "host:0" or "host:port" // where host is a known external IP address; port is a // desired port number to listen on; and ":0" chooses an // available dynamic port. // // If Address is "", Start() listens only on the loopback // interface (and changes Address to "127.0.0.1:port"). // Otherwise it listens on all interfaces. // // If Address is "host:0", Start() updates Address to // "host:port". Address string AuthSecret string Target GatewayTarget Log interface { Printf(fmt string, args ...interface{}) } // If non-nil, set up a ContainerGatewayTunnel, so that the // controller can connect to us even if our external IP // address is unknown or not routable from controller. ArvadosClient *arvados.Client // When a tunnel is connected or reconnected, this func (if // not nil) will be called with the InternalURL of the // controller process at the other end of the tunnel. UpdateTunnelURL func(url string) // Source for serving WebDAV requests with // X-Webdav-Source: /log LogCollection arvados.CollectionFileSystem // contains filtered or unexported fields }
type GatewayTarget ¶
type GatewayTargetStub ¶
type GatewayTargetStub struct{}
func (GatewayTargetStub) IPAddress ¶
func (GatewayTargetStub) IPAddress() (string, error)
type IArvadosClient ¶
type IArvadosClient interface { Create(resourceType string, parameters arvadosclient.Dict, output interface{}) error Get(resourceType string, uuid string, parameters arvadosclient.Dict, output interface{}) error Update(resourceType string, uuid string, parameters arvadosclient.Dict, output interface{}) error Call(method, resourceType, uuid, action string, parameters arvadosclient.Dict, output interface{}) error CallRaw(method string, resourceType string, uuid string, action string, parameters arvadosclient.Dict) (reader io.ReadCloser, err error) Discovery(key string) (interface{}, error) }
IArvadosClient is the minimal Arvados API methods used by crunch-run.
type IKeepClient ¶
type IKeepClient interface { BlockWrite(context.Context, arvados.BlockWriteOptions) (arvados.BlockWriteResponse, error) ReadAt(locator string, p []byte, off int) (int, error) LocalLocator(locator string) (string, error) SetStorageClasses(sc []string) }
IKeepClient is the minimal Keep API methods used by crunch-run.