github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/plugins/device/proto/device.proto (about)

     1  syntax = "proto3";
     2  package hashicorp.nomad.plugins.device;
     3  option go_package = "proto";
     4  
     5  import "google/protobuf/timestamp.proto";
     6  import "google/protobuf/duration.proto";
     7  import "plugins/shared/structs/proto/attribute.proto";
     8  import "plugins/shared/structs/proto/stats.proto";
     9  
    10  // DevicePlugin is the API exposed by device plugins
    11  service DevicePlugin {
    12    // Fingerprint allows the device plugin to return a set of   
    13    // detected devices and provide a mechanism to update the state of
    14    // the device.
    15    rpc Fingerprint(FingerprintRequest) returns (stream FingerprintResponse) {}
    16  
    17    // Reserve is called by the client before starting an allocation
    18    // that requires access to the plugin’s devices. The plugin can use
    19    // this to run any setup steps and provides the mounting details to 
    20    // the Nomad client
    21    rpc Reserve(ReserveRequest) returns (ReserveResponse) {}
    22  
    23    // Stats returns a stream of device statistics.
    24    rpc Stats(StatsRequest) returns (stream StatsResponse) {}
    25  }
    26  
    27  // FingerprintRequest is used to request for devices to be fingerprinted.
    28  message FingerprintRequest {}
    29  
    30  // FingerprintResponse returns a set of detected devices.
    31  message FingerprintResponse {
    32      // device_group is a group of devices that share a vendor, device_type, and
    33      // device_name. This is returned as a set so that a single plugin could
    34      // potentially detect several device types and models.
    35      repeated DeviceGroup device_group = 1;
    36  }
    37  
    38  // DeviceGroup is a group of devices that share a vendor, device type and name.
    39  message DeviceGroup {
    40    // vendor is the name of the vendor of the device
    41    string vendor = 1;
    42  
    43    // device_type is the type of the device (gpu, fpga, etc).
    44    string device_type = 2;
    45    
    46    // device_name is the name of the device.
    47    string device_name = 3;
    48  
    49    // devices is the set of devices detected by the plugin.
    50    repeated DetectedDevice devices = 4;
    51  
    52    // attributes allows adding attributes to be used for constraints or
    53    // affinities.
    54    map<string, hashicorp.nomad.plugins.shared.structs.Attribute> attributes = 5;
    55  }
    56  
    57  // DetectedDevice is a single detected device.
    58  message DetectedDevice {
    59    // ID is the ID of the device. This ID is used during allocation and must be
    60    // stable across restarts of the device driver.
    61    // buf:lint:ignore FIELD_LOWER_SNAKE_CASE
    62    string ID = 1;
    63  
    64    // Health of the device.
    65    bool healthy = 2;
    66    
    67    // health_description allows the device plugin to optionally 
    68    // annotate the health field with a human readable reason.
    69    string health_description = 3;
    70  
    71    // hw_locality is optionally set to expose hardware locality information for
    72    // more optimal placement decisions.
    73    DeviceLocality hw_locality = 4;
    74  }
    75  
    76  // DeviceLocality is used to expose HW locality information about a device.
    77  message DeviceLocality {
    78    // pci_bus_id is the PCI bus ID for the device. If reported, it
    79    // allows Nomad to make NUMA aware optimizations.
    80    string pci_bus_id = 1; 
    81  }
    82  
    83  
    84  // ReserveRequest is used to ask the device driver for information on 
    85  // how to allocate the requested devices.
    86  message ReserveRequest {
    87    // device_ids are the requested devices.
    88    repeated string device_ids = 1;
    89  }
    90  
    91  // ReserveResponse informs Nomad how to expose the requested devices
    92  // to the the task.
    93  message ReserveResponse {
    94    // container_res contains information on how to mount the device
    95    // into a task isolated using container technologies (where the 
    96    // host is shared)
    97    ContainerReservation container_res = 1;
    98  }
    99  
   100  // ContainerReservation returns how to mount the device into a 
   101  // container that shares the host OS.
   102  message ContainerReservation {
   103    // List of environment variable to be set
   104    map<string, string> envs = 1;
   105  
   106    // Mounts for the task.
   107    repeated Mount mounts = 2;
   108  
   109    // Devices for the task.
   110    repeated DeviceSpec devices = 3;
   111  }
   112  
   113  // Mount specifies a host volume to mount into a task.
   114  // where device library or tools are installed on host and task
   115  message Mount {
   116    // Path of the mount within the task.
   117    string task_path = 1;
   118  
   119    // Path of the mount on the host.
   120    string host_path = 2;
   121  
   122    // If set, the mount is read-only.
   123    bool read_only = 3;
   124  }
   125  
   126  // DeviceSpec specifies a host device to mount into a task.
   127  message DeviceSpec {
   128    // Path of the device within the task.
   129    string task_path = 1;
   130  
   131    // Path of the device on the host.
   132    string host_path = 2;
   133  
   134    // Cgroups permissions of the device, candidates are one or more of
   135    // * r - allows task to read from the specified device.
   136    // * w - allows task to write to the specified device.
   137    // * m - allows task to create device files that do not yet exist
   138    string permissions = 3;
   139  }
   140  
   141  
   142  // StatsRequest is used to parameterize the retrieval of statistics.
   143  message StatsRequest {
   144      // collection_interval is the duration in which to collect statistics.
   145      google.protobuf.Duration collection_interval = 1;
   146  }
   147  
   148  // StatsResponse returns the statistics for each device group.
   149  message StatsResponse {
   150    // groups contains statistics for each device group.
   151    repeated DeviceGroupStats groups = 1;
   152  }
   153  
   154  // DeviceGroupStats contains statistics for each device of a particular
   155  // device group, identified by the vendor, type and name of the device.
   156  message DeviceGroupStats {
   157    string vendor = 1;
   158    string type = 2;
   159    string name = 3;
   160  
   161    // instance_stats is a mapping of each device ID to its statistics.
   162    map<string, DeviceStats> instance_stats = 4;
   163  }
   164  
   165  // DeviceStats is the statistics for an individual device
   166  message DeviceStats {
   167    // summary exposes a single summary metric that should be the most  
   168    // informative to users.
   169    hashicorp.nomad.plugins.shared.structs.StatValue summary = 1;
   170  
   171    // stats contains the verbose statistics for the device.
   172    hashicorp.nomad.plugins.shared.structs.StatObject stats = 2;
   173  
   174    // timestamp is the time the statistics were collected.
   175    google.protobuf.Timestamp timestamp = 3;
   176  }