diff --git a/cmd/metal-api/internal/service/partition-service.go b/cmd/metal-api/internal/service/partition-service.go index 09a1bc389..b5fcfbe64 100644 --- a/cmd/metal-api/internal/service/partition-service.go +++ b/cmd/metal-api/internal/service/partition-service.go @@ -433,7 +433,7 @@ func (r *partitionResource) calcPartitionCapacity(pcr *v1.PartitionCapacityReque reservation := reservation cap.Reservations += reservation.Amount - cap.UnusedReservations += max(reservation.Amount-len(machinesByProject[reservation.ProjectID]), 0) + cap.UsedReservations += len(machinesByProject[reservation.ProjectID]) } } diff --git a/cmd/metal-api/internal/service/partition-service_test.go b/cmd/metal-api/internal/service/partition-service_test.go index 5a370a120..2ac060d60 100644 --- a/cmd/metal-api/internal/service/partition-service_test.go +++ b/cmd/metal-api/internal/service/partition-service_test.go @@ -289,5 +289,5 @@ func TestPartitionCapacity(t *testing.T) { require.Equal(t, 5, c.Total) require.Equal(t, 0, c.Free) require.Equal(t, 0, c.Reservations) - require.Equal(t, 0, c.UnusedReservations) + require.Equal(t, 0, c.UsedReservations) } diff --git a/cmd/metal-api/internal/service/v1/partition.go b/cmd/metal-api/internal/service/v1/partition.go index 908b150f2..7bea44237 100644 --- a/cmd/metal-api/internal/service/v1/partition.go +++ b/cmd/metal-api/internal/service/v1/partition.go @@ -47,16 +47,16 @@ type PartitionCapacity struct { } type ServerCapacity struct { - Size string `json:"size" description:"the size of the server"` - Total int `json:"total" description:"total amount of servers with this size"` - Free int `json:"free" description:"free servers with this size"` - Allocated int `json:"allocated" description:"allocated servers with this size"` - Reservations int `json:"reservations" description:"the amount of reservations for this size"` - UnusedReservations int `json:"unusedreservations" description:"the amount of unused reservations for this size"` - Faulty int `json:"faulty" description:"servers with issues with this size"` - FaultyMachines []string `json:"faultymachines" description:"servers with issues with this size"` - Other int `json:"other" description:"servers neither free, allocated or faulty with this size"` - OtherMachines []string `json:"othermachines" description:"servers neither free, allocated or faulty with this size"` + Size string `json:"size" description:"the size of the server"` + Total int `json:"total" description:"total amount of servers with this size"` + Free int `json:"free" description:"free servers with this size"` + Allocated int `json:"allocated" description:"allocated servers with this size"` + Reservations int `json:"reservations" description:"the amount of reservations for this size"` + UsedReservations int `json:"usedreservations" description:"the amount of used reservations for this size"` + Faulty int `json:"faulty" description:"servers with issues with this size"` + FaultyMachines []string `json:"faultymachines" description:"servers with issues with this size"` + Other int `json:"other" description:"servers neither free, allocated or faulty with this size"` + OtherMachines []string `json:"othermachines" description:"servers neither free, allocated or faulty with this size"` } func NewPartitionResponse(p *metal.Partition) *PartitionResponse { diff --git a/spec/metal-api.json b/spec/metal-api.json index 02fe540d2..6310ee36b 100644 --- a/spec/metal-api.json +++ b/spec/metal-api.json @@ -4262,8 +4262,8 @@ "format": "int32", "type": "integer" }, - "unusedreservations": { - "description": "the amount of unused reservations for this size", + "usedreservations": { + "description": "the amount of used reservations for this size", "format": "int32", "type": "integer" } @@ -4278,7 +4278,7 @@ "reservations", "size", "total", - "unusedreservations" + "usedreservations" ] }, "v1.SizeConstraint": {