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