Skip to content

Commit 34fde1a

Browse files
committed
Fix agent queue logs overflow
1 parent 05d536c commit 34fde1a

File tree

11 files changed

+56
-26
lines changed

11 files changed

+56
-26
lines changed

agent/agent.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -694,12 +694,12 @@ func (a *agent) runScript(ctx context.Context, lifecycle, script string) error {
694694
logMutex.Lock()
695695
defer logMutex.Unlock()
696696
queuedLogs = append(queuedLogs, log)
697-
if flushLogsTimer != nil {
698-
flushLogsTimer.Reset(100 * time.Millisecond)
697+
if len(queuedLogs) > 25 {
698+
go sendLogs()
699699
return
700700
}
701-
if len(queuedLogs) > 100 {
702-
go sendLogs()
701+
if flushLogsTimer != nil {
702+
flushLogsTimer.Reset(100 * time.Millisecond)
703703
return
704704
}
705705
flushLogsTimer = time.AfterFunc(100*time.Millisecond, func() {

coderd/apidoc/docs.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/agents.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ curl -X GET http://coder-server:8080/api/v2/workspaceagents/{workspaceagent} \
519519
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
520520
"shutdown_script": "string",
521521
"shutdown_script_timeout_seconds": 0,
522+
"startup_logs_overflowed": true,
522523
"startup_script": "string",
523524
"startup_script_timeout_seconds": 0,
524525
"status": "connecting",

docs/api/builds.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ curl -X GET http://coder-server:8080/api/v2/users/{user}/workspace/{workspacenam
106106
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
107107
"shutdown_script": "string",
108108
"shutdown_script_timeout_seconds": 0,
109+
"startup_logs_overflowed": true,
109110
"startup_script": "string",
110111
"startup_script_timeout_seconds": 0,
111112
"status": "connecting",
@@ -256,6 +257,7 @@ curl -X GET http://coder-server:8080/api/v2/workspacebuilds/{workspacebuild} \
256257
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
257258
"shutdown_script": "string",
258259
"shutdown_script_timeout_seconds": 0,
260+
"startup_logs_overflowed": true,
259261
"startup_script": "string",
260262
"startup_script_timeout_seconds": 0,
261263
"status": "connecting",
@@ -547,6 +549,7 @@ curl -X GET http://coder-server:8080/api/v2/workspacebuilds/{workspacebuild}/res
547549
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
548550
"shutdown_script": "string",
549551
"shutdown_script_timeout_seconds": 0,
552+
"startup_logs_overflowed": true,
550553
"startup_script": "string",
551554
"startup_script_timeout_seconds": 0,
552555
"status": "connecting",
@@ -627,6 +630,7 @@ Status Code **200**
627630
| `»» resource_id` | string(uuid) | false | | |
628631
| `»» shutdown_script` | string | false | | |
629632
| `»» shutdown_script_timeout_seconds` | integer | false | | |
633+
| `»» startup_logs_overflowed` | boolean | false | | |
630634
| `»» startup_script` | string | false | | |
631635
| `»» 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. |
632636
| `»» status` | [codersdk.WorkspaceAgentStatus](schemas.md#codersdkworkspaceagentstatus) | false | | |
@@ -781,6 +785,7 @@ curl -X GET http://coder-server:8080/api/v2/workspacebuilds/{workspacebuild}/sta
781785
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
782786
"shutdown_script": "string",
783787
"shutdown_script_timeout_seconds": 0,
788+
"startup_logs_overflowed": true,
784789
"startup_script": "string",
785790
"startup_script_timeout_seconds": 0,
786791
"status": "connecting",
@@ -936,6 +941,7 @@ curl -X GET http://coder-server:8080/api/v2/workspaces/{workspace}/builds \
936941
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
937942
"shutdown_script": "string",
938943
"shutdown_script_timeout_seconds": 0,
944+
"startup_logs_overflowed": true,
939945
"startup_script": "string",
940946
"startup_script_timeout_seconds": 0,
941947
"status": "connecting",
@@ -1050,6 +1056,7 @@ Status Code **200**
10501056
| `»»» resource_id` | string(uuid) | false | | |
10511057
| `»»» shutdown_script` | string | false | | |
10521058
| `»»» shutdown_script_timeout_seconds` | integer | false | | |
1059+
| `»»» startup_logs_overflowed` | boolean | false | | |
10531060
| `»»» startup_script` | string | false | | |
10541061
| `»»» 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. |
10551062
| `»»» status` | [codersdk.WorkspaceAgentStatus](schemas.md#codersdkworkspaceagentstatus) | false | | |
@@ -1266,6 +1273,7 @@ curl -X POST http://coder-server:8080/api/v2/workspaces/{workspace}/builds \
12661273
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
12671274
"shutdown_script": "string",
12681275
"shutdown_script_timeout_seconds": 0,
1276+
"startup_logs_overflowed": true,
12691277
"startup_script": "string",
12701278
"startup_script_timeout_seconds": 0,
12711279
"status": "connecting",

docs/api/schemas.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4274,6 +4274,7 @@ Parameter represents a set value for the scope.
42744274
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
42754275
"shutdown_script": "string",
42764276
"shutdown_script_timeout_seconds": 0,
4277+
"startup_logs_overflowed": true,
42774278
"startup_script": "string",
42784279
"startup_script_timeout_seconds": 0,
42794280
"status": "connecting",
@@ -4399,6 +4400,7 @@ Parameter represents a set value for the scope.
43994400
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
44004401
"shutdown_script": "string",
44014402
"shutdown_script_timeout_seconds": 0,
4403+
"startup_logs_overflowed": true,
44024404
"startup_script": "string",
44034405
"startup_script_timeout_seconds": 0,
44044406
"status": "connecting",
@@ -4434,6 +4436,7 @@ Parameter represents a set value for the scope.
44344436
| `resource_id` | string | false | | |
44354437
| `shutdown_script` | string | false | | |
44364438
| `shutdown_script_timeout_seconds` | integer | false | | |
4439+
| `startup_logs_overflowed` | boolean | false | | |
44374440
| `startup_script` | string | false | | |
44384441
| `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. |
44394442
| `status` | [codersdk.WorkspaceAgentStatus](#codersdkworkspaceagentstatus) | false | | |
@@ -4744,6 +4747,7 @@ Parameter represents a set value for the scope.
47444747
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
47454748
"shutdown_script": "string",
47464749
"shutdown_script_timeout_seconds": 0,
4750+
"startup_logs_overflowed": true,
47474751
"startup_script": "string",
47484752
"startup_script_timeout_seconds": 0,
47494753
"status": "connecting",
@@ -4963,6 +4967,7 @@ Parameter represents a set value for the scope.
49634967
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
49644968
"shutdown_script": "string",
49654969
"shutdown_script_timeout_seconds": 0,
4970+
"startup_logs_overflowed": true,
49664971
"startup_script": "string",
49674972
"startup_script_timeout_seconds": 0,
49684973
"status": "connecting",
@@ -5158,6 +5163,7 @@ Parameter represents a set value for the scope.
51585163
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
51595164
"shutdown_script": "string",
51605165
"shutdown_script_timeout_seconds": 0,
5166+
"startup_logs_overflowed": true,
51615167
"startup_script": "string",
51625168
"startup_script_timeout_seconds": 0,
51635169
"status": "connecting",

docs/api/templates.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,6 +1624,7 @@ curl -X GET http://coder-server:8080/api/v2/templateversions/{templateversion}/d
16241624
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
16251625
"shutdown_script": "string",
16261626
"shutdown_script_timeout_seconds": 0,
1627+
"startup_logs_overflowed": true,
16271628
"startup_script": "string",
16281629
"startup_script_timeout_seconds": 0,
16291630
"status": "connecting",
@@ -1704,6 +1705,7 @@ Status Code **200**
17041705
| `»» resource_id` | string(uuid) | false | | |
17051706
| `»» shutdown_script` | string | false | | |
17061707
| `»» shutdown_script_timeout_seconds` | integer | false | | |
1708+
| `»» startup_logs_overflowed` | boolean | false | | |
17071709
| `»» startup_script` | string | false | | |
17081710
| `»» 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. |
17091711
| `»» status` | [codersdk.WorkspaceAgentStatus](schemas.md#codersdkworkspaceagentstatus) | false | | |
@@ -2049,6 +2051,7 @@ curl -X GET http://coder-server:8080/api/v2/templateversions/{templateversion}/r
20492051
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
20502052
"shutdown_script": "string",
20512053
"shutdown_script_timeout_seconds": 0,
2054+
"startup_logs_overflowed": true,
20522055
"startup_script": "string",
20532056
"startup_script_timeout_seconds": 0,
20542057
"status": "connecting",
@@ -2129,6 +2132,7 @@ Status Code **200**
21292132
| `»» resource_id` | string(uuid) | false | | |
21302133
| `»» shutdown_script` | string | false | | |
21312134
| `»» shutdown_script_timeout_seconds` | integer | false | | |
2135+
| `»» startup_logs_overflowed` | boolean | false | | |
21322136
| `»» startup_script` | string | false | | |
21332137
| `»» 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. |
21342138
| `»» status` | [codersdk.WorkspaceAgentStatus](schemas.md#codersdkworkspaceagentstatus) | false | | |

0 commit comments

Comments
 (0)