mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
refactor: replace startup script logs EOF with starting/ready time (#8082)
This commit reverts some of the changes in #8029 and implements an alternative method of keeping track of when the startup script has ended and there will be no more logs. This is achieved by adding new agent fields for tracking when the agent enters the "starting" and "ready"/"start_error" lifecycle states. The timestamps simplify logic since we don't need understand if the current state is before or after the state we're interested in. They can also be used to show data like how long the startup script took to execute. This also allowed us to remove the EOF field from the logs as the implementation was problematic when we returned the EOF log entry in the response since requesting _after_ that ID would give no logs and the API would thus lose track of EOF.
This commit is contained in:
+9
-9
@@ -466,9 +466,11 @@ curl -X GET http://coder-server:8080/api/v2/workspaceagents/{workspaceagent} \
|
||||
"login_before_ready": 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,
|
||||
"started_at": "2019-08-24T14:15:22Z",
|
||||
"startup_logs_length": 0,
|
||||
"startup_logs_overflowed": true,
|
||||
"startup_script": "string",
|
||||
@@ -702,7 +704,6 @@ curl -X GET http://coder-server:8080/api/v2/workspaceagents/{workspaceagent}/sta
|
||||
[
|
||||
{
|
||||
"created_at": "2019-08-24T14:15:22Z",
|
||||
"eof": true,
|
||||
"id": 0,
|
||||
"level": "trace",
|
||||
"output": "string"
|
||||
@@ -720,14 +721,13 @@ curl -X GET http://coder-server:8080/api/v2/workspaceagents/{workspaceagent}/sta
|
||||
|
||||
Status Code **200**
|
||||
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
| -------------- | ------------------------------------------------ | -------- | ------------ | --------------------------------------------------------------------- |
|
||||
| `[array item]` | array | false | | |
|
||||
| `» created_at` | string(date-time) | false | | |
|
||||
| `» eof` | boolean | false | | Eof indicates that this is the last log entry and the file is closed. |
|
||||
| `» id` | integer | false | | |
|
||||
| `» level` | [codersdk.LogLevel](schemas.md#codersdkloglevel) | false | | |
|
||||
| `» output` | string | false | | |
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
| -------------- | ------------------------------------------------ | -------- | ------------ | ----------- |
|
||||
| `[array item]` | array | false | | |
|
||||
| `» created_at` | string(date-time) | false | | |
|
||||
| `» id` | integer | false | | |
|
||||
| `» level` | [codersdk.LogLevel](schemas.md#codersdkloglevel) | false | | |
|
||||
| `» output` | string | false | | |
|
||||
|
||||
#### Enumerated Values
|
||||
|
||||
|
||||
@@ -103,9 +103,11 @@ curl -X GET http://coder-server:8080/api/v2/users/{user}/workspace/{workspacenam
|
||||
"login_before_ready": 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,
|
||||
"started_at": "2019-08-24T14:15:22Z",
|
||||
"startup_logs_length": 0,
|
||||
"startup_logs_overflowed": true,
|
||||
"startup_script": "string",
|
||||
@@ -257,9 +259,11 @@ curl -X GET http://coder-server:8080/api/v2/workspacebuilds/{workspacebuild} \
|
||||
"login_before_ready": 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,
|
||||
"started_at": "2019-08-24T14:15:22Z",
|
||||
"startup_logs_length": 0,
|
||||
"startup_logs_overflowed": true,
|
||||
"startup_script": "string",
|
||||
@@ -552,9 +556,11 @@ curl -X GET http://coder-server:8080/api/v2/workspacebuilds/{workspacebuild}/res
|
||||
"login_before_ready": 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,
|
||||
"started_at": "2019-08-24T14:15:22Z",
|
||||
"startup_logs_length": 0,
|
||||
"startup_logs_overflowed": true,
|
||||
"startup_script": "string",
|
||||
@@ -636,9 +642,11 @@ Status Code **200**
|
||||
| `»» login_before_ready` | boolean | false | | Deprecated: Use StartupScriptBehavior instead. |
|
||||
| `»» name` | string | false | | |
|
||||
| `»» operating_system` | string | false | | |
|
||||
| `»» ready_at` | string(date-time) | false | | |
|
||||
| `»» resource_id` | string(uuid) | false | | |
|
||||
| `»» shutdown_script` | string | false | | |
|
||||
| `»» shutdown_script_timeout_seconds` | integer | false | | |
|
||||
| `»» started_at` | string(date-time) | false | | |
|
||||
| `»» startup_logs_length` | integer | false | | |
|
||||
| `»» startup_logs_overflowed` | boolean | false | | |
|
||||
| `»» startup_script` | string | false | | |
|
||||
@@ -797,9 +805,11 @@ curl -X GET http://coder-server:8080/api/v2/workspacebuilds/{workspacebuild}/sta
|
||||
"login_before_ready": 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,
|
||||
"started_at": "2019-08-24T14:15:22Z",
|
||||
"startup_logs_length": 0,
|
||||
"startup_logs_overflowed": true,
|
||||
"startup_script": "string",
|
||||
@@ -956,9 +966,11 @@ curl -X GET http://coder-server:8080/api/v2/workspaces/{workspace}/builds \
|
||||
"login_before_ready": 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,
|
||||
"started_at": "2019-08-24T14:15:22Z",
|
||||
"startup_logs_length": 0,
|
||||
"startup_logs_overflowed": true,
|
||||
"startup_script": "string",
|
||||
@@ -1074,9 +1086,11 @@ Status Code **200**
|
||||
| `»»» login_before_ready` | boolean | false | | Deprecated: Use StartupScriptBehavior instead. |
|
||||
| `»»» name` | string | false | | |
|
||||
| `»»» operating_system` | string | false | | |
|
||||
| `»»» ready_at` | string(date-time) | false | | |
|
||||
| `»»» resource_id` | string(uuid) | false | | |
|
||||
| `»»» shutdown_script` | string | false | | |
|
||||
| `»»» shutdown_script_timeout_seconds` | integer | false | | |
|
||||
| `»»» started_at` | string(date-time) | false | | |
|
||||
| `»»» startup_logs_length` | integer | false | | |
|
||||
| `»»» startup_logs_overflowed` | boolean | false | | |
|
||||
| `»»» startup_script` | string | false | | |
|
||||
@@ -1289,9 +1303,11 @@ curl -X POST http://coder-server:8080/api/v2/workspaces/{workspace}/builds \
|
||||
"login_before_ready": 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,
|
||||
"started_at": "2019-08-24T14:15:22Z",
|
||||
"startup_logs_length": 0,
|
||||
"startup_logs_overflowed": true,
|
||||
"startup_script": "string",
|
||||
|
||||
+23
-14
@@ -280,7 +280,6 @@
|
||||
"logs": [
|
||||
{
|
||||
"created_at": "string",
|
||||
"eof": true,
|
||||
"level": "trace",
|
||||
"output": "string"
|
||||
}
|
||||
@@ -316,15 +315,17 @@
|
||||
|
||||
```json
|
||||
{
|
||||
"changed_at": "string",
|
||||
"state": "created"
|
||||
}
|
||||
```
|
||||
|
||||
### Properties
|
||||
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
| ------- | -------------------------------------------------------------------- | -------- | ------------ | ----------- |
|
||||
| `state` | [codersdk.WorkspaceAgentLifecycle](#codersdkworkspaceagentlifecycle) | false | | |
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
| ------------ | -------------------------------------------------------------------- | -------- | ------------ | ----------- |
|
||||
| `changed_at` | string | false | | |
|
||||
| `state` | [codersdk.WorkspaceAgentLifecycle](#codersdkworkspaceagentlifecycle) | false | | |
|
||||
|
||||
## agentsdk.PostMetadataRequest
|
||||
|
||||
@@ -369,7 +370,6 @@
|
||||
```json
|
||||
{
|
||||
"created_at": "string",
|
||||
"eof": true,
|
||||
"level": "trace",
|
||||
"output": "string"
|
||||
}
|
||||
@@ -380,7 +380,6 @@
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
| ------------ | -------------------------------------- | -------- | ------------ | ----------- |
|
||||
| `created_at` | string | false | | |
|
||||
| `eof` | boolean | false | | |
|
||||
| `level` | [codersdk.LogLevel](#codersdkloglevel) | false | | |
|
||||
| `output` | string | false | | |
|
||||
|
||||
@@ -4512,9 +4511,11 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
"login_before_ready": 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,
|
||||
"started_at": "2019-08-24T14:15:22Z",
|
||||
"startup_logs_length": 0,
|
||||
"startup_logs_overflowed": true,
|
||||
"startup_script": "string",
|
||||
@@ -4644,9 +4645,11 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
"login_before_ready": 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,
|
||||
"started_at": "2019-08-24T14:15:22Z",
|
||||
"startup_logs_length": 0,
|
||||
"startup_logs_overflowed": true,
|
||||
"startup_script": "string",
|
||||
@@ -4683,9 +4686,11 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
| `login_before_ready` | boolean | false | | Deprecated: Use StartupScriptBehavior instead. |
|
||||
| `name` | string | false | | |
|
||||
| `operating_system` | string | false | | |
|
||||
| `ready_at` | string | false | | |
|
||||
| `resource_id` | string | false | | |
|
||||
| `shutdown_script` | string | false | | |
|
||||
| `shutdown_script_timeout_seconds` | integer | false | | |
|
||||
| `started_at` | string | false | | |
|
||||
| `startup_logs_length` | integer | false | | |
|
||||
| `startup_logs_overflowed` | boolean | false | | |
|
||||
| `startup_script` | string | false | | |
|
||||
@@ -4848,7 +4853,6 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
```json
|
||||
{
|
||||
"created_at": "2019-08-24T14:15:22Z",
|
||||
"eof": true,
|
||||
"id": 0,
|
||||
"level": "trace",
|
||||
"output": "string"
|
||||
@@ -4857,13 +4861,12 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
|
||||
### Properties
|
||||
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
| ------------ | -------------------------------------- | -------- | ------------ | --------------------------------------------------------------------- |
|
||||
| `created_at` | string | false | | |
|
||||
| `eof` | boolean | false | | Eof indicates that this is the last log entry and the file is closed. |
|
||||
| `id` | integer | false | | |
|
||||
| `level` | [codersdk.LogLevel](#codersdkloglevel) | false | | |
|
||||
| `output` | string | false | | |
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
| ------------ | -------------------------------------- | -------- | ------------ | ----------- |
|
||||
| `created_at` | string | false | | |
|
||||
| `id` | integer | false | | |
|
||||
| `level` | [codersdk.LogLevel](#codersdkloglevel) | false | | |
|
||||
| `output` | string | false | | |
|
||||
|
||||
## codersdk.WorkspaceAgentStartupScriptBehavior
|
||||
|
||||
@@ -5056,9 +5059,11 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
"login_before_ready": 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,
|
||||
"started_at": "2019-08-24T14:15:22Z",
|
||||
"startup_logs_length": 0,
|
||||
"startup_logs_overflowed": true,
|
||||
"startup_script": "string",
|
||||
@@ -5339,9 +5344,11 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
"login_before_ready": 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,
|
||||
"started_at": "2019-08-24T14:15:22Z",
|
||||
"startup_logs_length": 0,
|
||||
"startup_logs_overflowed": true,
|
||||
"startup_script": "string",
|
||||
@@ -5539,9 +5546,11 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
|
||||
"login_before_ready": 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,
|
||||
"started_at": "2019-08-24T14:15:22Z",
|
||||
"startup_logs_length": 0,
|
||||
"startup_logs_overflowed": true,
|
||||
"startup_script": "string",
|
||||
|
||||
@@ -1654,9 +1654,11 @@ curl -X GET http://coder-server:8080/api/v2/templateversions/{templateversion}/d
|
||||
"login_before_ready": 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,
|
||||
"started_at": "2019-08-24T14:15:22Z",
|
||||
"startup_logs_length": 0,
|
||||
"startup_logs_overflowed": true,
|
||||
"startup_script": "string",
|
||||
@@ -1738,9 +1740,11 @@ Status Code **200**
|
||||
| `»» login_before_ready` | boolean | false | | Deprecated: Use StartupScriptBehavior instead. |
|
||||
| `»» name` | string | false | | |
|
||||
| `»» operating_system` | string | false | | |
|
||||
| `»» ready_at` | string(date-time) | false | | |
|
||||
| `»» resource_id` | string(uuid) | false | | |
|
||||
| `»» shutdown_script` | string | false | | |
|
||||
| `»» shutdown_script_timeout_seconds` | integer | false | | |
|
||||
| `»» started_at` | string(date-time) | false | | |
|
||||
| `»» startup_logs_length` | integer | false | | |
|
||||
| `»» startup_logs_overflowed` | boolean | false | | |
|
||||
| `»» startup_script` | string | false | | |
|
||||
@@ -2035,9 +2039,11 @@ curl -X GET http://coder-server:8080/api/v2/templateversions/{templateversion}/r
|
||||
"login_before_ready": 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,
|
||||
"started_at": "2019-08-24T14:15:22Z",
|
||||
"startup_logs_length": 0,
|
||||
"startup_logs_overflowed": true,
|
||||
"startup_script": "string",
|
||||
@@ -2119,9 +2125,11 @@ Status Code **200**
|
||||
| `»» login_before_ready` | boolean | false | | Deprecated: Use StartupScriptBehavior instead. |
|
||||
| `»» name` | string | false | | |
|
||||
| `»» operating_system` | string | false | | |
|
||||
| `»» ready_at` | string(date-time) | false | | |
|
||||
| `»» resource_id` | string(uuid) | false | | |
|
||||
| `»» shutdown_script` | string | false | | |
|
||||
| `»» shutdown_script_timeout_seconds` | integer | false | | |
|
||||
| `»» started_at` | string(date-time) | false | | |
|
||||
| `»» startup_logs_length` | integer | false | | |
|
||||
| `»» startup_logs_overflowed` | boolean | false | | |
|
||||
| `»» startup_script` | string | false | | |
|
||||
|
||||
@@ -127,9 +127,11 @@ curl -X POST http://coder-server:8080/api/v2/organizations/{organization}/member
|
||||
"login_before_ready": 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,
|
||||
"started_at": "2019-08-24T14:15:22Z",
|
||||
"startup_logs_length": 0,
|
||||
"startup_logs_overflowed": true,
|
||||
"startup_script": "string",
|
||||
@@ -302,9 +304,11 @@ curl -X GET http://coder-server:8080/api/v2/users/{user}/workspace/{workspacenam
|
||||
"login_before_ready": 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,
|
||||
"started_at": "2019-08-24T14:15:22Z",
|
||||
"startup_logs_length": 0,
|
||||
"startup_logs_overflowed": true,
|
||||
"startup_script": "string",
|
||||
@@ -497,9 +501,11 @@ curl -X GET http://coder-server:8080/api/v2/workspaces \
|
||||
"login_before_ready": 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,
|
||||
"started_at": "2019-08-24T14:15:22Z",
|
||||
"startup_logs_length": 0,
|
||||
"startup_logs_overflowed": true,
|
||||
"startup_script": "string",
|
||||
@@ -673,9 +679,11 @@ curl -X GET http://coder-server:8080/api/v2/workspaces/{workspace} \
|
||||
"login_before_ready": 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,
|
||||
"started_at": "2019-08-24T14:15:22Z",
|
||||
"startup_logs_length": 0,
|
||||
"startup_logs_overflowed": true,
|
||||
"startup_script": "string",
|
||||
|
||||
Reference in New Issue
Block a user