feat: add support for coder_script (#9584)

* Add basic migrations

* Improve schema

* Refactor agent scripts into it's own package

* Support legacy start and stop script format

* Pipe the scripts!

* Finish the piping

* Fix context usage

* It works!

* Fix sql query

* Fix SQL query

* Rename `LogSourceID` -> `SourceID`

* Fix the FE

* fmt

* Rename migrations

* Fix log tests

* Fix lint err

* Fix gen

* Fix story type

* Rename source to script

* Fix schema jank

* Uncomment test

* Rename proto to TimeoutSeconds

* Fix comments

* Fix comments

* Fix legacy endpoint without specified log_source

* Fix non-blocking by default in agent

* Fix resources tests

* Fix dbfake

* Fix resources

* Fix linting I think

* Add fixtures

* fmt

* Fix startup script behavior

* Fix comments

* Fix context

* Fix cancel

* Fix SQL tests

* Fix e2e tests

* Interrupt on Windows

* Fix agent leaking script process

* Fix migrations

* Fix stories

* Fix duplicate logs appearing

* Gen

* Fix log location

* Fix tests

* Fix tests

* Fix log output

* Show display name in output

* Fix print

* Return timeout on start context

* Gen

* Fix fixture

* Fix the agent status

* Fix startup timeout msg

* Fix command using shared context

* Fix timeout draining

* Change signal type

* Add deterministic colors to startup script logs

---------

Co-authored-by: Muhammad Atif Ali <atif@coder.com>
This commit is contained in:
Kyle Carberry
2023-09-25 16:47:17 -05:00
committed by GitHub
co-authored by Muhammad Atif Ali
parent dac1375880
commit 1262eef2c0
61 changed files with 3820 additions and 2117 deletions
+43 -15
View File
@@ -311,12 +311,12 @@ curl -X PATCH http://coder-server:8080/api/v2/workspaceagents/me/logs \
```json
{
"log_source_id": "string",
"logs": [
{
"created_at": "string",
"level": "trace",
"output": "string",
"source": "startup_script"
"output": "string"
}
]
}
@@ -470,10 +470,18 @@ curl -X GET http://coder-server:8080/api/v2/workspaceagents/me/manifest \
}
],
"motd_file": "string",
"shutdown_script": "string",
"shutdown_script_timeout": 0,
"startup_script": "string",
"startup_script_timeout": 0,
"scripts": [
{
"cron": "string",
"log_path": "string",
"log_source_id": "4197ab25-95cf-4b91-9c78-f7f2af5d353a",
"run_on_start": true,
"run_on_stop": true,
"script": "string",
"start_blocks_login": true,
"timeout": 0
}
],
"vscode_port_proxy_uri": "string"
}
```
@@ -576,12 +584,12 @@ curl -X PATCH http://coder-server:8080/api/v2/workspaceagents/me/startup-logs \
```json
{
"log_source_id": "string",
"logs": [
{
"created_at": "string",
"level": "trace",
"output": "string",
"source": "startup_script"
"output": "string"
}
]
}
@@ -693,19 +701,35 @@ curl -X GET http://coder-server:8080/api/v2/workspaceagents/{workspaceagent} \
}
},
"lifecycle_state": "created",
"login_before_ready": true,
"log_sources": [
{
"created_at": "2019-08-24T14:15:22Z",
"display_name": "string",
"icon": "string",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"workspace_agent_id": "7ad2e618-fea7-4c1a-b70a-f501566a72f1"
}
],
"logs_length": 0,
"logs_overflowed": true,
"name": "string",
"operating_system": "string",
"ready_at": "2019-08-24T14:15:22Z",
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
"shutdown_script": "string",
"shutdown_script_timeout_seconds": 0,
"scripts": [
{
"cron": "string",
"log_path": "string",
"log_source_id": "4197ab25-95cf-4b91-9c78-f7f2af5d353a",
"run_on_start": true,
"run_on_stop": true,
"script": "string",
"start_blocks_login": true,
"timeout": 0
}
],
"started_at": "2019-08-24T14:15:22Z",
"startup_script": "string",
"startup_script_behavior": "blocking",
"startup_script_timeout_seconds": 0,
"status": "connecting",
"subsystems": ["envbox"],
"troubleshooting_url": "string",
@@ -921,7 +945,8 @@ curl -X GET http://coder-server:8080/api/v2/workspaceagents/{workspaceagent}/log
"created_at": "2019-08-24T14:15:22Z",
"id": 0,
"level": "trace",
"output": "string"
"output": "string",
"source_id": "ae50a35c-df42-4eff-ba26-f8bc28d2af81"
}
]
```
@@ -943,6 +968,7 @@ Status Code **200**
| `» id` | integer | false | | |
| `» level` | [codersdk.LogLevel](schemas.md#codersdkloglevel) | false | | |
| `» output` | string | false | | |
| `» source_id` | string(uuid) | false | | |
#### Enumerated Values
@@ -1015,7 +1041,8 @@ curl -X GET http://coder-server:8080/api/v2/workspaceagents/{workspaceagent}/sta
"created_at": "2019-08-24T14:15:22Z",
"id": 0,
"level": "trace",
"output": "string"
"output": "string",
"source_id": "ae50a35c-df42-4eff-ba26-f8bc28d2af81"
}
]
```
@@ -1037,6 +1064,7 @@ Status Code **200**
| `» id` | integer | false | | |
| `» level` | [codersdk.LogLevel](schemas.md#codersdkloglevel) | false | | |
| `» output` | string | false | | |
| `» source_id` | string(uuid) | false | | |
#### Enumerated Values