Skip to content

feat: send log limit exceeded in response, not error #12078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 70 additions & 58 deletions agent/proto/agent.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion agent/proto/agent.proto
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ message BatchCreateLogsRequest {
repeated Log logs = 2;
}

message BatchCreateLogsResponse {}
message BatchCreateLogsResponse {
bool log_limit_exceeded = 1;
}

service Agent {
rpc GetManifest(GetManifestRequest) returns (Manifest);
Expand Down
4 changes: 2 additions & 2 deletions coderd/agentapi/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (a *LogsAPI) BatchCreateLogs(ctx context.Context, req *agentproto.BatchCrea
return nil, err
}
if workspaceAgent.LogsOverflowed {
return nil, xerrors.New("workspace agent logs overflowed")
return &agentproto.BatchCreateLogsResponse{LogLimitExceeded: true}, nil
}

if len(req.Logs) == 0 {
Expand Down Expand Up @@ -128,7 +128,7 @@ func (a *LogsAPI) BatchCreateLogs(ctx context.Context, req *agentproto.BatchCrea
return nil, xerrors.Errorf("publish workspace update: %w", err)
}
}
return nil, xerrors.New("workspace agent log limit exceeded")
return &agentproto.BatchCreateLogsResponse{LogLimitExceeded: true}, nil
}

// Publish by the lowest log ID inserted so the log stream will fetch
Expand Down
11 changes: 6 additions & 5 deletions coderd/agentapi/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down Expand Up @@ -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)
})
Expand Down