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

Intercept capabilities and uploader requests and add custom grpc headers #10634

Closed

Conversation

AlessandroPatti
Copy link
Contributor

@AlessandroPatti AlessandroPatti commented Jan 22, 2020

Following #10015. Some requests do not use the custom headers.

@jin jin added the team-Remote-Exec Issues and PRs for the Execution (Remote) team label Jan 23, 2020
@jin jin assigned jin and buchgr and unassigned jin Jan 23, 2020
@elianuber
Copy link

Thanks Ale for patching this bug !
Maybe @buchgr can you give a quick review ?

@EdSchouten
Copy link
Contributor

Friendly ping!

Copy link
Contributor

@ulfjack ulfjack left a comment

Choose a reason for hiding this comment

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

Do you know why it wasn't done this way when the extra header options were added to Bazel? Just an oversight?

@@ -87,6 +89,7 @@

@GuardedBy("lock")
private final Map<HashCode, ListenableFuture<Void>> uploadsInProgress = new HashMap<>();
private final ClientInterceptor[] 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'd prefer to use ImmutableList here instead of array. One problem with using arrays is that anyone with a reference to the array can modify the contents asynchronously. Technically, ensuring the safety of this code requires reviewing all the callers to check if they're doing anything sinister. Even if it's unlikely that anyone would do so intentionally, it wouldn't be obvious if anyone is doing it accidentally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed this one to an ImmutableList as suggested.
There was also a similar bit in RemoteServerCapability, for which I opted for making a copy of the array instead, as it makes it easier to pass it directly to the withInterceptors method, that only accepts an array.

retrier);
retrier,
(execChannel != null ?
TracingMetadataUtils.newExecHeadersInterceptor(remoteOptions) :
Copy link
Contributor

Choose a reason for hiding this comment

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

I find it slightly odd that this has different options for caching and execution. If someone is asking Bazel to do one or the other, they can also provide different options, no?

(I realize that's a pre-existing condition, so feel free to ignore this comment.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to run the checks twice if the endpoints differ.

@@ -103,6 +105,10 @@ public static void afterEverything() {
assertThat(meta.getToolDetails().getToolName()).isEqualTo("bazel");
assertThat(meta.getToolDetails().getToolVersion())
.isEqualTo(BlazeVersionInfo.instance().getVersion());
assertThat(headers.get(Metadata.Key.of("Key1", Metadata.ASCII_STRING_MARSHALLER)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Having checks in the common case means that any future test case is forced to also test this by setting up custom remoteOptions. That seems like a bad direction, generally speaking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I'll create a new test case for it.

@AlessandroPatti
Copy link
Contributor Author

Do you know why it wasn't done this way when the extra header options were added to Bazel? Just an oversight?

Yes, just an oversight.

@ulfjack
Copy link
Contributor

ulfjack commented Feb 28, 2020

Looks good to me.

@buchgr @meisterT

@@ -108,14 +113,16 @@ public ByteStreamUploader(
ReferenceCountedChannel channel,
@Nullable CallCredentials callCredentials,
long callTimeoutSecs,
RemoteRetrier retrier) {
RemoteRetrier retrier,
ClientInterceptor... interceptors) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you consider passing in a channel that already has the interceptors attached instead? It seems preferable to me to not add knowledge about interceptors to the ByteStreamUploader if not necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

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.

None yet

7 participants