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:
Mathias Fredriksson
2023-06-20 14:41:55 +03:00
committed by GitHub
parent b1d1b63113
commit 8dac0356ed
29 changed files with 462 additions and 540 deletions

18
coderd/apidoc/docs.go generated
View File

@ -5812,6 +5812,9 @@ const docTemplate = `{
"agentsdk.PostLifecycleRequest": {
"type": "object",
"properties": {
"changed_at": {
"type": "string"
},
"state": {
"$ref": "#/definitions/codersdk.WorkspaceAgentLifecycle"
}
@ -5856,9 +5859,6 @@ const docTemplate = `{
"created_at": {
"type": "string"
},
"eof": {
"type": "boolean"
},
"level": {
"$ref": "#/definitions/codersdk.LogLevel"
},
@ -9256,6 +9256,10 @@ const docTemplate = `{
"operating_system": {
"type": "string"
},
"ready_at": {
"type": "string",
"format": "date-time"
},
"resource_id": {
"type": "string",
"format": "uuid"
@ -9266,6 +9270,10 @@ const docTemplate = `{
"shutdown_script_timeout_seconds": {
"type": "integer"
},
"started_at": {
"type": "string",
"format": "date-time"
},
"startup_logs_length": {
"type": "integer"
},
@ -9388,10 +9396,6 @@ const docTemplate = `{
"type": "string",
"format": "date-time"
},
"eof": {
"description": "EOF indicates that this is the last log entry and the file is closed.",
"type": "boolean"
},
"id": {
"type": "integer"
},