Skip to content
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

Basic CacheProxy Server #6430

Merged
merged 4 commits into from
Apr 25, 2024
Merged

Basic CacheProxy Server #6430

merged 4 commits into from
Apr 25, 2024

Conversation

iain-macdonald
Copy link
Contributor

This PR introduces a new cache_proxy server (//enterprise/server/cmd/cache_proxy) that proxies the ActionCache, ByteStream, Capabilities, and ContentAddressableStorage services to the specified backend server. It authenticates with the backing cache by forwarding the provided API Key along. This server is currently running in dev at grpcs://proxy.buildbudd.dev, you can build against it by running something like:

bazel clean && bazel build --config=remote-dev --remote_cache=grpcs://proxy.buildbuddy.dev --remote_header=x-buildbuddy-api-key=[REDACTED] //server/util/status

Next steps are to add a local cache, better auth, and then try routing executor-to-app traffic through the proxy.

I went back and forth over whether to switch the gRPC server configuration to use the Builder pattern instead of just adding a new configuration option, but chose the latter because it's a little simpler.

Related issues: N/A

Copy link
Member

@tylerwilliams tylerwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks pretty good, just a handful of nits

if err != nil {
return err
}
stream.Send(rsp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we ignoring the error returned by stream.Send?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops, fixed

}

func (s *ByteStreamServerProxy) Write(stream bspb.ByteStream_WriteServer) error {
remote_stream, err := s.remote_cache.Write(stream.Context())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/remote_stream/remoteStream/g

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 17 to 18
local_cache interfaces.Cache
remote_cache repb.ActionCacheClient
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: camelCase var names instead of c_style

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(here, and throughout)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think i got 'em all

listen = flag.String("listen", "0.0.0.0", "The interface to listen on (default: 0.0.0.0)")
port = flag.Int("port", 8080, "The port to listen for HTTP traffic on")
sslPort = flag.Int("ssl_port", 8081, "The port to listen for HTTPS traffic on")
internalHTTPPort = flag.Int("internal_http_port", 0, "The port to listen for internal HTTP traffic")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dumb question: what is this used for? Could we remove it and the whole block where we use it below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

if err != nil {
return err
}
stream.Send(rsp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignored error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

if err != nil {
return err
}
env.SetGRPCSServer(grpcsServer)
return nil
}

func RegisterInternalGRPCServer(env *real_environment.RealEnv, regServices RegisterServices) error {
func RegisterInternalGRPCServer(env *real_environment.RealEnv, config GRPCServerConfig, regServices RegisterServices) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find these Register functions that take a closure really confusing. Not your fault obvi :) They are not very idiomatic and are hard to use.

Maybe we can find a way to remove them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#6442 (i'll rebase this on that if it gets in relatively quickly)

@iain-macdonald iain-macdonald merged commit 4702a42 into master Apr 25, 2024
18 of 19 checks passed
@iain-macdonald iain-macdonald deleted the cache_proxy_server_1 branch April 25, 2024 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants