Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit92b2e26

Browse files
authored
feat: send log limit exceeded in response, not error (#12078)
When we exceed the db-imposed limit of logs, we need to communicate that back to the agent. In v1 we did it with a 4xx-level HTTP status, but with dRPC, the errors are delivered as strings, which feels fragile to me for something we want to gracefully handle.So, this PR adds the log limit exceeded as a field on the response message, and fixes the API handler to set it as appropriate instead of an error.
1 parent1f5a6d5 commit92b2e26

File tree

4 files changed

+81
-66
lines changed

4 files changed

+81
-66
lines changed

‎agent/proto/agent.pb.go

Lines changed: 70 additions & 58 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎agent/proto/agent.proto

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,9 @@ message BatchCreateLogsRequest {
247247
repeatedLoglogs=2;
248248
}
249249

250-
messageBatchCreateLogsResponse {}
250+
messageBatchCreateLogsResponse {
251+
boollog_limit_exceeded=1;
252+
}
251253

252254
serviceAgent {
253255
rpcGetManifest(GetManifestRequest)returns (Manifest);

‎coderd/agentapi/logs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func (a *LogsAPI) BatchCreateLogs(ctx context.Context, req *agentproto.BatchCrea
3737
returnnil,err
3838
}
3939
ifworkspaceAgent.LogsOverflowed {
40-
returnnil,xerrors.New("workspace agent logs overflowed")
40+
return&agentproto.BatchCreateLogsResponse{LogLimitExceeded:true},nil
4141
}
4242

4343
iflen(req.Logs)==0 {
@@ -128,7 +128,7 @@ func (a *LogsAPI) BatchCreateLogs(ctx context.Context, req *agentproto.BatchCrea
128128
returnnil,xerrors.Errorf("publish workspace update: %w",err)
129129
}
130130
}
131-
returnnil,xerrors.New("workspace agent log limit exceeded")
131+
return&agentproto.BatchCreateLogsResponse{LogLimitExceeded:true},nil
132132
}
133133

134134
// Publish by the lowest log ID inserted so the log stream will fetch

‎coderd/agentapi/logs_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ func TestBatchCreateLogs(t *testing.T) {
215215
LogSourceId:logSource.ID[:],
216216
Logs: []*agentproto.Log{},
217217
})
218-
require.Error(t,err)
219-
require.ErrorContains(t,err,"workspace agent logs overflowed")
220-
require.Nil(t,resp)
218+
require.NoError(t,err)
219+
require.NotNil(t,resp)
220+
require.True(t,resp.LogLimitExceeded)
221221
require.False(t,publishWorkspaceUpdateCalled)
222222
require.False(t,publishWorkspaceAgentLogsUpdateCalled)
223223
})
@@ -419,8 +419,9 @@ func TestBatchCreateLogs(t *testing.T) {
419419
},
420420
},
421421
})
422-
require.Error(t,err)
423-
require.Nil(t,resp)
422+
require.NoError(t,err)
423+
require.NotNil(t,resp)
424+
require.True(t,resp.LogLimitExceeded)
424425
require.True(t,publishWorkspaceUpdateCalled)
425426
require.False(t,publishWorkspaceAgentLogsUpdateCalled)
426427
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp