github.com/manicqin/nomad@v0.9.5/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 "github.com/hashicorp/nomad/plugins/shared/structs/proto/attribute.proto";
     8  import "github.com/hashicorp/nomad/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    string ID = 1;
    62  
    63    // Health of the device.
    64    bool healthy = 2;
    65    
    66    // health_description allows the device plugin to optionally 
    67    // annotate the health field with a human readable reason.
    68    string health_description = 3;
    69  
    70    // hw_locality is optionally set to expose hardware locality information for
    71    // more optimal placement decisions.
    72    DeviceLocality hw_locality = 4;
    73  }
    74  
    75  // DeviceLocality is used to expose HW locality information about a device.
    76  message DeviceLocality {
    77    // pci_bus_id is the PCI bus ID for the device. If reported, it
    78    // allows Nomad to make NUMA aware optimizations.
    79    string pci_bus_id = 1; 
    80  }
    81  
    82  
    83  // ReserveRequest is used to ask the device driver for information on 
    84  // how to allocate the requested devices.
    85  message ReserveRequest {
    86    // device_ids are the requested devices.
    87    repeated string device_ids = 1;
    88  }
    89  
    90  // ReserveResponse informs Nomad how to expose the requested devices
    91  // to the the task.
    92  message ReserveResponse {
    93    // container_res contains information on how to mount the device
    94    // into a task isolated using container technologies (where the 
    95    // host is shared)
    96    ContainerReservation container_res = 1;
    97  }
    98  
    99  // ContainerReservation returns how to mount the device into a 
   100  // container that shares the host OS.
   101  message ContainerReservation {
   102    // List of environment variable to be set
   103    map<string, string> envs = 1;
   104  
   105    // Mounts for the task.
   106    repeated Mount mounts = 2;
   107  
   108    // Devices for the task.
   109    repeated DeviceSpec devices = 3;
   110  }
   111  
   112  // Mount specifies a host volume to mount into a task.
   113  // where device library or tools are installed on host and task
   114  message Mount {
   115    // Path of the mount within the task.
   116    string task_path = 1;
   117  
   118    // Path of the mount on the host.
   119    string host_path = 2;
   120  
   121    // If set, the mount is read-only.
   122    bool read_only = 3;
   123  }
   124  
   125  // DeviceSpec specifies a host device to mount into a task.
   126  message DeviceSpec {
   127    // Path of the device within the task.
   128    string task_path = 1;
   129  
   130    // Path of the device on the host.
   131    string host_path = 2;
   132  
   133    // Cgroups permissions of the device, candidates are one or more of
   134    // * r - allows task to read from the specified device.
   135    // * w - allows task to write to the specified device.
   136    // * m - allows task to create device files that do not yet exist
   137    string permissions = 3;
   138  }
   139  
   140  
   141  // StatsRequest is used to parameterize the retrieval of statistics.
   142  message StatsRequest {
   143      // collection_interval is the duration in which to collect statistics.
   144      google.protobuf.Duration collection_interval = 1;
   145  }
   146  
   147  // StatsResponse returns the statistics for each device group.
   148  message StatsResponse {
   149    // groups contains statistics for each device group.
   150    repeated DeviceGroupStats groups = 1;
   151  }
   152  
   153  // DeviceGroupStats contains statistics for each device of a particular
   154  // device group, identified by the vendor, type and name of the device.
   155  message DeviceGroupStats {
   156    string vendor = 1;
   157    string type = 2;
   158    string name = 3;
   159  
   160    // instance_stats is a mapping of each device ID to its statistics.
   161    map<string, DeviceStats> instance_stats = 4;
   162  }
   163  
   164  // DeviceStats is the statistics for an individual device
   165  message DeviceStats {
   166    // summary exposes a single summary metric that should be the most  
   167    // informative to users.
   168    hashicorp.nomad.plugins.shared.structs.StatValue summary = 1;
   169  
   170    // stats contains the verbose statistics for the device.
   171    hashicorp.nomad.plugins.shared.structs.StatObject stats = 2;
   172  
   173    // timestamp is the time the statistics were collected.
   174    google.protobuf.Timestamp timestamp = 3;
   175  }