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

     1  // Copyright 2016 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  syntax = "proto3";
     6  
     7  package swarming.config;
     8  
     9  option go_package = "go.chromium.org/luci/swarming/proto/config;configpb";
    10  
    11  import "go.chromium.org/luci/common/proto/options.proto";
    12  
    13  option (luci.file_metadata) = {
    14    doc_url: "https://config.luci.app/schemas/services/swarming:bots.cfg";
    15  };
    16  
    17  // Schema for bots.cfg service config file in luci-config.
    18  //
    19  // It defines a function bot_id => (required credentials, trusted_dimensions,
    20  // config), where
    21  //    * "bot_id" is identifier of a bot as sent by the bot itself (usually
    22  //      machine hostname, short one, not FQDN)
    23  //    * "required credentials" describes how server should authenticate calls
    24  //      from the bot.
    25  //    * "trusted_dimensions" is a set of dimension set by the server itself.
    26  //      Such dimensions can't be spoofed by the bot.
    27  //    * "config" is any additional bot configuration.
    28  //
    29  // Connections from bots that do not appear in this config are rejected.
    30  //
    31  // The default config (used if bots.cfg is missing) represents IP-whitelist only
    32  // authentication, as was used before bots.cfg was implemented:
    33  //
    34  //  bot_group {
    35  //    auth {
    36  //      ip_whitelist: "<swarming-app-id>-bots"
    37  //    }
    38  //  }
    39  message BotsCfg {
    40    // List of dimension names that are provided by the server.
    41    //
    42    // If bot attempts to set such dimension, it'll be ignored. Trusted dimensions
    43    // are defined through bot_group configs below. Swarming users can trust such
    44    // dimensions, since they are set by the server based on validated credentials
    45    // (unlike other dimensions that can be arbitrary defined by the bot itself).
    46    repeated string trusted_dimensions = 1;
    47  
    48    // A list of groups of bots. Each group defines a bunch of bots that all
    49    // have same dimensions and authenticate in the same way.
    50    //
    51    // The order of entries here is irrelevant. The server uses the following
    52    // search algorithm when trying to pick a group for a bot with some bot_id:
    53    //    1) First it tries to find a direct match: a group that lists the bot in
    54    //       bot_id field.
    55    //    2) Next it tries to find a group with matching bot_id_prefix. The config
    56    //       validation process makes sure prefixes do not "intersect", so there
    57    //       will be at most one matching group.
    58    //    3) Finally, if there's a group with no defined bot_id or bot_id_prefix
    59    //       fields (the "default" group), the bot is categorized to that group.
    60    //       If there's no such group, the connection from the bot is rejected.
    61    //       Config validation process ensures there can be only one such group.
    62    repeated BotGroup bot_group = 2;
    63  }
    64  
    65  
    66  // A group of bots that share authentication method, dimensions and owners.
    67  //
    68  // Union of bot_id and bot_id_prefix define a set of bots that belong to this
    69  // group. The rest of the fields define properties of this group.
    70  //
    71  // If bot_id and bot_id_prefix are both missing, the group defines all bots that
    72  // didn't fit into other groups. There can be only one such "default" group.
    73  //
    74  // NOTE: Swarming allows 'derivative' bots where multiple bots run on the same
    75  // host machine in some sort of container (such as Docker containers) and SHARE
    76  // A SINGLE CREDENTIAL. These bots have hostnames such as 'hostmachine--001',
    77  // where the "--001" suffix indicates which of the contained bots on
    78  // 'hostmachine' it is. When Swarming checks the bot affiliation for this
    79  // contained machine, it checks ONLY the 'hostmachine' portion. This means that
    80  // if your contained bot is 'vm10-vlan2--001', it would match:
    81  //   `bot_id: "vm10-vlan2`
    82  //   `bot_id: "vm{0...100}-vlan2`
    83  //   `bot_id_prefix: "vm10-vlan`
    84  // but would NOT match:
    85  //   `bot_id: "vm10-vlan2--001`
    86  //   `bot_id_prefix: "vm10-vlan2-`
    87  //   `bot_id_prefix: "vm10-vlan2--`
    88  //
    89  // TODO(vadimsh): Introduce explicit field "use_as_default" instead.
    90  message BotGroup {
    91    reserved 3;
    92  
    93    // Explicit enumeration of bot IDs belonging to this group.
    94    //
    95    // It supports subset of bash brace expansion syntax, in particular ranges
    96    // and lists. For example:
    97    //    * vm{1..3}-m1 will expand into vm1-m1, vm2-m1 and vm3-m1.
    98    //    * vm{100,150,200}-m1 will expand into vm100-m1, vm150-m1 and vm200-m1.
    99    //
   100    // There can be only one "{...}" section in the string.
   101    repeated string bot_id = 1;
   102  
   103    // A prefix to match against bot ID string.
   104    repeated string bot_id_prefix = 2;
   105  
   106    ////////////////////////
   107  
   108    // Defines authentication methods for bots from this group.
   109    //
   110    // Evaluated sequentially until first match.
   111    repeated BotAuth auth = 20;
   112  
   113    // Emails of owners of these bots. Optional.
   114    repeated string owners = 21;
   115  
   116    // List of dimensions to assign to these bots.
   117    //
   118    // Each dimension is a "<key>:<value>" pair.
   119    repeated string dimensions = 22;
   120  
   121    // Path to an additional config script to inject into the swarming bot upon
   122    // handshake.
   123    //
   124    // The path is relative to 'scripts/' directory in the service config repo.
   125    string bot_config_script = 23;
   126  
   127    // The revision of the config script to inject into the swarming bot upon
   128    // handshake.
   129    //
   130    // The field is filled when the bots.cfg gets loaded.
   131    string bot_config_script_rev = 26;
   132  
   133    // The actual body of the config script to inject into the swarming bot upon
   134    // handshake (in whatever encoding it happened to be in the config repo).
   135    //
   136    // For internal use (unless you fancy writing python scripts as single line
   137    // escaped text proto string). If present, overrides 'bot_config_script'.
   138    bytes bot_config_script_content = 25;
   139  
   140    // A service account to use on bots when authenticating calls to various
   141    // system-level services (like Isolate and CIPD), required for correct
   142    // operation of the bot.
   143    //
   144    // Tasks will be able to access this account too, but it is not recommended
   145    // and should be used extremely rare.
   146    //
   147    // If set to a service account email (*@*.iam.gserviceaccount.com), bots will
   148    // use this account, generating access token through Swarming server. For this
   149    // to work, the server account (<app-id>@appspot.gserviceaccount.com) must
   150    // have "serviceAccountActor" IAM role set on the account.
   151    //
   152    // If set to a special string "bot", bots will use exact same token they use
   153    // when authenticating calls to Swarming server itself. This works only if
   154    // bots use OAuth for authentication (see 'require_service_account' in
   155    // BotAuth). This mode exists for cases when proliferation of various service
   156    // accounts is undesirable. Note that in this mode Swarming processes won't be
   157    // able to request a system account token with some new scopes: they get exact
   158    // same token as returned by get_authentication_headers bot_config.py hook.
   159    //
   160    // If not set, bots will not use authentication at all.
   161    string system_service_account = 24;
   162  
   163    // The cloud project id where the bot saves its logs.
   164    // For GCE bots, it is the same cloud project where the bots reside.
   165    // For non-GCE bots, it is the cloud project where the logs are being sent to.
   166    string logs_cloud_project = 27;
   167  
   168    // Settings controlling migration to the RBE Scheduler.
   169    //
   170    // They are used only if all pools the bot belongs to are associated with an
   171    // RBE instance, and it is the same instance for all pools.
   172    //
   173    // TODO(vadimsh): Remove when no longer used. Replace by BotModeAllocation in
   174    // Pool.RBEMigration.
   175    message RBEMigration {
   176      // Approximate percent of bots in this bot group to switch to the RBE mode.
   177      //
   178      // A bot is in the RBE mode if `hash(bot_id) % 100 <= rbe_mode_percent`.
   179      int32 rbe_mode_percent = 1;
   180      // Bots to put into the RBE mode regardless of `rbe_mode_percent`.
   181      //
   182      // Useful to force the RBE mode on a particular bot.
   183      repeated string enable_rbe_on = 2;
   184      // Bots to exclude from the RBE mode regardless of `rbe_mode_percent`.
   185      //
   186      // Useful to exclude problematic bots from the RBE mode.
   187      repeated string disable_rbe_on = 3;
   188      // If true consume tasks from both Swarming and RBE schedulers at the same
   189      // time (in an interleaved kind of way).
   190      //
   191      // Useful when migrating small bot pools. In this mode task ordering and
   192      // priority may not be respected (if tasks end up in different schedulers)
   193      // and there may be higher scheduling delays.
   194      bool hybrid_mode = 4;
   195    }
   196    RBEMigration rbe_migration = 28;
   197  }
   198  
   199  
   200  // Defines what kind of authentication to perform when handling requests from
   201  // bots belonging to some bot group.
   202  //
   203  // The following combinations are valid:
   204  //   * Either one of require_* alone.
   205  //   * IP whitelist alone.
   206  //   * IP + require_luci_machine_token: requires both to pass.
   207  //   * IP + require_service_account: requires both to pass.
   208  //   * IP + require_gce_vm_token: requires both to pass.
   209  //
   210  // Next ID: 6.
   211  message BotAuth {
   212    // See require_gce_vm_token below.
   213    message GCE {
   214      string project = 1;
   215    }
   216  
   217    // If true, log an error (but proceed) if this method didn't succeed.
   218    //
   219    // This field is totally optional and makes sense only when there are more
   220    // than one auth method. Affects only logging levels.
   221    //
   222    // Doesn't apply to methods that were skipped because some method before them
   223    // succeeded. Thus methods that have 'log_if_failed' should be in front of
   224    // BotGroup.auth list.
   225    //
   226    // This is useful when migrating from one auth method to another to verify
   227    // the new method is used in 100% of cases, while still keeping a fallback
   228    // to an old method.
   229    bool log_if_failed = 5;
   230  
   231    // If true, the bot should provide valid X-Luci-Machine-Token header.
   232    //
   233    // The machine FQDN embedded in the token should have hostname equal to the
   234    // bot_id.
   235    bool require_luci_machine_token = 1;
   236  
   237    // If set, the bot should use OAuth access token belonging to any of these
   238    // service accounts.
   239    //
   240    // The token should have "https://www.googleapis.com/auth/userinfo.email"
   241    // scope.
   242    repeated string require_service_account = 2;
   243  
   244    // If set, the bot should provide valid X-Luci-Gce-Vm-Token header.
   245    //
   246    // This header should contain JWT with signed VM metadata with the following
   247    // expectations:
   248    //   * Audience matches https://[*-dot-]<app>.appspot.com
   249    //   * google.compute_engine.project_id field matches the value of 'project'.
   250    //   * instance_name matches bot_id reported by the bot (case insensitive).
   251    GCE require_gce_vm_token = 4;
   252  
   253    // If set, defines an IP whitelist name (in auth_service database) with a set
   254    // of IPs allowed to be used by the bots in this group.
   255    //
   256    // Works in conjunction with other checks, e.g. if require_luci_machine_token
   257    // is true, both valid X-Luci-Machine-Token and a whitelisted IP are needed to
   258    // successfully authenticate.
   259    //
   260    // Can also be used on its own (when all other fields are empty). In that case
   261    // the IP whitelist is the primary authentication mechanism. Note that in this
   262    // case all bots that share the IP whitelist are effectively in a single trust
   263    // domain (any bot can pretend to be some other bot).
   264    string ip_whitelist = 3;
   265  }