go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/swarming/proto/api/plugin.proto (about)

     1  // Copyright 2018 The LUCI Authors. All rights reserved.
     2  // Use of this source code is governed under the Apache License, Version 2.0
     3  // that can be found in the LICENSE file.
     4  
     5  // This proto file describes the external scheduler plugin API.
     6  
     7  syntax = "proto3";
     8  
     9  package swarming.v1;
    10  option go_package = "go.chromium.org/luci/swarming/proto/api;apipb";
    11  
    12  import "google/protobuf/timestamp.proto";
    13  import "go.chromium.org/luci/swarming/proto/api/swarming.proto";
    14  
    15  // Basic types used by the plugin API.
    16  
    17  // TaskSpec describes a task request and its state, for the purposes of the
    18  // external scheduler API.
    19  //
    20  // It intentionally elides aspects of a task request that are irrelevant
    21  // to scheduling decisions, to keep this proto small for performance reasons.
    22  //
    23  // This message format is in its early stages, and may be subject to frequent
    24  // or even breaking changes as the external scheduler API is rolled out.
    25  message TaskSpec {
    26    // Id is the swarming task request ID.
    27    //
    28    // Other than being a unique string to track the lifecycle of this request,
    29    // it is opaque to external scheduler. By convention, swarming uses a task's
    30    // summary ID (trailing '0') here, not the run ID.
    31    string id = 1;
    32  
    33    // Tags is the list of tags applied to this task request.
    34    repeated string tags = 2;
    35  
    36    // Slices is the set of task slices for this spec. A TaskSpec must contain
    37    // at least 1 slice.
    38    repeated SliceSpec slices = 3;
    39  
    40    // State is the current state of this task.
    41    TaskState state = 4;
    42  
    43    // BotID is the id of the bot that this task is running on. It is only
    44    // valid if state=RUNNING.
    45    string bot_id = 5;
    46  
    47    // EnqueuedTime is the time at which a task was enqueued. It is only valid
    48    // if state=PENDING.
    49    google.protobuf.Timestamp enqueued_time = 6;
    50  }
    51  
    52  // SliceSpec describes a task request slice, for the purposes of TaskSpec.
    53  message SliceSpec {
    54    // Dimensions is set dimension strings for this slice.
    55    repeated string dimensions = 1;
    56  }
    57  
    58  message IdleBot {
    59    // BotId is the id of the bot that is idle.
    60    string bot_id = 1;
    61  
    62    // Dimensions is the dimension set of the idle bot.
    63    repeated string dimensions = 2;
    64  }
    65  
    66  // API Request/Response types.
    67  
    68  message AssignTasksRequest {
    69    // SchedulerID is the id of the scheduler that this request should be run on.
    70    string scheduler_id = 1;
    71  
    72    // IdleBots is the set of idle bots that are trying to get tasks assigned.
    73    repeated IdleBot idle_bots = 2;
    74  
    75    // Time is the current time (according to swarming) at which these bots
    76    // are attempting to have tasks assigned to them.
    77    google.protobuf.Timestamp time = 3;
    78  }
    79  
    80  message AssignTasksResponse {
    81    // Assignments is the set of (bot, task) assignments that the scheduler
    82    // determined should be made.
    83    repeated TaskAssignment assignments = 1;
    84  }
    85  
    86  message TaskAssignment {
    87    // BotID is the bot that should be assigned a task.
    88    string bot_id = 1;
    89  
    90    // TaskID is the task that should be assigned to the bot.
    91    string task_id = 2;
    92  
    93    // SliceNumber is the slice within the task that should be assigned to the bot.
    94    // If absent, slice 0 will be assumed.
    95    int32 slice_number = 3;
    96  }
    97  
    98  message GetCancellationsRequest {
    99    // SchedulerID is the id of the scheduler that this request should be run on.
   100    string scheduler_id = 1;
   101  }
   102  
   103  message GetCancellationsResponse {
   104    message Cancellation {
   105        // BotID is the bot that a task should be cancelled on.
   106        string bot_id = 1;
   107  
   108        // TaskID is the task that should be cancelled on the bot.
   109        string task_id = 2;
   110  
   111        enum Reason {
   112          // Invalid reason, do not use.
   113          INVALID = 0;
   114          // Task was running on a worker, but was interrupted by another task.
   115          // Task may be retried by swarming.
   116          PREEMPTED = 1;
   117          // Task had invalid or erroneous properties that make it not handleable
   118          // by scheduler. Task should not be retried.
   119          ERROR = 2;
   120        }
   121  
   122        // Reason is the reason the task was cancelled.
   123        Reason reason = 3;
   124  
   125        // ExtraInfo is optional, human readable extra information about why the
   126        // task was cancelled.
   127        string extra_info = 4;
   128    }
   129  
   130    // Cancellations is the set of (bot, task) pairs for tasks that should be
   131    // cancelled on bots.
   132    repeated Cancellation cancellations = 1;
   133  }
   134  
   135  message NotifyTasksItem {
   136    // Time is the time at which the given task was in the given state.
   137    google.protobuf.Timestamp time = 1;
   138  
   139    // Task describes a task request and its current state.
   140    TaskSpec task = 2;
   141  }
   142  
   143  message NotifyTasksRequest {
   144    // SchedulerID is the id of the scheduler that this request should be run on.
   145    string scheduler_id = 1;
   146  
   147    // Notifications is the set of task notifications to send to the scheduler.
   148    repeated NotifyTasksItem notifications = 2;
   149  
   150    // IsCallback specifies whether these notifications are in response to
   151    // updates that were requested by a previous GetCallbacks call.
   152    //
   153    // This is for diagnostic purposes only.
   154    bool is_callback = 3;
   155  }
   156  
   157  message NotifyTasksResponse {}
   158  
   159  message GetCallbacksRequest {
   160      // SchedulerID is the id of the scheduler that this request should be run on.
   161      string scheduler_id = 1;
   162  }
   163  
   164  message GetCallbacksResponse {
   165    // TaskIds is the list of tasks that the external scheduler would like
   166    // callback notifications about.
   167    repeated string task_ids = 1;
   168  }
   169  
   170  // Service definition.
   171  
   172  // ExternalScheduler is the API by which swarming can delegate the assigning of
   173  // individuals task requests to individual bots to an external service.
   174  service ExternalScheduler {
   175    // Swarming-scheduler plugin endpoints.
   176  
   177    // AssignTasks determines which tasks should be run on which of the supplied
   178    // idle bots.
   179    rpc AssignTasks(AssignTasksRequest) returns (AssignTasksResponse);
   180  
   181    // GetCancellations determines which tasks should be cancelled on which bots.
   182    rpc GetCancellations(GetCancellationsRequest) returns (GetCancellationsResponse);
   183  
   184    // NotifyTasks informs the scheduler about the state of tasks (either new
   185    // tasks, or states of existing tasks).
   186    rpc NotifyTasks(NotifyTasksRequest) returns (NotifyTasksResponse);
   187  
   188    // GetCallbacks asks the scheduler for a set of request ids that the
   189    // external scheduler wants to receive callback NotifyTasks calls about.
   190    rpc GetCallbacks(GetCallbacksRequest) returns (GetCallbacksResponse);
   191  }