command.proto 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. // Copyright 2019 Google LLC.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //
  15. syntax = "proto3";
  16. package google.devtools.remoteworkers.v1test2;
  17. import "google/protobuf/any.proto";
  18. import "google/protobuf/duration.proto";
  19. import "google/rpc/status.proto";
  20. option csharp_namespace = "Google.DevTools.RemoteWorkers.V1Test2";
  21. option go_package = "google.golang.org/genproto/googleapis/devtools/remoteworkers/v1test2;remoteworkers";
  22. option java_multiple_files = true;
  23. option java_outer_classname = "RemoteWorkersCommands";
  24. option java_package = "com.google.devtools.remoteworkers.v1test2";
  25. option php_namespace = "Google\\Cloud\\Remoteworkers\\V1test2";
  26. option objc_class_prefix = "RW";
  27. // Describes a shell-style task to execute, suitable for providing as the Bots
  28. // interface's `Lease.payload` field.
  29. message CommandTask {
  30. // Describes the inputs to a shell-style task.
  31. message Inputs {
  32. // An environment variable required by this task.
  33. message EnvironmentVariable {
  34. // The envvar name.
  35. string name = 1;
  36. // The envvar value.
  37. string value = 2;
  38. }
  39. // The command itself to run (e.g., argv).
  40. //
  41. // This field should be passed directly to the underlying operating system,
  42. // and so it must be sensible to that operating system. For example, on
  43. // Windows, the first argument might be "C:\Windows\System32\ping.exe" -
  44. // that is, using drive letters and backslashes. A command for a *nix
  45. // system, on the other hand, would use forward slashes.
  46. //
  47. // All other fields in the RWAPI must consistently use forward slashes,
  48. // since those fields may be interpretted by both the service and the bot.
  49. repeated string arguments = 1;
  50. // The input filesystem to be set up prior to the task beginning. The
  51. // contents should be a repeated set of FileMetadata messages though other
  52. // formats are allowed if better for the implementation (eg, a LUCI-style
  53. // .isolated file).
  54. //
  55. // This field is repeated since implementations might want to cache the
  56. // metadata, in which case it may be useful to break up portions of the
  57. // filesystem that change frequently (eg, specific input files) from those
  58. // that don't (eg, standard header files).
  59. repeated Digest files = 2;
  60. // Inline contents for blobs expected to be needed by the bot to execute the
  61. // task. For example, contents of entries in `files` or blobs that are
  62. // indirectly referenced by an entry there.
  63. //
  64. // The bot should check against this list before downloading required task
  65. // inputs to reduce the number of communications between itself and the
  66. // remote CAS server.
  67. repeated Blob inline_blobs = 4;
  68. // All environment variables required by the task.
  69. repeated EnvironmentVariable environment_variables = 3;
  70. // Directory from which a command is executed. It is a relative directory
  71. // with respect to the bot's working directory (i.e., "./"). If it is
  72. // non-empty, then it must exist under "./". Otherwise, "./" will be used.
  73. string working_directory = 5;
  74. }
  75. // Describes the expected outputs of the command.
  76. message Outputs {
  77. // A list of expected files, relative to the execution root. All paths
  78. // MUST be delimited by forward slashes.
  79. repeated string files = 1;
  80. // A list of expected directories, relative to the execution root. All paths
  81. // MUST be delimited by forward slashes.
  82. repeated string directories = 2;
  83. // The destination to which any stdout should be sent. The method by which
  84. // the bot should send the stream contents to that destination is not
  85. // defined in this API. As examples, the destination could be a file
  86. // referenced in the `files` field in this message, or it could be a URI
  87. // that must be written via the ByteStream API.
  88. string stdout_destination = 3;
  89. // The destination to which any stderr should be sent. The method by which
  90. // the bot should send the stream contents to that destination is not
  91. // defined in this API. As examples, the destination could be a file
  92. // referenced in the `files` field in this message, or it could be a URI
  93. // that must be written via the ByteStream API.
  94. string stderr_destination = 4;
  95. }
  96. // Describes the timeouts associated with this task.
  97. message Timeouts {
  98. // This specifies the maximum time that the task can run, excluding the
  99. // time required to download inputs or upload outputs. That is, the worker
  100. // will terminate the task if it runs longer than this.
  101. google.protobuf.Duration execution = 1;
  102. // This specifies the maximum amount of time the task can be idle - that is,
  103. // go without generating some output in either stdout or stderr. If the
  104. // process is silent for more than the specified time, the worker will
  105. // terminate the task.
  106. google.protobuf.Duration idle = 2;
  107. // If the execution or IO timeouts are exceeded, the worker will try to
  108. // gracefully terminate the task and return any existing logs. However,
  109. // tasks may be hard-frozen in which case this process will fail. This
  110. // timeout specifies how long to wait for a terminated task to shut down
  111. // gracefully (e.g. via SIGTERM) before we bring down the hammer (e.g.
  112. // SIGKILL on *nix, CTRL_BREAK_EVENT on Windows).
  113. google.protobuf.Duration shutdown = 3;
  114. }
  115. // The inputs to the task.
  116. Inputs inputs = 1;
  117. // The expected outputs from the task.
  118. Outputs expected_outputs = 4;
  119. // The timeouts of this task.
  120. Timeouts timeouts = 5;
  121. }
  122. // DEPRECATED - use CommandResult instead.
  123. // Describes the actual outputs from the task.
  124. message CommandOutputs {
  125. // exit_code is only fully reliable if the status' code is OK. If the task
  126. // exceeded its deadline or was cancelled, the process may still produce an
  127. // exit code as it is cancelled, and this will be populated, but a successful
  128. // (zero) is unlikely to be correct unless the status code is OK.
  129. int32 exit_code = 1;
  130. // The output files. The blob referenced by the digest should contain
  131. // one of the following (implementation-dependent):
  132. // * A marshalled DirectoryMetadata of the returned filesystem
  133. // * A LUCI-style .isolated file
  134. Digest outputs = 2;
  135. }
  136. // DEPRECATED - use CommandResult instead.
  137. // Can be used as part of CompleteRequest.metadata, or are part of a more
  138. // sophisticated message.
  139. message CommandOverhead {
  140. // The elapsed time between calling Accept and Complete. The server will also
  141. // have its own idea of what this should be, but this excludes the overhead of
  142. // the RPCs and the bot response time.
  143. google.protobuf.Duration duration = 1;
  144. // The amount of time *not* spent executing the command (ie
  145. // uploading/downloading files).
  146. google.protobuf.Duration overhead = 2;
  147. }
  148. // All information about the execution of a command, suitable for providing as
  149. // the Bots interface's `Lease.result` field.
  150. message CommandResult {
  151. // An overall status for the command. For example, if the command timed out,
  152. // this might have a code of DEADLINE_EXCEEDED; if it was killed by the OS for
  153. // memory exhaustion, it might have a code of RESOURCE_EXHAUSTED.
  154. google.rpc.Status status = 1;
  155. // The exit code of the process. An exit code of "0" should only be trusted if
  156. // `status` has a code of OK (otherwise it may simply be unset).
  157. int32 exit_code = 2;
  158. // The output files. The blob referenced by the digest should contain
  159. // one of the following (implementation-dependent):
  160. // * A marshalled DirectoryMetadata of the returned filesystem
  161. // * A LUCI-style .isolated file
  162. Digest outputs = 3;
  163. // The elapsed time between calling Accept and Complete. The server will also
  164. // have its own idea of what this should be, but this excludes the overhead of
  165. // the RPCs and the bot response time.
  166. google.protobuf.Duration duration = 4 [deprecated = true];
  167. // The amount of time *not* spent executing the command (ie
  168. // uploading/downloading files).
  169. google.protobuf.Duration overhead = 5 [deprecated = true];
  170. // Implementation-dependent metadata about the task. Both servers and bots
  171. // may define messages which can be encoded here; bots are free to provide
  172. // metadata in multiple formats, and servers are free to choose one or more
  173. // of the values to process and ignore others. In particular, it is *not*
  174. // considered an error for the bot to provide the server with a field that it
  175. // doesn't know about.
  176. repeated google.protobuf.Any metadata = 6;
  177. }
  178. // The metadata for a file. Similar to the equivalent message in the Remote
  179. // Execution API.
  180. message FileMetadata {
  181. // The path of this file. If this message is part of the
  182. // CommandOutputs.outputs fields, the path is relative to the execution root
  183. // and must correspond to an entry in CommandTask.outputs.files. If this
  184. // message is part of a Directory message, then the path is relative to the
  185. // root of that directory. All paths MUST be delimited by forward slashes.
  186. string path = 1;
  187. // A pointer to the contents of the file. The method by which a client
  188. // retrieves the contents from a CAS system is not defined here.
  189. Digest digest = 2;
  190. // If the file is small enough, its contents may also or alternatively be
  191. // listed here.
  192. bytes contents = 3;
  193. // Properties of the file
  194. bool is_executable = 4;
  195. }
  196. // The metadata for a directory. Similar to the equivalent message in the Remote
  197. // Execution API.
  198. message DirectoryMetadata {
  199. // The path of the directory, as in
  200. // [FileMetadata.path][google.devtools.remoteworkers.v1test2.FileMetadata.path].
  201. string path = 1;
  202. // A pointer to the contents of the directory, in the form of a marshalled
  203. // Directory message.
  204. Digest digest = 2;
  205. }
  206. // The CommandTask and CommandResult messages assume the existence of a service
  207. // that can serve blobs of content, identified by a hash and size known as a
  208. // "digest." The method by which these blobs may be retrieved is not specified
  209. // here, but a model implementation is in the Remote Execution API's
  210. // "ContentAddressibleStorage" interface.
  211. //
  212. // In the context of the RWAPI, a Digest will virtually always refer to the
  213. // contents of a file or a directory. The latter is represented by the
  214. // byte-encoded Directory message.
  215. message Digest {
  216. // A string-encoded hash (eg "1a2b3c", not the byte array [0x1a, 0x2b, 0x3c])
  217. // using an implementation-defined hash algorithm (eg SHA-256).
  218. string hash = 1;
  219. // The size of the contents. While this is not strictly required as part of an
  220. // identifier (after all, any given hash will have exactly one canonical
  221. // size), it's useful in almost all cases when one might want to send or
  222. // retrieve blobs of content and is included here for this reason.
  223. int64 size_bytes = 2;
  224. }
  225. // Describes a blob of binary content with its digest.
  226. message Blob {
  227. // The digest of the blob. This should be verified by the receiver.
  228. Digest digest = 1;
  229. // The contents of the blob.
  230. bytes contents = 2;
  231. }
  232. // The contents of a directory. Similar to the equivalent message in the Remote
  233. // Execution API.
  234. message Directory {
  235. // The files in this directory
  236. repeated FileMetadata files = 1;
  237. // Any subdirectories
  238. repeated DirectoryMetadata directories = 2;
  239. }