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

Pass --remote_header's headers to grpc endpoints #10015

Conversation

AlessandroPatti
Copy link
Contributor

Extends #8245 to gRPC.

@jin jin added the team-Remote-Exec Issues and PRs for the Execution (Remote) team label Oct 14, 2019
@AlessandroPatti AlessandroPatti force-pushed the apatti/grpc/remote-headers branch from a7dde66 to 08a3cd2 Compare October 15, 2019 08:45
Copy link
Contributor

@buchgr buchgr left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Can you please add a test to ensure that this actually works and we don't regress?

Can you please explain why headers for caching and execution have different flags? I am somewhat surprised given that Bazel doesn't allow you to mix caching and execution in one invocation.

}
if (remoteOptions.remoteCacheHeaders.size() > 0) {
cacheInterceptors = new ArrayList<>(interceptors);
cacheInterceptors.add(createExtraHeadersClientInterceptor(remoteOptions.remoteCacheHeaders));
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of adding the headers in the module, consider passing the headers to the RemoteSpawnRunner. That way it's easier to write a unit test.

@AlessandroPatti
Copy link
Contributor Author

Can you please explain why headers for caching and execution have different flags? I am somewhat surprised given that Bazel doesn't allow you to mix caching and execution in one invocation.

Bazel does allow to have two different endpoints for cache and executor doesn't it? The idea there was that if both --remote_cache=<host> and --remote_executor=<host>, it is possible to attach different headers to the cache and execution requests.

@buchgr
Copy link
Contributor

buchgr commented Oct 18, 2019

@AlessandroPatti yes we do but I don't know of anyone setting these two to different values or both at the same time. If you set --remote_executor then --remote_cache automatically defaults to the value of --remote_executor.

So for now I'd prefer to just reuse --remote_headers flag for everything until the use case comes up.

@simon0191
Copy link

@AlessandroPatti yes we do but I don't know of anyone setting these two to different values or both at the same time. If you set --remote_executor then --remote_cache automatically defaults to the value of --remote_executor.

So for now I'd prefer to just reuse --remote_headers flag for everything until the use case comes up.

We are using separate services for the CAS and the Scheduler, and therefore require different endpoints for both. I though that Bazel now creates 2 different connections.
CC @eliangidoni @AlessandroPatti

@AlessandroPatti
Copy link
Contributor Author

We do have such use case already. We want to add different headers to cache and execution requests. Now that I think about it, it is not really necessary for the two endpoint to be different, different headers might be necessary according to the request type.

@buchgr
Copy link
Contributor

buchgr commented Oct 18, 2019

Makes sense. Let's figure out how to keep flags sane then :-). I don't want to have 3 different flags.

How about:

  • --remote_header: if set applies to all requests for both http and grpc.
  • --remote_exec_header: if set applies only to Execute() RPCs. Allows to override a header set in --remote_header.

@simon0191
Copy link

If we want to pass a header for the CAS and a header for execution the request would look like:

bazel build --remote_header='CAS_SPECIFIC_HEADER=XXX' --remote_exec_header='EXEC_SPECIFIC_HEADER=YYY'

I think it would be better to have a flag that allow us to specify a cas specific header so that it's more explicit what's happening.

bazel build --remote_cas_header='CAS_SPECIFIC_HEADER=XXX' --remote_exec_header='EXEC_SPECIFIC_HEADER=YYY'

And, alternatively have a --remote_header=GENERIC_HEADER=ZZZ which will be passed to both, CAS and Executor, but will be overriden by the specific ones.

@AlessandroPatti
Copy link
Contributor Author

If we want to pass a header for the CAS and a header for execution the request would look like:

bazel build --remote_header='CAS_SPECIFIC_HEADER=XXX' --remote_exec_header='EXEC_SPECIFIC_HEADER=YYY'

I think it would be better to have a flag that allow us to specify a cas specific header so that it's more explicit what's happening.

bazel build --remote_cas_header='CAS_SPECIFIC_HEADER=XXX' --remote_exec_header='EXEC_SPECIFIC_HEADER=YYY'

And, alternatively have a --remote_header=GENERIC_HEADER=ZZZ which will be passed to both, CAS and Executor, but will be overriden by the specific ones.

I'd also add that it would not be possible to pass a header to the CAS and not to the executor.

@buchgr

@simon0191
Copy link

@werkt thoughts on this?

Comment on lines 200 to 201
List<ClientInterceptor> execInterceptors = interceptors;
List<ClientInterceptor> cacheInterceptors = interceptors;
Copy link
Contributor

Choose a reason for hiding this comment

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

This will use the same referenced list for all of the interceptors, which definitely is not what you want. You would need separate List instances, likely with interceptors populated below copied in, to effect different sets of interceptors.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see the reassignment below accomplishes this, but a bit awkwardly. Composition via a list view would be preferred, as jakob mentioned below, as a parameter to RemoteSpawnRunner instantiation, just so you don't have the potential for reference duplication, and don't have to rely on reference equality.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure what you meant here. How should the headers be passed with the RemoteSpawnRunner? Also, that module takes care only of remote execution, doesn't it? In that case, how to pass the headers to the cache too?

Copy link
Contributor

Choose a reason for hiding this comment

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

Coordinated offline. New changes look good, ty.

@AlessandroPatti AlessandroPatti force-pushed the apatti/grpc/remote-headers branch 2 times, most recently from b149fd2 to 9873e84 Compare November 25, 2019 13:06
@AlessandroPatti AlessandroPatti force-pushed the apatti/grpc/remote-headers branch from 9873e84 to 19a4d2e Compare November 25, 2019 13:12
@AlessandroPatti
Copy link
Contributor Author

Moved the code outside the RemoteModule class and added some tests. @buchgr can you please review the changes?

@elianuber
Copy link

cc @ola-rozenfeld @ishikhman
Could you take a look at this PR ? It seems that the most important comments were fixed by @AlessandroPatti

@rizzatti
Copy link

rizzatti commented Dec 9, 2019

👍

@ola-rozenfeld ola-rozenfeld removed their request for review December 9, 2019 17:06
@AlessandroPatti
Copy link
Contributor Author

@buchgr Could you please review these changes? It is the last missing piece for us and we'd love to see it in the next release

@bazel-io bazel-io closed this in 38a7321 Dec 18, 2019
@AlessandroPatti AlessandroPatti deleted the apatti/grpc/remote-headers branch December 23, 2019 10:58
AlessandroPatti pushed a commit to uber-common/bazel that referenced this pull request Jan 13, 2020
Extends bazelbuild#8245 to gRPC.

Closes bazelbuild#10015.

PiperOrigin-RevId: 286175898
bazel-io pushed a commit that referenced this pull request Mar 3, 2020
Following #10015. Some requests do not use the custom headers.

Closes #10634.

PiperOrigin-RevId: 298574179
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes team-Remote-Exec Issues and PRs for the Execution (Remote) team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants