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.
This commit is contained in:
Spike Curtis
2024-02-09 16:17:20 +04:00
committed by GitHub
parent 1f5a6d59ba
commit 92b2e26a48
4 changed files with 81 additions and 66 deletions
+6 -5
View File
@@ -215,9 +215,9 @@ func TestBatchCreateLogs(t *testing.T) {
LogSourceId: logSource.ID[:],
Logs: []*agentproto.Log{},
})
require.Error(t, err)
require.ErrorContains(t, err, "workspace agent logs overflowed")
require.Nil(t, resp)
require.NoError(t, err)
require.NotNil(t, resp)
require.True(t, resp.LogLimitExceeded)
require.False(t, publishWorkspaceUpdateCalled)
require.False(t, publishWorkspaceAgentLogsUpdateCalled)
})
@@ -419,8 +419,9 @@ func TestBatchCreateLogs(t *testing.T) {
},
},
})
require.Error(t, err)
require.Nil(t, resp)
require.NoError(t, err)
require.NotNil(t, resp)
require.True(t, resp.LogLimitExceeded)
require.True(t, publishWorkspaceUpdateCalled)
require.False(t, publishWorkspaceAgentLogsUpdateCalled)
})