feat: add startup script logs to the ui (#6558)

* Add startup script logs to the database

* Add coderd endpoints for startup script logs

* Push startup script logs from agent

* Pull startup script logs on frontend

* Rename queries

* Add constraint

* Start creating log sending loop

* Add log sending to the agent

* Add tests for streaming logs

* Shorten notify channel name

* Add FE

* Improve bulk log performance

* Finish UI display

* Fix startup log visibility

* Add warning for overflow

* Fix agent queue logs overflow

* Display staartup logs in a virtual DOM for performance

* Fix agent queue with loads of logs

* Fix authorize test

* Remove faulty test

* Fix startup and shutdown reporting error

* Fix gen

* Fix comments

* Periodically purge old database entries

* Add test fixture for migration

* Add Storybook

* Check if there are logs when displaying features

* Fix startup component overflow gap

* Fix startup log wrapping

---------

Co-authored-by: Asher <ash@coder.com>
This commit is contained in:
Kyle Carberry
2023-03-23 14:09:13 -05:00
committed by GitHub
co-authored by Asher
parent a6fa8cac58
commit cb7375450b
57 changed files with 2513 additions and 353 deletions
+57
View File
@@ -519,6 +519,8 @@ curl -X GET http://coder-server:8080/api/v2/workspaceagents/{workspaceagent} \
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
"shutdown_script": "string",
"shutdown_script_timeout_seconds": 0,
"startup_logs_length": 0,
"startup_logs_overflowed": true,
"startup_script": "string",
"startup_script_timeout_seconds": 0,
"status": "connecting",
@@ -717,3 +719,58 @@ curl -X GET http://coder-server:8080/api/v2/workspaceagents/{workspaceagent}/pty
| 101 | [Switching Protocols](https://tools.ietf.org/html/rfc7231#section-6.2.2) | Switching Protocols | |
To perform this operation, you must be authenticated. [Learn more](authentication.md).
## Get startup logs by workspace agent
### Code samples
```shell
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/workspaceagents/{workspaceagent}/startup-logs \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY'
```
`GET /workspaceagents/{workspaceagent}/startup-logs`
### Parameters
| Name | In | Type | Required | Description |
| ---------------- | ----- | ------------ | -------- | ------------------ |
| `workspaceagent` | path | string(uuid) | true | Workspace agent ID |
| `before` | query | integer | false | Before log id |
| `after` | query | integer | false | After log id |
| `follow` | query | boolean | false | Follow log stream |
### Example responses
> 200 Response
```json
[
{
"created_at": "2019-08-24T14:15:22Z",
"id": 0,
"output": "string"
}
]
```
### Responses
| Status | Meaning | Description | Schema |
| ------ | ------------------------------------------------------- | ----------- | ----------------------------------------------------------------------------------------- |
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | array of [codersdk.WorkspaceAgentStartupLog](schemas.md#codersdkworkspaceagentstartuplog) |
<h3 id="get-startup-logs-by-workspace-agent-responseschema">Response Schema</h3>
Status Code **200**
| Name | Type | Required | Restrictions | Description |
| -------------- | ----------------- | -------- | ------------ | ----------- |
| `[array item]` | array | false | | |
| `» created_at` | string(date-time) | false | | |
| `» id` | integer | false | | |
| `» output` | string | false | | |
To perform this operation, you must be authenticated. [Learn more](authentication.md).
+16
View File
@@ -106,6 +106,8 @@ curl -X GET http://coder-server:8080/api/v2/users/{user}/workspace/{workspacenam
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
"shutdown_script": "string",
"shutdown_script_timeout_seconds": 0,
"startup_logs_length": 0,
"startup_logs_overflowed": true,
"startup_script": "string",
"startup_script_timeout_seconds": 0,
"status": "connecting",
@@ -256,6 +258,8 @@ curl -X GET http://coder-server:8080/api/v2/workspacebuilds/{workspacebuild} \
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
"shutdown_script": "string",
"shutdown_script_timeout_seconds": 0,
"startup_logs_length": 0,
"startup_logs_overflowed": true,
"startup_script": "string",
"startup_script_timeout_seconds": 0,
"status": "connecting",
@@ -547,6 +551,8 @@ curl -X GET http://coder-server:8080/api/v2/workspacebuilds/{workspacebuild}/res
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
"shutdown_script": "string",
"shutdown_script_timeout_seconds": 0,
"startup_logs_length": 0,
"startup_logs_overflowed": true,
"startup_script": "string",
"startup_script_timeout_seconds": 0,
"status": "connecting",
@@ -627,6 +633,8 @@ Status Code **200**
| `»» resource_id` | string(uuid) | false | | |
| `»» shutdown_script` | string | false | | |
| `»» shutdown_script_timeout_seconds` | integer | false | | |
| `»» startup_logs_length` | integer | false | | |
| `»» startup_logs_overflowed` | boolean | false | | |
| `»» startup_script` | string | false | | |
| `»» startup_script_timeout_seconds` | integer | false | | »startup script timeout seconds is the number of seconds to wait for the startup script to complete. If the script does not complete within this time, the agent lifecycle will be marked as start_timeout. |
| `»» status` | [codersdk.WorkspaceAgentStatus](schemas.md#codersdkworkspaceagentstatus) | false | | |
@@ -781,6 +789,8 @@ curl -X GET http://coder-server:8080/api/v2/workspacebuilds/{workspacebuild}/sta
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
"shutdown_script": "string",
"shutdown_script_timeout_seconds": 0,
"startup_logs_length": 0,
"startup_logs_overflowed": true,
"startup_script": "string",
"startup_script_timeout_seconds": 0,
"status": "connecting",
@@ -936,6 +946,8 @@ curl -X GET http://coder-server:8080/api/v2/workspaces/{workspace}/builds \
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
"shutdown_script": "string",
"shutdown_script_timeout_seconds": 0,
"startup_logs_length": 0,
"startup_logs_overflowed": true,
"startup_script": "string",
"startup_script_timeout_seconds": 0,
"status": "connecting",
@@ -1050,6 +1062,8 @@ Status Code **200**
| `»»» resource_id` | string(uuid) | false | | |
| `»»» shutdown_script` | string | false | | |
| `»»» shutdown_script_timeout_seconds` | integer | false | | |
| `»»» startup_logs_length` | integer | false | | |
| `»»» startup_logs_overflowed` | boolean | false | | |
| `»»» startup_script` | string | false | | |
| `»»» startup_script_timeout_seconds` | integer | false | | »»startup script timeout seconds is the number of seconds to wait for the startup script to complete. If the script does not complete within this time, the agent lifecycle will be marked as start_timeout. |
| `»»» status` | [codersdk.WorkspaceAgentStatus](schemas.md#codersdkworkspaceagentstatus) | false | | |
@@ -1266,6 +1280,8 @@ curl -X POST http://coder-server:8080/api/v2/workspaces/{workspace}/builds \
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
"shutdown_script": "string",
"shutdown_script_timeout_seconds": 0,
"startup_logs_length": 0,
"startup_logs_overflowed": true,
"startup_script": "string",
"startup_script_timeout_seconds": 0,
"status": "connecting",
+65
View File
@@ -200,6 +200,25 @@
| `startup_script_timeout` | integer | false | | |
| `vscode_port_proxy_uri` | string | false | | |
## agentsdk.PatchStartupLogs
```json
{
"logs": [
{
"created_at": "string",
"output": "string"
}
]
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
| ------ | --------------------------------------------------- | -------- | ------------ | ----------- |
| `logs` | array of [agentsdk.StartupLog](#agentsdkstartuplog) | false | | |
## agentsdk.PostAppHealthsRequest
```json
@@ -248,6 +267,22 @@
| `expanded_directory` | string | false | | |
| `version` | string | false | | |
## agentsdk.StartupLog
```json
{
"created_at": "string",
"output": "string"
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
| ------------ | ------ | -------- | ------------ | ----------- |
| `created_at` | string | false | | |
| `output` | string | false | | |
## agentsdk.Stats
```json
@@ -4321,6 +4356,8 @@ Parameter represents a set value for the scope.
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
"shutdown_script": "string",
"shutdown_script_timeout_seconds": 0,
"startup_logs_length": 0,
"startup_logs_overflowed": true,
"startup_script": "string",
"startup_script_timeout_seconds": 0,
"status": "connecting",
@@ -4448,6 +4485,8 @@ Parameter represents a set value for the scope.
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
"shutdown_script": "string",
"shutdown_script_timeout_seconds": 0,
"startup_logs_length": 0,
"startup_logs_overflowed": true,
"startup_script": "string",
"startup_script_timeout_seconds": 0,
"status": "connecting",
@@ -4483,6 +4522,8 @@ Parameter represents a set value for the scope.
| `resource_id` | string | false | | |
| `shutdown_script` | string | false | | |
| `shutdown_script_timeout_seconds` | integer | false | | |
| `startup_logs_length` | integer | false | | |
| `startup_logs_overflowed` | boolean | false | | |
| `startup_script` | string | false | | |
| `startup_script_timeout_seconds` | integer | false | | Startup script timeout seconds is the number of seconds to wait for the startup script to complete. If the script does not complete within this time, the agent lifecycle will be marked as start_timeout. |
| `status` | [codersdk.WorkspaceAgentStatus](#codersdkworkspaceagentstatus) | false | | |
@@ -4614,6 +4655,24 @@ Parameter represents a set value for the scope.
| ------- | ------------------------------------------------------------------------------------- | -------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `ports` | array of [codersdk.WorkspaceAgentListeningPort](#codersdkworkspaceagentlisteningport) | false | | If there are no ports in the list, nothing should be displayed in the UI. There must not be a "no ports available" message or anything similar, as there will always be no ports displayed on platforms where our port detection logic is unsupported. |
## codersdk.WorkspaceAgentStartupLog
```json
{
"created_at": "2019-08-24T14:15:22Z",
"id": 0,
"output": "string"
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
| ------------ | ------- | -------- | ------------ | ----------- |
| `created_at` | string | false | | |
| `id` | integer | false | | |
| `output` | string | false | | |
## codersdk.WorkspaceAgentStatus
```json
@@ -4793,6 +4852,8 @@ Parameter represents a set value for the scope.
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
"shutdown_script": "string",
"shutdown_script_timeout_seconds": 0,
"startup_logs_length": 0,
"startup_logs_overflowed": true,
"startup_script": "string",
"startup_script_timeout_seconds": 0,
"status": "connecting",
@@ -5012,6 +5073,8 @@ Parameter represents a set value for the scope.
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
"shutdown_script": "string",
"shutdown_script_timeout_seconds": 0,
"startup_logs_length": 0,
"startup_logs_overflowed": true,
"startup_script": "string",
"startup_script_timeout_seconds": 0,
"status": "connecting",
@@ -5207,6 +5270,8 @@ Parameter represents a set value for the scope.
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
"shutdown_script": "string",
"shutdown_script_timeout_seconds": 0,
"startup_logs_length": 0,
"startup_logs_overflowed": true,
"startup_script": "string",
"startup_script_timeout_seconds": 0,
"status": "connecting",
+14 -6
View File
@@ -1709,6 +1709,8 @@ curl -X GET http://coder-server:8080/api/v2/templateversions/{templateversion}/d
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
"shutdown_script": "string",
"shutdown_script_timeout_seconds": 0,
"startup_logs_length": 0,
"startup_logs_overflowed": true,
"startup_script": "string",
"startup_script_timeout_seconds": 0,
"status": "connecting",
@@ -1789,6 +1791,8 @@ Status Code **200**
| `»» resource_id` | string(uuid) | false | | |
| `»» shutdown_script` | string | false | | |
| `»» shutdown_script_timeout_seconds` | integer | false | | |
| `»» startup_logs_length` | integer | false | | |
| `»» startup_logs_overflowed` | boolean | false | | |
| `»» startup_script` | string | false | | |
| `»» startup_script_timeout_seconds` | integer | false | | »startup script timeout seconds is the number of seconds to wait for the startup script to complete. If the script does not complete within this time, the agent lifecycle will be marked as start_timeout. |
| `»» status` | [codersdk.WorkspaceAgentStatus](schemas.md#codersdkworkspaceagentstatus) | false | | |
@@ -1917,12 +1921,12 @@ curl -X GET http://coder-server:8080/api/v2/templateversions/{templateversion}/l
### Parameters
| Name | In | Type | Required | Description |
| ----------------- | ----- | ------------ | -------- | --------------------- |
| `templateversion` | path | string(uuid) | true | Template version ID |
| `before` | query | integer | false | Before Unix timestamp |
| `after` | query | integer | false | After Unix timestamp |
| `follow` | query | boolean | false | Follow log stream |
| Name | In | Type | Required | Description |
| ----------------- | ----- | ------------ | -------- | ------------------- |
| `templateversion` | path | string(uuid) | true | Template version ID |
| `before` | query | integer | false | Before log id |
| `after` | query | integer | false | After log id |
| `follow` | query | boolean | false | Follow log stream |
### Example responses
@@ -2134,6 +2138,8 @@ curl -X GET http://coder-server:8080/api/v2/templateversions/{templateversion}/r
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
"shutdown_script": "string",
"shutdown_script_timeout_seconds": 0,
"startup_logs_length": 0,
"startup_logs_overflowed": true,
"startup_script": "string",
"startup_script_timeout_seconds": 0,
"status": "connecting",
@@ -2214,6 +2220,8 @@ Status Code **200**
| `»» resource_id` | string(uuid) | false | | |
| `»» shutdown_script` | string | false | | |
| `»» shutdown_script_timeout_seconds` | integer | false | | |
| `»» startup_logs_length` | integer | false | | |
| `»» startup_logs_overflowed` | boolean | false | | |
| `»» startup_script` | string | false | | |
| `»» startup_script_timeout_seconds` | integer | false | | »startup script timeout seconds is the number of seconds to wait for the startup script to complete. If the script does not complete within this time, the agent lifecycle will be marked as start_timeout. |
| `»» status` | [codersdk.WorkspaceAgentStatus](schemas.md#codersdkworkspaceagentstatus) | false | | |
+8
View File
@@ -138,6 +138,8 @@ curl -X POST http://coder-server:8080/api/v2/organizations/{organization}/member
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
"shutdown_script": "string",
"shutdown_script_timeout_seconds": 0,
"startup_logs_length": 0,
"startup_logs_overflowed": true,
"startup_script": "string",
"startup_script_timeout_seconds": 0,
"status": "connecting",
@@ -308,6 +310,8 @@ curl -X GET http://coder-server:8080/api/v2/users/{user}/workspace/{workspacenam
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
"shutdown_script": "string",
"shutdown_script_timeout_seconds": 0,
"startup_logs_length": 0,
"startup_logs_overflowed": true,
"startup_script": "string",
"startup_script_timeout_seconds": 0,
"status": "connecting",
@@ -497,6 +501,8 @@ curl -X GET http://coder-server:8080/api/v2/workspaces \
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
"shutdown_script": "string",
"shutdown_script_timeout_seconds": 0,
"startup_logs_length": 0,
"startup_logs_overflowed": true,
"startup_script": "string",
"startup_script_timeout_seconds": 0,
"status": "connecting",
@@ -668,6 +674,8 @@ curl -X GET http://coder-server:8080/api/v2/workspaces/{workspace} \
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
"shutdown_script": "string",
"shutdown_script_timeout_seconds": 0,
"startup_logs_length": 0,
"startup_logs_overflowed": true,
"startup_script": "string",
"startup_script_timeout_seconds": 0,
"status": "connecting",