Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(inventory): generate grpc gateways #109

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 63 additions & 6 deletions docs/proto/provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@
- [akash/inventory/v1/cluster.proto](#akash/inventory/v1/cluster.proto)
- [Cluster](#akash.inventory.v1.Cluster)

- [akash/inventory/v1/resources.proto](#akash/inventory/v1/resources.proto)
- [NodeResources](#akash.inventory.v1.NodeResources)

- [akash/inventory/v1/node.proto](#akash/inventory/v1/node.proto)
- [Node](#akash.inventory.v1.Node)
- [NodeCapabilities](#akash.inventory.v1.NodeCapabilities)

- [akash/inventory/v1/resourcepair.proto](#akash/inventory/v1/resourcepair.proto)
- [ResourcePair](#akash.inventory.v1.ResourcePair)
Expand Down Expand Up @@ -545,6 +549,42 @@



<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



<a name="akash/inventory/v1/resources.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## akash/inventory/v1/resources.proto



<a name="akash.inventory.v1.NodeResources"></a>

### NodeResources
NodeResources reports node inventory details


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `cpu` | [CPU](#akash.inventory.v1.CPU) | | |
| `memory` | [Memory](#akash.inventory.v1.Memory) | | |
| `gpu` | [GPU](#akash.inventory.v1.GPU) | | |
| `ephemeral_storage` | [ResourcePair](#akash.inventory.v1.ResourcePair) | | |
| `volumes_attached` | [ResourcePair](#akash.inventory.v1.ResourcePair) | | |
| `volumes_mounted` | [ResourcePair](#akash.inventory.v1.ResourcePair) | | |





<!-- end messages -->

<!-- end enums -->
Expand All @@ -570,10 +610,24 @@

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `cpu` | [CPU](#akash.inventory.v1.CPU) | | |
| `memory` | [Memory](#akash.inventory.v1.Memory) | | |
| `gpu` | [GPU](#akash.inventory.v1.GPU) | | |
| `storage` | [Storage](#akash.inventory.v1.Storage) | | |
| `name` | [string](#string) | | |
| `resources` | [NodeResources](#akash.inventory.v1.NodeResources) | | |
| `capabilities` | [NodeCapabilities](#akash.inventory.v1.NodeCapabilities) | | |






<a name="akash.inventory.v1.NodeCapabilities"></a>

### NodeCapabilities
NodeCapabilities extended list of node capabilities


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `storage_classes` | [string](#string) | repeated | |



Expand Down Expand Up @@ -654,6 +708,7 @@
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `vendor` | [string](#string) | | |
| `vendor_id` | [string](#string) | | |
| `name` | [string](#string) | | |
| `modelid` | [string](#string) | | |
| `interface` | [string](#string) | | |
Expand Down Expand Up @@ -751,7 +806,8 @@

| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `QueryCluster` | [VoidNoParam](#akash.inventory.v1.VoidNoParam) | [Cluster](#akash.inventory.v1.Cluster) stream | QueryNode defines a method to query and stream hardware state of the cluster buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE buf:lint:ignore RPC_RESPONSE_STANDARD_NAME | |
| `QueryCluster` | [VoidNoParam](#akash.inventory.v1.VoidNoParam) | [Cluster](#akash.inventory.v1.Cluster) | QueryCluster defines a method to query hardware state of the cluster buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE buf:lint:ignore RPC_RESPONSE_STANDARD_NAME | GET|/v1/inventory|
| `StreamCluster` | [VoidNoParam](#akash.inventory.v1.VoidNoParam) | [Cluster](#akash.inventory.v1.Cluster) stream | StreamCluster defines a method to stream hardware state of the cluster buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE buf:lint:ignore RPC_RESPONSE_STANDARD_NAME | |


<a name="akash.inventory.v1.NodeRPC"></a>
Expand All @@ -761,7 +817,8 @@

| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `QueryNode` | [VoidNoParam](#akash.inventory.v1.VoidNoParam) | [Node](#akash.inventory.v1.Node) stream | QueryNode defines a method to query and stream hardware state of the node buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE buf:lint:ignore RPC_RESPONSE_STANDARD_NAME | |
| `QueryNode` | [VoidNoParam](#akash.inventory.v1.VoidNoParam) | [Node](#akash.inventory.v1.Node) | QueryNode defines a method to query hardware state of the node buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE buf:lint:ignore RPC_RESPONSE_STANDARD_NAME | GET|/v1/node|
| `StreamNode` | [VoidNoParam](#akash.inventory.v1.VoidNoParam) | [Node](#akash.inventory.v1.Node) stream | StreamNode defines a method to stream hardware state of the node buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE buf:lint:ignore RPC_RESPONSE_STANDARD_NAME | |

<!-- end services -->

Expand Down
1 change: 1 addition & 0 deletions go/inventory/v1/gpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func (r *GPU) Dup() GPU {
func (s *GPUInfo) Dup() GPUInfo {
res := GPUInfo{
Vendor: s.Vendor,
VendorID: s.VendorID,
Name: s.Name,
ModelID: s.ModelID,
Interface: s.Interface,
Expand Down
135 changes: 94 additions & 41 deletions go/inventory/v1/gpu.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 25 additions & 4 deletions go/inventory/v1/node.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
package v1

func (nd *NodeCapabilities) Dup() NodeCapabilities {
res := NodeCapabilities{
StorageClasses: make([]string, 0, len(nd.StorageClasses)),
}

for _, class := range nd.StorageClasses {
res.StorageClasses = append(res.StorageClasses, class)
}

return res
}

func (nd Nodes) Dup() Nodes {
res := make(Nodes, 0, len(nd))

Expand All @@ -11,11 +23,20 @@ func (nd Nodes) Dup() Nodes {

func (nd *Node) Dup() Node {
res := Node{
CPU: nd.CPU.Dup(),
GPU: nd.GPU.Dup(),
Memory: nd.Memory.Dup(),
EphemeralStorage: nd.EphemeralStorage.Dup(),
Name: nd.Name,
Resources: nd.Resources.Dup(),
Capabilities: nd.Capabilities.Dup(),
}

return res
}

func (nd *Node) IsStorageClassSupported(class string) bool {
for _, val := range nd.Capabilities.StorageClasses {
if val == class {
return true
}
}

return false
}
Loading