Skip to content

Commit fb3ee9e

Browse files
Integrate bb-browser web interface into bb-portal
Co-authored-by: Oscar Falk <oscar@meroton.com>
1 parent 0af4a53 commit fb3ee9e

File tree

82 files changed

+8746
-108
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+8746
-108
lines changed

BUILD.bazel

+2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ load("@gazelle//:def.bzl", "gazelle")
99
# gazelle:resolve proto go build/bazel/remote/execution/v2/remote_execution.proto @bazel_remote_apis//build/bazel/remote/execution/v2:remote_execution_go_proto
1010
# gazelle:resolve proto go google/rpc/status.proto @org_golang_google_genproto_googleapis_rpc//status
1111
# gazelle:resolve proto go pkg/proto/configuration/auth/auth.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/auth
12+
# gazelle:resolve proto go pkg/proto/configuration/blobstore/blobstore.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/blobstore
1213
# gazelle:resolve proto go pkg/proto/configuration/global/global.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/global
1314
# gazelle:resolve proto go pkg/proto/configuration/grpc/grpc.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/grpc
1415
# gazelle:resolve proto go pkg/proto/configuration/http/http.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/http
1516
# gazelle:resolve proto build/bazel/remote/execution/v2/remote_execution.proto @bazel_remote_apis//build/bazel/remote/execution/v2:remote_execution_proto
1617
# gazelle:resolve proto google/rpc/status.proto @googleapis//google/rpc:status_proto
1718
# gazelle:resolve proto pkg/proto/configuration/auth/auth.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/auth:auth_proto
19+
# gazelle:resolve proto pkg/proto/configuration/blobstore/blobstore.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/blobstore:blobstore_proto
1820
# gazelle:resolve proto pkg/proto/configuration/global/global.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/global:global_proto
1921
# gazelle:resolve proto pkg/proto/configuration/grpc/grpc.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/grpc:grpc_proto
2022
# gazelle:resolve proto pkg/proto/configuration/http/http.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/http:http_proto

MODULE.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ use_repo(
101101
"io_entgo_ent",
102102
"org_golang_google_api",
103103
"org_golang_google_genproto",
104+
"org_golang_google_genproto_googleapis_bytestream",
104105
"org_golang_google_grpc",
105106
"org_golang_google_protobuf",
106107
"org_golang_x_lint",

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,17 @@ Once you have BEP files produced by Bazel, you can upload them via the applicati
106106

107107
BB-portal can show the same information as the web interface from BB-scheduler. To do this, you need to configure the `buildQueueStateProxy` in the portal configuration file. The interface can be found under the `Remote Execution Scheduler` tab in the menu.
108108

109+
### BB-browser
110+
111+
BB-portal can show the same information as BB-browser. Everything it can show is visible under the tab `Browser`. To make the browser functionality work, you need to configure
112+
113+
- `actionCacheProxy`
114+
- `contentAddressableStorageProxy`
115+
- (optional) `initialSizeClassCacheProxy`
116+
- (optional) `fileSystemAccessCacheProxy`
117+
118+
in the portal configuration file. Despite having the name "browser", it is not possible to browse through the content. Instead other parts of Buildbarn will generate links to the browser. To open the content in bb-portal, the the prefix for the links should be `http://url-to-bb-portal/browser/`. After the `/browser/` prefix, the rest of the URL is compatible with urls for bb-browser.
119+
109120
## Using GraphiQL To Explore the GraphQL API
110121

111122
The GraphiQL explorer is available via http://localhost:8081/graphiql.

cmd/bb_portal/BUILD.bazel

+11
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,28 @@ go_library(
1414
"//ent/gen/ent/migrate",
1515
"//internal/api",
1616
"//internal/api/grpc/bes",
17+
"//internal/api/grpcweb/actioncacheproxy",
1718
"//internal/api/grpcweb/buildqueuestateproxy",
19+
"//internal/api/grpcweb/casproxy",
20+
"//internal/api/grpcweb/fsacproxy",
21+
"//internal/api/grpcweb/isccproxy",
22+
"//internal/api/servefiles:servefiles_lib",
1823
"//internal/graphql",
1924
"//pkg/processing",
2025
"//pkg/proto/configuration/bb_portal",
26+
"@bazel_remote_apis//build/bazel/remote/execution/v2:remote_execution_go_proto",
2127
"@com_github_99designs_gqlgen//graphql/handler",
2228
"@com_github_99designs_gqlgen//graphql/playground",
2329
"@com_github_buildbarn_bb_remote_execution//pkg/proto/buildqueuestate",
2430
"@com_github_buildbarn_bb_storage//pkg/auth",
31+
"@com_github_buildbarn_bb_storage//pkg/blobstore",
32+
"@com_github_buildbarn_bb_storage//pkg/blobstore/configuration",
2533
"@com_github_buildbarn_bb_storage//pkg/global",
2634
"@com_github_buildbarn_bb_storage//pkg/grpc",
2735
"@com_github_buildbarn_bb_storage//pkg/http",
2836
"@com_github_buildbarn_bb_storage//pkg/program",
37+
"@com_github_buildbarn_bb_storage//pkg/proto/fsac",
38+
"@com_github_buildbarn_bb_storage//pkg/proto/iscc",
2939
"@com_github_buildbarn_bb_storage//pkg/util",
3040
"@com_github_fsnotify_fsnotify//:fsnotify",
3141
"@com_github_gorilla_mux//:mux",
@@ -36,6 +46,7 @@ go_library(
3646
"@io_entgo_ent//dialect",
3747
"@io_entgo_ent//dialect/sql",
3848
"@org_golang_google_genproto//googleapis/devtools/build/v1:build",
49+
"@org_golang_google_genproto_googleapis_bytestream//:bytestream",
3950
"@org_golang_google_grpc//:grpc",
4051
],
4152
)

cmd/bb_portal/grpcweb_proxy_server.go

+52
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,22 @@ import (
44
"log"
55
"slices"
66

7+
remoteexecution "github.com/bazelbuild/remote-apis/build/bazel/remote/execution/v2"
8+
"github.com/buildbarn/bb-portal/internal/api/grpcweb/actioncacheproxy"
79
"github.com/buildbarn/bb-portal/internal/api/grpcweb/buildqueuestateproxy"
10+
"github.com/buildbarn/bb-portal/internal/api/grpcweb/casproxy"
11+
"github.com/buildbarn/bb-portal/internal/api/grpcweb/fsacproxy"
12+
"github.com/buildbarn/bb-portal/internal/api/grpcweb/isccproxy"
813
"github.com/buildbarn/bb-portal/pkg/proto/configuration/bb_portal"
914
"github.com/buildbarn/bb-remote-execution/pkg/proto/buildqueuestate"
1015
"github.com/buildbarn/bb-storage/pkg/auth"
1116
bb_grpc "github.com/buildbarn/bb-storage/pkg/grpc"
1217
bb_http "github.com/buildbarn/bb-storage/pkg/http"
1318
"github.com/buildbarn/bb-storage/pkg/program"
19+
"github.com/buildbarn/bb-storage/pkg/proto/fsac"
20+
"github.com/buildbarn/bb-storage/pkg/proto/iscc"
1421
"github.com/improbable-eng/grpc-web/go/grpcweb"
22+
"google.golang.org/genproto/googleapis/bytestream"
1523
go_grpc "google.golang.org/grpc"
1624
)
1725

@@ -67,4 +75,48 @@ func StartGrpcWebProxyServer(
6775
buildqueuestate.RegisterBuildQueueStateServer(grpcServer, buildqueuestateproxy.NewBuildQueueStateServerImpl(c, instanceNameAuthorizer))
6876
},
6977
)
78+
79+
registerAndStartServer(
80+
configuration.ActionCacheProxy,
81+
siblingsGroup,
82+
grpcClientFactory,
83+
"ActionCacheProxy",
84+
func(grpcServer *go_grpc.Server, grpcClient go_grpc.ClientConnInterface) {
85+
c := remoteexecution.NewActionCacheClient(grpcClient)
86+
remoteexecution.RegisterActionCacheServer(grpcServer, actioncacheproxy.NewAcctionCacheServerImpl(c, instanceNameAuthorizer))
87+
},
88+
)
89+
90+
registerAndStartServer(
91+
configuration.ContentAddressableStorageProxy,
92+
siblingsGroup,
93+
grpcClientFactory,
94+
"ContentAddressableStorageProxy",
95+
func(grpcServer *go_grpc.Server, grpcClient go_grpc.ClientConnInterface) {
96+
c := bytestream.NewByteStreamClient(grpcClient)
97+
bytestream.RegisterByteStreamServer(grpcServer, casproxy.NewCasServerImpl(c, instanceNameAuthorizer))
98+
},
99+
)
100+
101+
registerAndStartServer(
102+
configuration.InitialSizeClassCacheProxy,
103+
siblingsGroup,
104+
grpcClientFactory,
105+
"InitialSizeClassCacheProxy",
106+
func(grpcServer *go_grpc.Server, grpcClient go_grpc.ClientConnInterface) {
107+
c := iscc.NewInitialSizeClassCacheClient(grpcClient)
108+
iscc.RegisterInitialSizeClassCacheServer(grpcServer, isccproxy.NewIsccServerImpl(c, instanceNameAuthorizer))
109+
},
110+
)
111+
112+
registerAndStartServer(
113+
configuration.FileSystemAccessCacheProxy,
114+
siblingsGroup,
115+
grpcClientFactory,
116+
"FileSystemAccessCacheProxy",
117+
func(grpcServer *go_grpc.Server, grpcClient go_grpc.ClientConnInterface) {
118+
c := fsac.NewFileSystemAccessCacheClient(grpcClient)
119+
fsac.RegisterFileSystemAccessCacheServer(grpcServer, fsacproxy.NewFsacServerImpl(c, instanceNameAuthorizer))
120+
},
121+
)
70122
}

cmd/bb_portal/main.go

+22-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@ import (
3030
"github.com/buildbarn/bb-portal/ent/gen/ent/migrate"
3131
"github.com/buildbarn/bb-portal/internal/api"
3232
"github.com/buildbarn/bb-portal/internal/api/grpc/bes"
33+
"github.com/buildbarn/bb-portal/internal/api/servefiles"
3334
"github.com/buildbarn/bb-portal/internal/graphql"
3435
"github.com/buildbarn/bb-portal/pkg/processing"
3536
"github.com/buildbarn/bb-portal/pkg/proto/configuration/bb_portal"
3637
"github.com/buildbarn/bb-storage/pkg/auth"
38+
"github.com/buildbarn/bb-storage/pkg/blobstore"
39+
blobstore_configuration "github.com/buildbarn/bb-storage/pkg/blobstore/configuration"
3740
"github.com/buildbarn/bb-storage/pkg/global"
3841
bb_grpc "github.com/buildbarn/bb-storage/pkg/grpc"
3942
bb_http "github.com/buildbarn/bb-storage/pkg/http"
@@ -124,8 +127,22 @@ func main() {
124127
log.Fatalf("Failed to create InstanceNameAuthorizer: %v", err)
125128
}
126129

130+
// Storage access.
131+
contentAddressableStorage, _, err := blobstore_configuration.NewCASAndACBlobAccessFromConfiguration(
132+
dependenciesGroup,
133+
configuration.Blobstore,
134+
grpcClientFactory,
135+
int(configuration.MaximumMessageSizeBytes))
136+
if err != nil {
137+
return err
138+
}
139+
140+
authorizedCas := blobstore.NewAuthorizingBlobAccess(contentAddressableStorage, instanceNameAuthorizer, nil, nil)
141+
142+
serveFileService := servefiles.NewFileServerService(authorizedCas, int(configuration.MaximumMessageSizeBytes))
143+
127144
router := mux.NewRouter()
128-
newPortalService(blobArchiver, dbClient, router)
145+
newPortalService(blobArchiver, dbClient, serveFileService, router)
129146
bb_http.NewServersFromConfigurationAndServe(
130147
configuration.HttpServers,
131148
bb_http.NewMetricsHandler(router, "PortalUI"),
@@ -206,13 +223,16 @@ func fatal(msg string, args ...any) {
206223
os.Exit(1)
207224
}
208225

209-
func newPortalService(archiver processing.BlobMultiArchiver, dbClient *ent.Client, router *mux.Router) {
226+
func newPortalService(archiver processing.BlobMultiArchiver, dbClient *ent.Client, serveFilesService *servefiles.FileServerService, router *mux.Router) {
210227
srv := handler.NewDefaultServer(graphql.NewSchema(dbClient))
211228
srv.Use(entgql.Transactioner{TxOpener: dbClient})
212229

213230
router.PathPrefix("/graphql").Handler(srv)
214231
router.Handle("/graphiql", playground.Handler("GraphQL Playground", "/graphql"))
215232
router.Handle("/api/v1/bep/upload", api.NewBEPUploadHandler(dbClient, archiver)).Methods("POST")
233+
router.HandleFunc("/api/servefile/{instanceName:(?:.*?/)?}blobs/{digestFunction}/file/{hash}-{sizeBytes}/{name}", serveFilesService.HandleFile).Methods("GET")
234+
router.HandleFunc("/api/servefile/{instanceName:(?:.*?/)?}blobs/{digestFunction}/command/{hash}-{sizeBytes}/", serveFilesService.HandleCommand).Methods("GET")
235+
router.HandleFunc("/api/servefile/{instanceName:(?:.*?/)?}blobs/{digestFunction}/directory/{hash}-{sizeBytes}/", serveFilesService.HandleDirectory).Methods("GET")
216236
router.PathPrefix("/").Handler(frontendServer())
217237
}
218238

config/portal.jsonnet

+113-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,36 @@
44
// [bb-deployments](https://github.com/buildbarn/bb-deployments), i.e. it
55
// assumes that the following services are running:
66
// - A Buildbarn scheduler, accessible at localhost:8984
7+
// - A Buildbarn frontend, accessible at localhost:8980
78

89
{
10+
blobstore: {
11+
contentAddressableStorage: {
12+
grpc: { address: 'localhost:8980' },
13+
},
14+
actionCache: {
15+
completenessChecking: {
16+
backend: { grpc: { address: 'localhost:8980' } },
17+
maximumTotalTreeSizeBytes: 64 * 1024 * 1024,
18+
},
19+
},
20+
},
21+
maximumMessageSizeBytes: 2 * 1024 * 1024,
22+
923
httpServers: [{
1024
listenAddresses: [':8081'],
11-
authenticationPolicy: { allow: {} },
25+
authenticationPolicy: {
26+
allow: {
27+
public: {
28+
user: 'FooBar',
29+
},
30+
private: {
31+
groups: ['admin'],
32+
instances: ['fuse', 'testingQueue'],
33+
email: 'foo@example.com',
34+
},
35+
},
36+
},
1237
}],
1338
grpcServers: [{
1439
listenAddresses: [':8082'],
@@ -44,4 +69,91 @@
4469
},
4570
}],
4671
},
72+
73+
actionCacheProxy: {
74+
client: {
75+
address: 'localhost:8980',
76+
},
77+
allowedOrigins: ['http://localhost:8081'],
78+
httpServers: [{
79+
listenAddresses: [':9434'],
80+
authenticationPolicy: {
81+
allow: {
82+
public: {
83+
user: 'FooBar',
84+
},
85+
private: {
86+
groups: ['admin'],
87+
instances: ['fuse', 'testingQueue'],
88+
email: 'foo@example.com',
89+
},
90+
},
91+
},
92+
}],
93+
},
94+
95+
contentAddressableStorageProxy: {
96+
client: {
97+
address: 'localhost:8980',
98+
},
99+
allowedOrigins: ['http://localhost:8081'],
100+
httpServers: [{
101+
listenAddresses: [':9435'],
102+
authenticationPolicy: {
103+
allow: {
104+
public: {
105+
user: 'FooBar',
106+
},
107+
private: {
108+
groups: ['admin'],
109+
instances: ['fuse', 'testingQueue'],
110+
email: 'foo@example.com',
111+
},
112+
},
113+
},
114+
}],
115+
},
116+
117+
initialSizeClassCacheProxy: {
118+
client: {
119+
address: 'localhost:8980',
120+
},
121+
allowedOrigins: ['http://localhost:8081'],
122+
httpServers: [{
123+
listenAddresses: [':9436'],
124+
authenticationPolicy: {
125+
allow: {
126+
public: {
127+
user: 'FooBar',
128+
},
129+
private: {
130+
groups: ['admin'],
131+
instances: ['fuse', 'testingQueue'],
132+
email: 'foo@example.com',
133+
},
134+
},
135+
},
136+
}],
137+
},
138+
fileSystemAccessCacheProxy: {
139+
client: {
140+
address: 'localhost:8980',
141+
},
142+
allowedOrigins: ['http://localhost:8081'],
143+
httpServers: [{
144+
listenAddresses: [':9437'],
145+
authenticationPolicy: {
146+
allow: {
147+
public: {
148+
user: 'FooBar',
149+
},
150+
private: {
151+
groups: ['admin'],
152+
instances: ['fuse', 'testingQueue'],
153+
email: 'foo@example.com',
154+
},
155+
},
156+
},
157+
}],
158+
},
47159
}

frontend/.env

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
NEXT_PUBLIC_BES_BACKEND_URL=http://localhost:8081
22
NEXT_PUBLIC_BES_GRPC_BACKEND_URL=grpc://localhost:8082
33
NEXT_PUBLIC_BB_BUILDQUEUESTATE_GRPC_BACKEND_URL=http://localhost:9433
4+
NEXT_PUBLIC_BB_ACTIONCACHE_GRPC_BACKEND_URL=http://localhost:9434
5+
NEXT_PUBLIC_BB_CAS_GRPC_BACKEND_URL=http://localhost:9435
6+
NEXT_PUBLIC_BB_ISCC_GRPC_BACKEND_URL=http://localhost:9436
7+
NEXT_PUBLIC_BB_FSAC_GRPC_BACKEND_URL=http://localhost:9437
48
NEXT_PUBLIC_BROWSER_URL=https://browser.example.com
59
NEXT_PUBLIC_COMPANY_NAME="Example Co"
610
NEXT_PUBLIC_COMPANY_SLACK_CHANNEL_NAME=ExampleCoBuild

frontend/scripts/grpc-client-gen.sh

+7
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,11 @@ generate_grpc_client() {
1919
${proto_file}
2020
}
2121

22+
generate_grpc_client "${PROTO_DIR}/buildbarn/auth/auth.proto"
2223
generate_grpc_client "${PROTO_DIR}/buildbarn/buildqueuestate/buildqueuestate.proto"
24+
generate_grpc_client "${PROTO_DIR}/buildbarn/cas/cas.proto"
25+
generate_grpc_client "${PROTO_DIR}/buildbarn/resourceusage/resourceusage.proto"
26+
generate_grpc_client "${PROTO_DIR}/google/bytestream/bytestream.proto"
27+
generate_grpc_client "${PROTO_DIR}/buildbarn/iscc/iscc.proto"
28+
generate_grpc_client "${PROTO_DIR}/buildbarn/fsac/fsac.proto"
29+
generate_grpc_client "${PROTO_DIR}/buildbarn/query/query.proto"

0 commit comments

Comments
 (0)