From 941af1a340e537d5135fafad89b686de8ccf38e9 Mon Sep 17 00:00:00 2001 From: xieydd Date: Mon, 9 Oct 2023 23:03:41 +0800 Subject: [PATCH] chore: Fix server list return type Signed-off-by: xieydd --- agent/pkg/docs/docs.go | 90 ++++++++++++++++++++++++- agent/pkg/server/handler_server_list.go | 4 +- 2 files changed, 92 insertions(+), 2 deletions(-) diff --git a/agent/pkg/docs/docs.go b/agent/pkg/docs/docs.go index fbe08a9..d0d7e03 100644 --- a/agent/pkg/docs/docs.go +++ b/agent/pkg/docs/docs.go @@ -1085,6 +1085,38 @@ const docTemplate = `{ } } } + }, + "delete": { + "description": "Delete the namespace.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "namespace" + ], + "summary": "Delete the namespace.", + "parameters": [ + { + "description": "Namespace name", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/types.NamespaceRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/types.NamespaceRequest" + } + } + } } }, "/system/scale-inference": { @@ -1226,7 +1258,7 @@ const docTemplate = `{ "schema": { "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/types.Server" } } } @@ -1531,6 +1563,31 @@ const docTemplate = `{ } } }, + "types.NodeSystemInfo": { + "type": "object", + "properties": { + "architecture": { + "description": "The Architecture reported by the node", + "type": "string" + }, + "kernelVersion": { + "description": "Kernel Version reported by the node from 'uname -r' (e.g. 3.16.0-0.bpo.4-amd64).", + "type": "string" + }, + "machineID": { + "description": "MachineID reported by the node. For unique machine identification\nin the cluster this field is preferred. Learn more from man(5)\nmachine-id: http://man7.org/linux/man-pages/man5/machine-id.5.html", + "type": "string" + }, + "operatingSystem": { + "description": "The Operating System reported by the node", + "type": "string" + }, + "osImage": { + "description": "OS Image reported by the node from /etc/os-release (e.g. Debian GNU/Linux 7 (wheezy)).", + "type": "string" + } + } + }, "types.ProviderInfo": { "type": "object", "properties": { @@ -1567,6 +1624,9 @@ const docTemplate = `{ "types.ScaleServiceRequest": { "type": "object", "properties": { + "attempt": { + "type": "integer" + }, "eventMessage": { "type": "string" }, @@ -1607,6 +1667,17 @@ const docTemplate = `{ } } }, + "types.Server": { + "type": "object", + "properties": { + "spec": { + "$ref": "#/definitions/types.ServerSpec" + }, + "status": { + "$ref": "#/definitions/types.ServerStatus" + } + } + }, "types.ServerSpec": { "type": "object", "properties": { @@ -1621,6 +1692,23 @@ const docTemplate = `{ } } }, + "types.ServerStatus": { + "type": "object", + "properties": { + "allocatable": { + "$ref": "#/definitions/types.ResourceList" + }, + "capacity": { + "$ref": "#/definitions/types.ResourceList" + }, + "phase": { + "type": "string" + }, + "system": { + "$ref": "#/definitions/types.NodeSystemInfo" + } + } + }, "types.VersionInfo": { "type": "object", "properties": { diff --git a/agent/pkg/server/handler_server_list.go b/agent/pkg/server/handler_server_list.go index f7a7024..bc452d0 100644 --- a/agent/pkg/server/handler_server_list.go +++ b/agent/pkg/server/handler_server_list.go @@ -4,6 +4,7 @@ import ( "net/http" "github.com/gin-gonic/gin" + "github.com/tensorchord/openmodelz/agent/api/types" ) // @Summary List the servers. @@ -11,9 +12,10 @@ import ( // @Tags namespace // @Accept json // @Produce json -// @Success 200 {object} []string +// @Success 200 {object} []types.Server // @Router /system/servers [get] func (s *Server) handleServerList(c *gin.Context) error { + ns := []types.Server{} ns, err := s.runtime.ServerList(c.Request.Context()) if err != nil { return errFromErrDefs(err, "namespace-list")