[YUNIKORN-1086] expose reservation in node rest response (#436)
The reservations details are exposed in the node object. A flag to show
if the node is reserved and a list of reservations keys. The reservation
key is the application ID and allocation ID separated by a pipe
symbol "|"
Closes: #436
Signed-off-by: Wilfred Spiegelenburg <wilfreds@apache.org>
diff --git a/pkg/webservice/dao/node_info.go b/pkg/webservice/dao/node_info.go
index 39ceae6..18700c2 100644
--- a/pkg/webservice/dao/node_info.go
+++ b/pkg/webservice/dao/node_info.go
@@ -24,14 +24,16 @@
}
type NodeDAOInfo struct {
- NodeID string `json:"nodeID"`
- HostName string `json:"hostName"`
- RackName string `json:"rackName"`
- Capacity map[string]int64 `json:"capacity"`
- Allocated map[string]int64 `json:"allocated"`
- Occupied map[string]int64 `json:"occupied"`
- Available map[string]int64 `json:"available"`
- Utilized map[string]int64 `json:"utilized"`
- Allocations []*AllocationDAOInfo `json:"allocations"`
- Schedulable bool `json:"schedulable"`
+ NodeID string `json:"nodeID"`
+ HostName string `json:"hostName"`
+ RackName string `json:"rackName"`
+ Capacity map[string]int64 `json:"capacity"`
+ Allocated map[string]int64 `json:"allocated"`
+ Occupied map[string]int64 `json:"occupied"`
+ Available map[string]int64 `json:"available"`
+ Utilized map[string]int64 `json:"utilized"`
+ Allocations []*AllocationDAOInfo `json:"allocations"`
+ Schedulable bool `json:"schedulable"`
+ IsReserved bool `json:"isReserved"`
+ Reservations []string `json:"reservations"`
}
diff --git a/pkg/webservice/handlers.go b/pkg/webservice/handlers.go
index 0905602..cb2109d 100644
--- a/pkg/webservice/handlers.go
+++ b/pkg/webservice/handlers.go
@@ -316,16 +316,18 @@
}
return &dao.NodeDAOInfo{
- NodeID: node.NodeID,
- HostName: node.Hostname,
- RackName: node.Rackname,
- Capacity: node.GetCapacity().DAOMap(),
- Occupied: node.GetOccupiedResource().DAOMap(),
- Allocated: node.GetAllocatedResource().DAOMap(),
- Available: node.GetAvailableResource().DAOMap(),
- Utilized: node.GetUtilizedResource().DAOMap(),
- Allocations: allocations,
- Schedulable: node.IsSchedulable(),
+ NodeID: node.NodeID,
+ HostName: node.Hostname,
+ RackName: node.Rackname,
+ Capacity: node.GetCapacity().DAOMap(),
+ Occupied: node.GetOccupiedResource().DAOMap(),
+ Allocated: node.GetAllocatedResource().DAOMap(),
+ Available: node.GetAvailableResource().DAOMap(),
+ Utilized: node.GetUtilizedResource().DAOMap(),
+ Allocations: allocations,
+ Schedulable: node.IsSchedulable(),
+ IsReserved: node.IsReserved(),
+ Reservations: node.GetReservations(),
}
}
diff --git a/pkg/webservice/handlers_test.go b/pkg/webservice/handlers_test.go
index 65d75b9..c12de9c 100644
--- a/pkg/webservice/handlers_test.go
+++ b/pkg/webservice/handlers_test.go
@@ -988,6 +988,12 @@
assert.Equal(t, 1, len(partitionNodesDao[0].Allocations))
for _, node := range partitionNodesDao {
assert.Equal(t, 1, len(node.Allocations))
+ if !node.IsReserved {
+ assert.Equal(t, len(node.Reservations), 0)
+ } else {
+ assert.Check(t, len(node.Reservations) > 0, "Get wrong reservation info from node dao")
+ }
+
if node.NodeID == node1ID {
assert.Equal(t, node.NodeID, node1ID)
assert.Equal(t, "alloc-1", node.Allocations[0].AllocationKey)