13219: Checks for expired run time and cancel container if needed.
[arvados.git] / sdk / go / arvados / container.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: Apache-2.0
4
5 package arvados
6
7 import "time"
8
9 // Container is an arvados#container resource.
10 type Container struct {
11         UUID                 string               `json:"uuid"`
12         CreatedAt            time.Time            `json:"created_at"`
13         Command              []string             `json:"command"`
14         ContainerImage       string               `json:"container_image"`
15         Cwd                  string               `json:"cwd"`
16         Environment          map[string]string    `json:"environment"`
17         LockedByUUID         string               `json:"locked_by_uuid"`
18         Mounts               map[string]Mount     `json:"mounts"`
19         Output               string               `json:"output"`
20         OutputPath           string               `json:"output_path"`
21         Priority             int                  `json:"priority"`
22         RuntimeConstraints   RuntimeConstraints   `json:"runtime_constraints"`
23         StartedAt            time.Time            `json:"started_at"`
24         State                ContainerState       `json:"state"`
25         SchedulingParameters SchedulingParameters `json:"scheduling_parameters"`
26 }
27
28 // Mount is special behavior to attach to a filesystem path or device.
29 type Mount struct {
30         Kind              string      `json:"kind"`
31         Writable          bool        `json:"writable"`
32         PortableDataHash  string      `json:"portable_data_hash"`
33         UUID              string      `json:"uuid"`
34         DeviceType        string      `json:"device_type"`
35         Path              string      `json:"path"`
36         Content           interface{} `json:"content"`
37         ExcludeFromOutput bool        `json:"exclude_from_output"`
38         Capacity          int64       `json:"capacity"`
39         Commit            string      `json:"commit"`          // only if kind=="git_tree"
40         RepositoryName    string      `json:"repository_name"` // only if kind=="git_tree"
41         GitURL            string      `json:"git_url"`         // only if kind=="git_tree"
42 }
43
44 // RuntimeConstraints specify a container's compute resources (RAM,
45 // CPU) and network connectivity.
46 type RuntimeConstraints struct {
47         API          *bool
48         RAM          int64 `json:"ram"`
49         VCPUs        int   `json:"vcpus"`
50         KeepCacheRAM int64 `json:"keep_cache_ram"`
51 }
52
53 // SchedulingParameters specify a container's scheduling parameters
54 // such as Partitions
55 type SchedulingParameters struct {
56         Partitions  []string `json:"partitions"`
57         Preemptible bool     `json:"preemptible"`
58         MaxRunTime  int      `json:"max_run_time"`
59 }
60
61 // ContainerList is an arvados#containerList resource.
62 type ContainerList struct {
63         Items          []Container `json:"items"`
64         ItemsAvailable int         `json:"items_available"`
65         Offset         int         `json:"offset"`
66         Limit          int         `json:"limit"`
67 }
68
69 // ContainerState is a string corresponding to a valid Container state.
70 type ContainerState string
71
72 const (
73         ContainerStateQueued    = ContainerState("Queued")
74         ContainerStateLocked    = ContainerState("Locked")
75         ContainerStateRunning   = ContainerState("Running")
76         ContainerStateComplete  = ContainerState("Complete")
77         ContainerStateCancelled = ContainerState("Cancelled")
78 )