From 6f3e1ffbe31166f16070479eff0cb2c71018bdcb Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Wed, 18 Jun 2025 13:02:11 +0200 Subject: [PATCH] Add ressource ounts to node table --- internal/api/node.go | 10 +++++++-- .../migrations/sqlite3/10_node-table.up.sql | 6 +++++ pkg/schema/node.go | 22 ++++++++++++------- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/internal/api/node.go b/internal/api/node.go index 675e5f6..61d7943 100644 --- a/internal/api/node.go +++ b/internal/api/node.go @@ -14,8 +14,14 @@ import ( ) type Node struct { - Name string `json:"hostname"` - States []string `json:"states"` + Name string `json:"hostname"` + States []string `json:"states"` + CpusAllocated int `json:"cpusAllocated"` + CpusTotal int `json:"cpusTotal"` + MemoryAllocated int `json:"memoryAllocated"` + MemoryTotal int `json:"memoryTotal"` + GpusAllocated int `json:"gpusAllocated"` + GpusTotal int `json:"gpusTotal"` } // updateNodeStatesRequest model diff --git a/internal/repository/migrations/sqlite3/10_node-table.up.sql b/internal/repository/migrations/sqlite3/10_node-table.up.sql index a11f20d..6ba5e25 100644 --- a/internal/repository/migrations/sqlite3/10_node-table.up.sql +++ b/internal/repository/migrations/sqlite3/10_node-table.up.sql @@ -3,6 +3,12 @@ CREATE TABLE "node" ( hostname VARCHAR(255) NOT NULL, cluster VARCHAR(255) NOT NULL, subcluster VARCHAR(255) NOT NULL, + cpus_allocated INTEGER NOT NULL, + cpus_total INTEGER NOT NULL, + memory_allocated INTEGER NOT NULL, + memory_total INTEGER NOT NULL, + gpus_allocated INTEGER NOT NULL, + gpus_total INTEGER NOT NULL, node_state VARCHAR(255) NOT NULL CHECK (node_state IN ( 'allocated', 'reserved', 'idle', 'mixed', diff --git a/pkg/schema/node.go b/pkg/schema/node.go index 3e2bbfb..7fd4b70 100644 --- a/pkg/schema/node.go +++ b/pkg/schema/node.go @@ -24,12 +24,18 @@ const ( ) type Node struct { - ID int64 `json:"id" db:"id"` - Hostname string `json:"hostname" db:"hostname" example:"fritz"` - Cluster string `json:"cluster" db:"cluster" example:"fritz"` - SubCluster string `json:"subCluster" db:"subcluster" example:"main"` - NodeState NodeState `json:"nodeState" db:"node_state" example:"completed" enums:"completed,failed,cancelled,stopped,timeout,out_of_memory"` - HealthState MonitoringState `json:"healthState" db:"health_state" example:"completed" enums:"completed,failed,cancelled,stopped,timeout,out_of_memory"` - RawMetaData []byte `json:"-" db:"meta_data"` - MetaData map[string]string `json:"metaData"` + ID int64 `json:"id" db:"id"` + Hostname string `json:"hostname" db:"hostname" example:"fritz"` + Cluster string `json:"cluster" db:"cluster" example:"fritz"` + SubCluster string `json:"subCluster" db:"subcluster" example:"main"` + NodeState NodeState `json:"nodeState" db:"node_state" example:"completed" enums:"completed,failed,cancelled,stopped,timeout,out_of_memory"` + HealthState MonitoringState `json:"healthState" db:"health_state" example:"completed" enums:"completed,failed,cancelled,stopped,timeout,out_of_memory"` + CpusAllocated int `json:"cpusAllocated" db:"cpus_allocated"` + CpusTotal int `json:"cpusTotal" db:"cpus_total"` + MemoryAllocated int `json:"memoryAllocated" db:"memory_allocated"` + MemoryTotal int `json:"memoryTotal" db:"memory_total"` + GpusAllocated int `json:"gpusAllocated" db:"gpus_allocated"` + GpusTotal int `json:"gpusTotal" db:"gpus_total"` + RawMetaData []byte `json:"-" db:"meta_data"` + MetaData map[string]string `json:"metaData"` }