chore: rename startup logs to agent logs (#8649)

* chore: rename startup logs to agent logs

This also adds a `source` property to every agent log. It
should allow us to group logs and display them nicer in
the UI as they stream in.

* Fix migration order

* Fix naming

* Rename the frontend

* Fix tests

* Fix down migration

* Match enums for workspace agent logs

* Fix inserting log source

* Fix migration order

* Fix logs tests

* Fix psql insert
This commit is contained in:
Kyle Carberry
2023-07-28 15:57:23 +00:00
committed by GitHub
parent 78b06397a6
commit bd944e0d21
48 changed files with 1471 additions and 876 deletions
+170 -47
View File
@@ -4565,6 +4565,45 @@ const docTemplate = `{
}
}
},
"/workspaceagents/me/logs": {
"patch": {
"security": [
{
"CoderSessionToken": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Agents"
],
"summary": "Patch workspace agent logs",
"operationId": "patch-workspace-agent-logs",
"parameters": [
{
"description": "logs",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/agentsdk.PatchLogs"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.Response"
}
}
}
}
},
"/workspaceagents/me/manifest": {
"get": {
"security": [
@@ -4764,16 +4803,16 @@ const docTemplate = `{
"tags": [
"Agents"
],
"summary": "Patch workspace agent startup logs",
"operationId": "patch-workspace-agent-startup-logs",
"summary": "Removed: Patch workspace agent logs",
"operationId": "removed-patch-workspace-agent-logs",
"parameters": [
{
"description": "Startup logs",
"description": "logs",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/agentsdk.PatchStartupLogs"
"$ref": "#/definitions/agentsdk.PatchLogs"
}
}
],
@@ -4959,6 +4998,68 @@ const docTemplate = `{
}
}
},
"/workspaceagents/{workspaceagent}/logs": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": [
"application/json"
],
"tags": [
"Agents"
],
"summary": "Get logs by workspace agent",
"operationId": "get-logs-by-workspace-agent",
"parameters": [
{
"type": "string",
"format": "uuid",
"description": "Workspace agent ID",
"name": "workspaceagent",
"in": "path",
"required": true
},
{
"type": "integer",
"description": "Before log id",
"name": "before",
"in": "query"
},
{
"type": "integer",
"description": "After log id",
"name": "after",
"in": "query"
},
{
"type": "boolean",
"description": "Follow log stream",
"name": "follow",
"in": "query"
},
{
"type": "boolean",
"description": "Disable compression for WebSocket connection",
"name": "no_compression",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/codersdk.WorkspaceAgentLog"
}
}
}
}
}
},
"/workspaceagents/{workspaceagent}/pty": {
"get": {
"security": [
@@ -5001,8 +5102,8 @@ const docTemplate = `{
"tags": [
"Agents"
],
"summary": "Get startup logs by workspace agent",
"operationId": "get-startup-logs-by-workspace-agent",
"summary": "Removed: Get logs by workspace agent",
"operationId": "removed-get-logs-by-workspace-agent",
"parameters": [
{
"type": "string",
@@ -5043,7 +5144,7 @@ const docTemplate = `{
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/codersdk.WorkspaceAgentStartupLog"
"$ref": "#/definitions/codersdk.WorkspaceAgentLog"
}
}
}
@@ -6213,6 +6314,23 @@ const docTemplate = `{
}
}
},
"agentsdk.Log": {
"type": "object",
"properties": {
"created_at": {
"type": "string"
},
"level": {
"$ref": "#/definitions/codersdk.LogLevel"
},
"output": {
"type": "string"
},
"source": {
"$ref": "#/definitions/codersdk.WorkspaceAgentLogSource"
}
}
},
"agentsdk.Manifest": {
"type": "object",
"properties": {
@@ -6270,13 +6388,13 @@ const docTemplate = `{
}
}
},
"agentsdk.PatchStartupLogs": {
"agentsdk.PatchLogs": {
"type": "object",
"properties": {
"logs": {
"type": "array",
"items": {
"$ref": "#/definitions/agentsdk.StartupLog"
"$ref": "#/definitions/agentsdk.Log"
}
}
}
@@ -6337,20 +6455,6 @@ const docTemplate = `{
}
}
},
"agentsdk.StartupLog": {
"type": "object",
"properties": {
"created_at": {
"type": "string"
},
"level": {
"$ref": "#/definitions/codersdk.LogLevel"
},
"output": {
"type": "string"
}
}
},
"agentsdk.Stats": {
"type": "object",
"properties": {
@@ -10325,6 +10429,12 @@ const docTemplate = `{
"description": "Deprecated: Use StartupScriptBehavior instead.",
"type": "boolean"
},
"logs_length": {
"type": "integer"
},
"logs_overflowed": {
"type": "boolean"
},
"name": {
"type": "string"
},
@@ -10349,12 +10459,6 @@ const docTemplate = `{
"type": "string",
"format": "date-time"
},
"startup_logs_length": {
"type": "integer"
},
"startup_logs_overflowed": {
"type": "boolean"
},
"startup_script": {
"type": "string"
},
@@ -10462,6 +10566,43 @@ const docTemplate = `{
}
}
},
"codersdk.WorkspaceAgentLog": {
"type": "object",
"properties": {
"created_at": {
"type": "string",
"format": "date-time"
},
"id": {
"type": "integer"
},
"level": {
"$ref": "#/definitions/codersdk.LogLevel"
},
"output": {
"type": "string"
}
}
},
"codersdk.WorkspaceAgentLogSource": {
"type": "string",
"enum": [
"startup_script",
"shutdown_script",
"kubernetes",
"envbox",
"envbuilder",
"external"
],
"x-enum-varnames": [
"WorkspaceAgentLogSourceStartupScript",
"WorkspaceAgentLogSourceShutdownScript",
"WorkspaceAgentLogSourceKubernetes",
"WorkspaceAgentLogSourceEnvbox",
"WorkspaceAgentLogSourceEnvbuilder",
"WorkspaceAgentLogSourceExternal"
]
},
"codersdk.WorkspaceAgentMetadataDescription": {
"type": "object",
"properties": {
@@ -10482,24 +10623,6 @@ const docTemplate = `{
}
}
},
"codersdk.WorkspaceAgentStartupLog": {
"type": "object",
"properties": {
"created_at": {
"type": "string",
"format": "date-time"
},
"id": {
"type": "integer"
},
"level": {
"$ref": "#/definitions/codersdk.LogLevel"
},
"output": {
"type": "string"
}
}
},
"codersdk.WorkspaceAgentStartupScriptBehavior": {
"type": "string",
"enum": [
+188 -75
View File
@@ -4017,6 +4017,39 @@
}
}
},
"/workspaceagents/me/logs": {
"patch": {
"security": [
{
"CoderSessionToken": []
}
],
"consumes": ["application/json"],
"produces": ["application/json"],
"tags": ["Agents"],
"summary": "Patch workspace agent logs",
"operationId": "patch-workspace-agent-logs",
"parameters": [
{
"description": "logs",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/agentsdk.PatchLogs"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.Response"
}
}
}
}
},
"/workspaceagents/me/manifest": {
"get": {
"security": [
@@ -4186,16 +4219,16 @@
"consumes": ["application/json"],
"produces": ["application/json"],
"tags": ["Agents"],
"summary": "Patch workspace agent startup logs",
"operationId": "patch-workspace-agent-startup-logs",
"summary": "Removed: Patch workspace agent logs",
"operationId": "removed-patch-workspace-agent-logs",
"parameters": [
{
"description": "Startup logs",
"description": "logs",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/agentsdk.PatchStartupLogs"
"$ref": "#/definitions/agentsdk.PatchLogs"
}
}
],
@@ -4363,34 +4396,7 @@
}
}
},
"/workspaceagents/{workspaceagent}/pty": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"tags": ["Agents"],
"summary": "Open PTY to workspace agent",
"operationId": "open-pty-to-workspace-agent",
"parameters": [
{
"type": "string",
"format": "uuid",
"description": "Workspace agent ID",
"name": "workspaceagent",
"in": "path",
"required": true
}
],
"responses": {
"101": {
"description": "Switching Protocols"
}
}
}
},
"/workspaceagents/{workspaceagent}/startup-logs": {
"/workspaceagents/{workspaceagent}/logs": {
"get": {
"security": [
{
@@ -4399,8 +4405,8 @@
],
"produces": ["application/json"],
"tags": ["Agents"],
"summary": "Get startup logs by workspace agent",
"operationId": "get-startup-logs-by-workspace-agent",
"summary": "Get logs by workspace agent",
"operationId": "get-logs-by-workspace-agent",
"parameters": [
{
"type": "string",
@@ -4441,7 +4447,92 @@
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/codersdk.WorkspaceAgentStartupLog"
"$ref": "#/definitions/codersdk.WorkspaceAgentLog"
}
}
}
}
}
},
"/workspaceagents/{workspaceagent}/pty": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"tags": ["Agents"],
"summary": "Open PTY to workspace agent",
"operationId": "open-pty-to-workspace-agent",
"parameters": [
{
"type": "string",
"format": "uuid",
"description": "Workspace agent ID",
"name": "workspaceagent",
"in": "path",
"required": true
}
],
"responses": {
"101": {
"description": "Switching Protocols"
}
}
}
},
"/workspaceagents/{workspaceagent}/startup-logs": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": ["application/json"],
"tags": ["Agents"],
"summary": "Removed: Get logs by workspace agent",
"operationId": "removed-get-logs-by-workspace-agent",
"parameters": [
{
"type": "string",
"format": "uuid",
"description": "Workspace agent ID",
"name": "workspaceagent",
"in": "path",
"required": true
},
{
"type": "integer",
"description": "Before log id",
"name": "before",
"in": "query"
},
{
"type": "integer",
"description": "After log id",
"name": "after",
"in": "query"
},
{
"type": "boolean",
"description": "Follow log stream",
"name": "follow",
"in": "query"
},
{
"type": "boolean",
"description": "Disable compression for WebSocket connection",
"name": "no_compression",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/codersdk.WorkspaceAgentLog"
}
}
}
@@ -5473,6 +5564,23 @@
}
}
},
"agentsdk.Log": {
"type": "object",
"properties": {
"created_at": {
"type": "string"
},
"level": {
"$ref": "#/definitions/codersdk.LogLevel"
},
"output": {
"type": "string"
},
"source": {
"$ref": "#/definitions/codersdk.WorkspaceAgentLogSource"
}
}
},
"agentsdk.Manifest": {
"type": "object",
"properties": {
@@ -5530,13 +5638,13 @@
}
}
},
"agentsdk.PatchStartupLogs": {
"agentsdk.PatchLogs": {
"type": "object",
"properties": {
"logs": {
"type": "array",
"items": {
"$ref": "#/definitions/agentsdk.StartupLog"
"$ref": "#/definitions/agentsdk.Log"
}
}
}
@@ -5597,20 +5705,6 @@
}
}
},
"agentsdk.StartupLog": {
"type": "object",
"properties": {
"created_at": {
"type": "string"
},
"level": {
"$ref": "#/definitions/codersdk.LogLevel"
},
"output": {
"type": "string"
}
}
},
"agentsdk.Stats": {
"type": "object",
"properties": {
@@ -9354,6 +9448,12 @@
"description": "Deprecated: Use StartupScriptBehavior instead.",
"type": "boolean"
},
"logs_length": {
"type": "integer"
},
"logs_overflowed": {
"type": "boolean"
},
"name": {
"type": "string"
},
@@ -9378,12 +9478,6 @@
"type": "string",
"format": "date-time"
},
"startup_logs_length": {
"type": "integer"
},
"startup_logs_overflowed": {
"type": "boolean"
},
"startup_script": {
"type": "string"
},
@@ -9491,6 +9585,43 @@
}
}
},
"codersdk.WorkspaceAgentLog": {
"type": "object",
"properties": {
"created_at": {
"type": "string",
"format": "date-time"
},
"id": {
"type": "integer"
},
"level": {
"$ref": "#/definitions/codersdk.LogLevel"
},
"output": {
"type": "string"
}
}
},
"codersdk.WorkspaceAgentLogSource": {
"type": "string",
"enum": [
"startup_script",
"shutdown_script",
"kubernetes",
"envbox",
"envbuilder",
"external"
],
"x-enum-varnames": [
"WorkspaceAgentLogSourceStartupScript",
"WorkspaceAgentLogSourceShutdownScript",
"WorkspaceAgentLogSourceKubernetes",
"WorkspaceAgentLogSourceEnvbox",
"WorkspaceAgentLogSourceEnvbuilder",
"WorkspaceAgentLogSourceExternal"
]
},
"codersdk.WorkspaceAgentMetadataDescription": {
"type": "object",
"properties": {
@@ -9511,24 +9642,6 @@
}
}
},
"codersdk.WorkspaceAgentStartupLog": {
"type": "object",
"properties": {
"created_at": {
"type": "string",
"format": "date-time"
},
"id": {
"type": "integer"
},
"level": {
"$ref": "#/definitions/codersdk.LogLevel"
},
"output": {
"type": "string"
}
}
},
"codersdk.WorkspaceAgentStartupScriptBehavior": {
"type": "string",
"enum": ["blocking", "non-blocking"],