internal/gomote: add ListDirectoryStreaming RPC

ListDirectory responses can overflow the maximum RPC message size.
Add a streaming version which returns its results in chunks.

For golang/go#69732

Change-Id: I3f7d50a3899f0cbc9954da89a26906f1f5850a93
Reviewed-on: https://go-review.googlesource.com/c/build/+/617160
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
This commit is contained in:
Damien Neil 2024-10-01 12:50:30 -07:00
Родитель 785db46b4b
Коммит d74ce56e94
5 изменённых файлов: 213 добавлений и 98 удалений

Просмотреть файл

@ -1925,7 +1925,7 @@ var file_internal_gomote_protos_gomote_proto_rawDesc = []byte{
0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x64,
0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x22, 0x19, 0x0a, 0x17, 0x57, 0x72, 0x69, 0x74,
0x65, 0x54, 0x47, 0x5a, 0x46, 0x72, 0x6f, 0x6d, 0x55, 0x52, 0x4c, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x32, 0xd2, 0x09, 0x0a, 0x0d, 0x47, 0x6f, 0x6d, 0x6f, 0x74, 0x65, 0x53, 0x65,
0x6e, 0x73, 0x65, 0x32, 0xad, 0x0a, 0x0a, 0x0d, 0x47, 0x6f, 0x6d, 0x6f, 0x74, 0x65, 0x53, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4b, 0x0a, 0x0c, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74,
0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x41,
0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,
@ -1962,50 +1962,56 @@ var file_internal_gomote_protos_gomote_proto_rawDesc = []byte{
0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x69, 0x72, 0x65,
0x63, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12,
0x4e, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73,
0x12, 0x1c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6e,
0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6e, 0x73, 0x74,
0x61, 0x6e, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12,
0x63, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x77, 0x61, 0x72, 0x6d, 0x69, 0x6e, 0x67, 0x42,
0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x73, 0x12, 0x23, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73,
0x59, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79,
0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x69, 0x6e, 0x67, 0x12, 0x1c, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73,
0x2e, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x4e, 0x0a, 0x0d, 0x4c, 0x69,
0x73, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x1c, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63,
0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x63, 0x0a, 0x14, 0x4c, 0x69,
0x73, 0x74, 0x53, 0x77, 0x61, 0x72, 0x6d, 0x69, 0x6e, 0x67, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x65,
0x72, 0x73, 0x12, 0x23, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74,
0x53, 0x77, 0x61, 0x72, 0x6d, 0x69, 0x6e, 0x67, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x73,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73,
0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x77, 0x61, 0x72, 0x6d, 0x69, 0x6e, 0x67, 0x42, 0x75, 0x69,
0x6c, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x77, 0x61, 0x72, 0x6d, 0x69,
0x6e, 0x67, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x22, 0x00, 0x12, 0x4b, 0x0a, 0x0c, 0x52, 0x65, 0x61, 0x64, 0x54, 0x47, 0x5a, 0x54,
0x6f, 0x55, 0x52, 0x4c, 0x12, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x52, 0x65,
0x61, 0x64, 0x54, 0x47, 0x5a, 0x54, 0x6f, 0x55, 0x52, 0x4c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x1c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x54,
0x47, 0x5a, 0x54, 0x6f, 0x55, 0x52, 0x4c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
0x00, 0x12, 0x48, 0x0a, 0x0b, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x73,
0x12, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65,
0x46, 0x69, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x46, 0x69, 0x6c, 0x65,
0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x45, 0x0a, 0x0a, 0x53,
0x69, 0x67, 0x6e, 0x53, 0x53, 0x48, 0x4b, 0x65, 0x79, 0x12, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x73, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x53, 0x53, 0x48, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x53, 0x69,
0x67, 0x6e, 0x53, 0x53, 0x48, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x22, 0x00, 0x12, 0x45, 0x0a, 0x0a, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65,
0x12, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64,
0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x70, 0x72,
0x6c, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12,
0x4b, 0x0a, 0x0c, 0x52, 0x65, 0x61, 0x64, 0x54, 0x47, 0x5a, 0x54, 0x6f, 0x55, 0x52, 0x4c, 0x12,
0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x54, 0x47, 0x5a,
0x54, 0x6f, 0x55, 0x52, 0x4c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x54, 0x47, 0x5a, 0x54, 0x6f, 0x55,
0x52, 0x4c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x48, 0x0a, 0x0b,
0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x1a, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x73,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73,
0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x45, 0x0a, 0x0a, 0x53, 0x69, 0x67, 0x6e, 0x53, 0x53,
0x48, 0x4b, 0x65, 0x79, 0x12, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x53, 0x69,
0x67, 0x6e, 0x53, 0x53, 0x48, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x53, 0x53, 0x48,
0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x45, 0x0a,
0x0a, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x19, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x57, 0x0a, 0x10, 0x57, 0x72, 0x69,
0x74, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x55, 0x52, 0x4c, 0x12, 0x1f, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x57, 0x72, 0x69, 0x74, 0x65, 0x46, 0x69, 0x6c, 0x65,
0x46, 0x72, 0x6f, 0x6d, 0x55, 0x52, 0x4c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x57, 0x72, 0x69, 0x74, 0x65, 0x46, 0x69, 0x6c,
0x65, 0x46, 0x72, 0x6f, 0x6d, 0x55, 0x52, 0x4c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x22, 0x00, 0x12, 0x54, 0x0a, 0x0f, 0x57, 0x72, 0x69, 0x74, 0x65, 0x54, 0x47, 0x5a, 0x46, 0x72,
0x6f, 0x6d, 0x55, 0x52, 0x4c, 0x12, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x57,
0x72, 0x69, 0x74, 0x65, 0x54, 0x47, 0x5a, 0x46, 0x72, 0x6f, 0x6d, 0x55, 0x52, 0x4c, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x57,
0x72, 0x69, 0x74, 0x65, 0x54, 0x47, 0x5a, 0x46, 0x72, 0x6f, 0x6d, 0x55, 0x52, 0x4c, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x2b, 0x5a, 0x29, 0x67, 0x6f, 0x6c, 0x61,
0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x78, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x69,
0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x6f, 0x6d, 0x6f, 0x74, 0x65, 0x2f, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e,
0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x22, 0x00, 0x12, 0x57, 0x0a, 0x10, 0x57, 0x72, 0x69, 0x74, 0x65, 0x46, 0x69, 0x6c,
0x65, 0x46, 0x72, 0x6f, 0x6d, 0x55, 0x52, 0x4c, 0x12, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x73, 0x2e, 0x57, 0x72, 0x69, 0x74, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x55,
0x52, 0x4c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x73, 0x2e, 0x57, 0x72, 0x69, 0x74, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x46, 0x72, 0x6f, 0x6d,
0x55, 0x52, 0x4c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x54, 0x0a,
0x0f, 0x57, 0x72, 0x69, 0x74, 0x65, 0x54, 0x47, 0x5a, 0x46, 0x72, 0x6f, 0x6d, 0x55, 0x52, 0x4c,
0x12, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x57, 0x72, 0x69, 0x74, 0x65, 0x54,
0x47, 0x5a, 0x46, 0x72, 0x6f, 0x6d, 0x55, 0x52, 0x4c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x57, 0x72, 0x69, 0x74, 0x65, 0x54,
0x47, 0x5a, 0x46, 0x72, 0x6f, 0x6d, 0x55, 0x52, 0x4c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x22, 0x00, 0x42, 0x2b, 0x5a, 0x29, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72,
0x67, 0x2f, 0x78, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e,
0x61, 0x6c, 0x2f, 0x67, 0x6f, 0x6d, 0x6f, 0x74, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -2069,31 +2075,33 @@ var file_internal_gomote_protos_gomote_proto_depIdxs = []int32{
9, // 8: protos.GomoteService.ExecuteCommand:input_type -> protos.ExecuteCommandRequest
12, // 9: protos.GomoteService.InstanceAlive:input_type -> protos.InstanceAliveRequest
14, // 10: protos.GomoteService.ListDirectory:input_type -> protos.ListDirectoryRequest
16, // 11: protos.GomoteService.ListInstances:input_type -> protos.ListInstancesRequest
18, // 12: protos.GomoteService.ListSwarmingBuilders:input_type -> protos.ListSwarmingBuildersRequest
20, // 13: protos.GomoteService.ReadTGZToURL:input_type -> protos.ReadTGZToURLRequest
22, // 14: protos.GomoteService.RemoveFiles:input_type -> protos.RemoveFilesRequest
24, // 15: protos.GomoteService.SignSSHKey:input_type -> protos.SignSSHKeyRequest
26, // 16: protos.GomoteService.UploadFile:input_type -> protos.UploadFileRequest
28, // 17: protos.GomoteService.WriteFileFromURL:input_type -> protos.WriteFileFromURLRequest
30, // 18: protos.GomoteService.WriteTGZFromURL:input_type -> protos.WriteTGZFromURLRequest
2, // 19: protos.GomoteService.Authenticate:output_type -> protos.AuthenticateResponse
4, // 20: protos.GomoteService.AddBootstrap:output_type -> protos.AddBootstrapResponse
6, // 21: protos.GomoteService.CreateInstance:output_type -> protos.CreateInstanceResponse
8, // 22: protos.GomoteService.DestroyInstance:output_type -> protos.DestroyInstanceResponse
10, // 23: protos.GomoteService.ExecuteCommand:output_type -> protos.ExecuteCommandResponse
13, // 24: protos.GomoteService.InstanceAlive:output_type -> protos.InstanceAliveResponse
15, // 25: protos.GomoteService.ListDirectory:output_type -> protos.ListDirectoryResponse
17, // 26: protos.GomoteService.ListInstances:output_type -> protos.ListInstancesResponse
19, // 27: protos.GomoteService.ListSwarmingBuilders:output_type -> protos.ListSwarmingBuildersResponse
21, // 28: protos.GomoteService.ReadTGZToURL:output_type -> protos.ReadTGZToURLResponse
23, // 29: protos.GomoteService.RemoveFiles:output_type -> protos.RemoveFilesResponse
25, // 30: protos.GomoteService.SignSSHKey:output_type -> protos.SignSSHKeyResponse
27, // 31: protos.GomoteService.UploadFile:output_type -> protos.UploadFileResponse
29, // 32: protos.GomoteService.WriteFileFromURL:output_type -> protos.WriteFileFromURLResponse
31, // 33: protos.GomoteService.WriteTGZFromURL:output_type -> protos.WriteTGZFromURLResponse
19, // [19:34] is the sub-list for method output_type
4, // [4:19] is the sub-list for method input_type
14, // 11: protos.GomoteService.ListDirectoryStreaming:input_type -> protos.ListDirectoryRequest
16, // 12: protos.GomoteService.ListInstances:input_type -> protos.ListInstancesRequest
18, // 13: protos.GomoteService.ListSwarmingBuilders:input_type -> protos.ListSwarmingBuildersRequest
20, // 14: protos.GomoteService.ReadTGZToURL:input_type -> protos.ReadTGZToURLRequest
22, // 15: protos.GomoteService.RemoveFiles:input_type -> protos.RemoveFilesRequest
24, // 16: protos.GomoteService.SignSSHKey:input_type -> protos.SignSSHKeyRequest
26, // 17: protos.GomoteService.UploadFile:input_type -> protos.UploadFileRequest
28, // 18: protos.GomoteService.WriteFileFromURL:input_type -> protos.WriteFileFromURLRequest
30, // 19: protos.GomoteService.WriteTGZFromURL:input_type -> protos.WriteTGZFromURLRequest
2, // 20: protos.GomoteService.Authenticate:output_type -> protos.AuthenticateResponse
4, // 21: protos.GomoteService.AddBootstrap:output_type -> protos.AddBootstrapResponse
6, // 22: protos.GomoteService.CreateInstance:output_type -> protos.CreateInstanceResponse
8, // 23: protos.GomoteService.DestroyInstance:output_type -> protos.DestroyInstanceResponse
10, // 24: protos.GomoteService.ExecuteCommand:output_type -> protos.ExecuteCommandResponse
13, // 25: protos.GomoteService.InstanceAlive:output_type -> protos.InstanceAliveResponse
15, // 26: protos.GomoteService.ListDirectory:output_type -> protos.ListDirectoryResponse
15, // 27: protos.GomoteService.ListDirectoryStreaming:output_type -> protos.ListDirectoryResponse
17, // 28: protos.GomoteService.ListInstances:output_type -> protos.ListInstancesResponse
19, // 29: protos.GomoteService.ListSwarmingBuilders:output_type -> protos.ListSwarmingBuildersResponse
21, // 30: protos.GomoteService.ReadTGZToURL:output_type -> protos.ReadTGZToURLResponse
23, // 31: protos.GomoteService.RemoveFiles:output_type -> protos.RemoveFilesResponse
25, // 32: protos.GomoteService.SignSSHKey:output_type -> protos.SignSSHKeyResponse
27, // 33: protos.GomoteService.UploadFile:output_type -> protos.UploadFileResponse
29, // 34: protos.GomoteService.WriteFileFromURL:output_type -> protos.WriteFileFromURLResponse
31, // 35: protos.GomoteService.WriteTGZFromURL:output_type -> protos.WriteTGZFromURLResponse
20, // [20:36] is the sub-list for method output_type
4, // [4:20] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name

Просмотреть файл

@ -24,6 +24,8 @@ service GomoteService {
rpc InstanceAlive (InstanceAliveRequest) returns (InstanceAliveResponse) {}
// ListDirectory lists the contents of a directory on an gomote instance.
rpc ListDirectory (ListDirectoryRequest) returns (ListDirectoryResponse) {}
// ListDirectoryStreaming lists the contents of a directory on an gomote instance.
rpc ListDirectoryStreaming (ListDirectoryRequest) returns (stream ListDirectoryResponse) {}
// ListInstances lists all of the live gomote instances owned by the caller.
rpc ListInstances (ListInstancesRequest) returns (ListInstancesResponse) {}
// ListSwarmingBuilders lists all of the swarming builders for the project.

Просмотреть файл

@ -23,21 +23,22 @@ import (
const _ = grpc.SupportPackageIsVersion9
const (
GomoteService_Authenticate_FullMethodName = "/protos.GomoteService/Authenticate"
GomoteService_AddBootstrap_FullMethodName = "/protos.GomoteService/AddBootstrap"
GomoteService_CreateInstance_FullMethodName = "/protos.GomoteService/CreateInstance"
GomoteService_DestroyInstance_FullMethodName = "/protos.GomoteService/DestroyInstance"
GomoteService_ExecuteCommand_FullMethodName = "/protos.GomoteService/ExecuteCommand"
GomoteService_InstanceAlive_FullMethodName = "/protos.GomoteService/InstanceAlive"
GomoteService_ListDirectory_FullMethodName = "/protos.GomoteService/ListDirectory"
GomoteService_ListInstances_FullMethodName = "/protos.GomoteService/ListInstances"
GomoteService_ListSwarmingBuilders_FullMethodName = "/protos.GomoteService/ListSwarmingBuilders"
GomoteService_ReadTGZToURL_FullMethodName = "/protos.GomoteService/ReadTGZToURL"
GomoteService_RemoveFiles_FullMethodName = "/protos.GomoteService/RemoveFiles"
GomoteService_SignSSHKey_FullMethodName = "/protos.GomoteService/SignSSHKey"
GomoteService_UploadFile_FullMethodName = "/protos.GomoteService/UploadFile"
GomoteService_WriteFileFromURL_FullMethodName = "/protos.GomoteService/WriteFileFromURL"
GomoteService_WriteTGZFromURL_FullMethodName = "/protos.GomoteService/WriteTGZFromURL"
GomoteService_Authenticate_FullMethodName = "/protos.GomoteService/Authenticate"
GomoteService_AddBootstrap_FullMethodName = "/protos.GomoteService/AddBootstrap"
GomoteService_CreateInstance_FullMethodName = "/protos.GomoteService/CreateInstance"
GomoteService_DestroyInstance_FullMethodName = "/protos.GomoteService/DestroyInstance"
GomoteService_ExecuteCommand_FullMethodName = "/protos.GomoteService/ExecuteCommand"
GomoteService_InstanceAlive_FullMethodName = "/protos.GomoteService/InstanceAlive"
GomoteService_ListDirectory_FullMethodName = "/protos.GomoteService/ListDirectory"
GomoteService_ListDirectoryStreaming_FullMethodName = "/protos.GomoteService/ListDirectoryStreaming"
GomoteService_ListInstances_FullMethodName = "/protos.GomoteService/ListInstances"
GomoteService_ListSwarmingBuilders_FullMethodName = "/protos.GomoteService/ListSwarmingBuilders"
GomoteService_ReadTGZToURL_FullMethodName = "/protos.GomoteService/ReadTGZToURL"
GomoteService_RemoveFiles_FullMethodName = "/protos.GomoteService/RemoveFiles"
GomoteService_SignSSHKey_FullMethodName = "/protos.GomoteService/SignSSHKey"
GomoteService_UploadFile_FullMethodName = "/protos.GomoteService/UploadFile"
GomoteService_WriteFileFromURL_FullMethodName = "/protos.GomoteService/WriteFileFromURL"
GomoteService_WriteTGZFromURL_FullMethodName = "/protos.GomoteService/WriteTGZFromURL"
)
// GomoteServiceClient is the client API for GomoteService service.
@ -60,6 +61,8 @@ type GomoteServiceClient interface {
InstanceAlive(ctx context.Context, in *InstanceAliveRequest, opts ...grpc.CallOption) (*InstanceAliveResponse, error)
// ListDirectory lists the contents of a directory on an gomote instance.
ListDirectory(ctx context.Context, in *ListDirectoryRequest, opts ...grpc.CallOption) (*ListDirectoryResponse, error)
// ListDirectoryStreaming lists the contents of a directory on an gomote instance.
ListDirectoryStreaming(ctx context.Context, in *ListDirectoryRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[ListDirectoryResponse], error)
// ListInstances lists all of the live gomote instances owned by the caller.
ListInstances(ctx context.Context, in *ListInstancesRequest, opts ...grpc.CallOption) (*ListInstancesResponse, error)
// ListSwarmingBuilders lists all of the swarming builders for the project.
@ -176,6 +179,25 @@ func (c *gomoteServiceClient) ListDirectory(ctx context.Context, in *ListDirecto
return out, nil
}
func (c *gomoteServiceClient) ListDirectoryStreaming(ctx context.Context, in *ListDirectoryRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[ListDirectoryResponse], error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
stream, err := c.cc.NewStream(ctx, &GomoteService_ServiceDesc.Streams[2], GomoteService_ListDirectoryStreaming_FullMethodName, cOpts...)
if err != nil {
return nil, err
}
x := &grpc.GenericClientStream[ListDirectoryRequest, ListDirectoryResponse]{ClientStream: stream}
if err := x.ClientStream.SendMsg(in); err != nil {
return nil, err
}
if err := x.ClientStream.CloseSend(); err != nil {
return nil, err
}
return x, nil
}
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type GomoteService_ListDirectoryStreamingClient = grpc.ServerStreamingClient[ListDirectoryResponse]
func (c *gomoteServiceClient) ListInstances(ctx context.Context, in *ListInstancesRequest, opts ...grpc.CallOption) (*ListInstancesResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListInstancesResponse)
@ -276,6 +298,8 @@ type GomoteServiceServer interface {
InstanceAlive(context.Context, *InstanceAliveRequest) (*InstanceAliveResponse, error)
// ListDirectory lists the contents of a directory on an gomote instance.
ListDirectory(context.Context, *ListDirectoryRequest) (*ListDirectoryResponse, error)
// ListDirectoryStreaming lists the contents of a directory on an gomote instance.
ListDirectoryStreaming(*ListDirectoryRequest, grpc.ServerStreamingServer[ListDirectoryResponse]) error
// ListInstances lists all of the live gomote instances owned by the caller.
ListInstances(context.Context, *ListInstancesRequest) (*ListInstancesResponse, error)
// ListSwarmingBuilders lists all of the swarming builders for the project.
@ -325,6 +349,9 @@ func (UnimplementedGomoteServiceServer) InstanceAlive(context.Context, *Instance
func (UnimplementedGomoteServiceServer) ListDirectory(context.Context, *ListDirectoryRequest) (*ListDirectoryResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListDirectory not implemented")
}
func (UnimplementedGomoteServiceServer) ListDirectoryStreaming(*ListDirectoryRequest, grpc.ServerStreamingServer[ListDirectoryResponse]) error {
return status.Errorf(codes.Unimplemented, "method ListDirectoryStreaming not implemented")
}
func (UnimplementedGomoteServiceServer) ListInstances(context.Context, *ListInstancesRequest) (*ListInstancesResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListInstances not implemented")
}
@ -482,6 +509,17 @@ func _GomoteService_ListDirectory_Handler(srv interface{}, ctx context.Context,
return interceptor(ctx, in, info, handler)
}
func _GomoteService_ListDirectoryStreaming_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(ListDirectoryRequest)
if err := stream.RecvMsg(m); err != nil {
return err
}
return srv.(GomoteServiceServer).ListDirectoryStreaming(m, &grpc.GenericServerStream[ListDirectoryRequest, ListDirectoryResponse]{ServerStream: stream})
}
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type GomoteService_ListDirectoryStreamingServer = grpc.ServerStreamingServer[ListDirectoryResponse]
func _GomoteService_ListInstances_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListInstancesRequest)
if err := dec(in); err != nil {
@ -697,6 +735,11 @@ var GomoteService_ServiceDesc = grpc.ServiceDesc{
Handler: _GomoteService_ExecuteCommand_Handler,
ServerStreams: true,
},
{
StreamName: "ListDirectoryStreaming",
Handler: _GomoteService_ListDirectoryStreaming_Handler,
ServerStreams: true,
},
},
Metadata: "internal/gomote/protos/gomote.proto",
}

Просмотреть файл

@ -336,6 +336,35 @@ func (ss *SwarmingServer) InstanceAlive(ctx context.Context, req *protos.Instanc
// ListDirectory lists the contents of the directory on a gomote instance.
func (ss *SwarmingServer) ListDirectory(ctx context.Context, req *protos.ListDirectoryRequest) (*protos.ListDirectoryResponse, error) {
entries, err := ss.listDirectory(ctx, req)
if err != nil {
return nil, err
}
return &protos.ListDirectoryResponse{
Entries: entries,
}, nil
}
// ListDirectoryStreaming lists the contents of the directory on a gomote instance.
func (ss *SwarmingServer) ListDirectoryStreaming(req *protos.ListDirectoryRequest, stream grpc.ServerStreamingServer[protos.ListDirectoryResponse]) error {
entries, err := ss.listDirectory(stream.Context(), req)
if err != nil {
return err
}
// This could use slices.Chunk, once our go.mod is on go1.23 or higher.
const chunkSize = 100
for i := 0; i < len(entries); i += chunkSize {
end := min(chunkSize, len(entries[i:]))
if err := stream.Send(&protos.ListDirectoryResponse{
Entries: entries[i:end],
}); err != nil {
return err
}
}
return nil
}
func (ss *SwarmingServer) listDirectory(ctx context.Context, req *protos.ListDirectoryRequest) ([]string, error) {
creds, err := access.IAPFromContext(ctx)
if err != nil {
return nil, status.Errorf(codes.Unauthenticated, "request does not contain the required authentication")
@ -359,9 +388,7 @@ func (ss *SwarmingServer) ListDirectory(ctx context.Context, req *protos.ListDir
}); err != nil {
return nil, status.Errorf(codes.Unimplemented, "method ListDirectory not implemented")
}
return &protos.ListDirectoryResponse{
Entries: entries,
}, nil
return entries, nil
}
const (

Просмотреть файл

@ -550,19 +550,55 @@ func TestSwarmingInstanceAliveError(t *testing.T) {
}
}
// listDirectory calls either ListDirectoryStreaming or ListDirectory.
func listDirectory(ctx context.Context, streaming bool, client protos.GomoteServiceClient, req *protos.ListDirectoryRequest) ([]*protos.ListDirectoryResponse, error) {
if streaming {
stream, err := client.ListDirectoryStreaming(ctx, req)
if err != nil {
return nil, err
}
var resps []*protos.ListDirectoryResponse
for {
resp, err := stream.Recv()
if err == io.EOF {
break
}
if err != nil {
return nil, err
}
resps = append(resps, resp)
}
return resps, nil
} else {
resp, err := client.ListDirectory(ctx, req)
if err != nil {
return nil, err
}
return []*protos.ListDirectoryResponse{resp}, nil
}
}
func TestSwarmingListDirectory(t *testing.T) {
t.Run("single", func(t *testing.T) { testSwarmingListDirectory(t, false) })
t.Run("streaming", func(t *testing.T) { testSwarmingListDirectory(t, true) })
}
func testSwarmingListDirectory(t *testing.T, streaming bool) {
ctx := access.FakeContextWithOutgoingIAPAuth(context.Background(), fakeIAP())
client := setupGomoteSwarmingTest(t, context.Background(), mockSwarmClientSimple())
gomoteID := mustCreateSwarmingInstance(t, client, fakeIAP())
if _, err := client.ListDirectory(ctx, &protos.ListDirectoryRequest{
if _, err := listDirectory(ctx, streaming, client, &protos.ListDirectoryRequest{
GomoteId: gomoteID,
Directory: "/foo",
}); err != nil {
t.Fatalf("client.RemoveFiles(ctx, req) = response, %s; want no error", err)
t.Fatalf("client.ListDirectory(ctx, req) = response, %s; want no error", err)
}
}
func TestSwarmingListDirectoryError(t *testing.T) {
t.Run("single", func(t *testing.T) { testSwarmingListDirectoryError(t, false) })
t.Run("streaming", func(t *testing.T) { testSwarmingListDirectoryError(t, true) })
}
func testSwarmingListDirectoryError(t *testing.T, streaming bool) {
// This test will create a gomote instance and attempt to call ListDirectory.
// If overrideID is set to true, the test will use a different gomoteID than
// the one created for the test.
@ -624,12 +660,12 @@ func TestSwarmingListDirectoryError(t *testing.T) {
SkipFiles: []string{},
Digest: false,
}
got, err := client.ListDirectory(tc.ctx, req)
got, err := listDirectory(tc.ctx, streaming, client, req)
if err != nil && status.Code(err) != tc.wantCode {
t.Fatalf("unexpected error: %s; want %s", err, tc.wantCode)
}
if err == nil {
t.Fatalf("client.RemoveFiles(ctx, %v) = %v, nil; want error", req, got)
t.Fatalf("client.ListDirectory(ctx, %v) = %v, nil; want error", req, got)
}
})
}
@ -1126,14 +1162,13 @@ func TestStartNewSwarmingTask(t *testing.T) {
}, nil
}
ss := &SwarmingServer{
UnimplementedGomoteServiceServer: protos.UnimplementedGomoteServiceServer{},
bucket: nil,
buildlets: &remote.SessionPool{},
gceBucketName: "",
sshCertificateAuthority: nil,
rendezvous: rdv,
swarmingClient: msc,
buildersClient: &FakeBuildersClient{},
bucket: nil,
buildlets: &remote.SessionPool{},
gceBucketName: "",
sshCertificateAuthority: nil,
rendezvous: rdv,
swarmingClient: msc,
buildersClient: &FakeBuildersClient{},
}
id := "task-123"
errCh := make(chan error, 2)