Skip to content

Commit 04d1292

Browse files
committed
[buildbuddy 1/6]: allow tool override
This change is needed because BuildBuddy cache and execution views key off the Bazel RequestMetadata tool name. Buck2 reports buck2 by default, so BuildBuddy-backed Buck2 requests need an override when a deployment requires Bazel-compatible request metadata. Add a buck2_re_client.request_metadata_tool_name option that defaults to buck2 and thread it through OSS RE gRPC requests. A later BuildBuddy profile commit uses the option to send bazel.
1 parent 832b53f commit 04d1292

4 files changed

Lines changed: 163 additions & 7 deletions

File tree

app/buck2_common/src/legacy_configs/dice.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,10 @@ const CONFIGS_INVISIBLE_TO_DICE: &[BuckconfigKeyRef<'static>] = &[
463463
section: "buck2_re_client",
464464
property: "override_use_case",
465465
},
466+
BuckconfigKeyRef {
467+
section: "buck2_re_client",
468+
property: "request_metadata_tool_name",
469+
},
466470
BuckconfigKeyRef {
467471
section: "scuba",
468472
property: "defaults",

app/buck2_re_configuration/src/lib.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,8 @@ pub struct Buck2OssReConfiguration {
466466
pub instance_name: Option<String>,
467467
/// Use the Meta version of the request metadata
468468
pub use_fbcode_metadata: bool,
469+
/// Optional override for RequestMetadata.tool_details.tool_name.
470+
pub request_metadata_tool_name: Option<String>,
469471
/// The max size for a GRPC message to be decoded.
470472
pub max_decoding_message_size: Option<usize>,
471473
/// The max cumulative blob size for batch CAS methods.
@@ -593,6 +595,10 @@ impl Buck2OssReConfiguration {
593595
property: "use_fbcode_metadata",
594596
})?
595597
.unwrap_or(false),
598+
request_metadata_tool_name: legacy_config.parse(BuckconfigKeyRef {
599+
section: BUCK2_RE_CLIENT_CFG_SECTION,
600+
property: "request_metadata_tool_name",
601+
})?,
596602
max_decoding_message_size: legacy_config.parse(BuckconfigKeyRef {
597603
section: BUCK2_RE_CLIENT_CFG_SECTION,
598604
property: "max_decoding_message_size",
@@ -701,4 +707,28 @@ mod tests {
701707
assert_eq!(config.remote_cache_compression_threshold, Some(100));
702708
Ok(())
703709
}
710+
711+
#[test]
712+
fn oss_config_parses_request_metadata_tool_name() -> buck2_error::Result<()> {
713+
let legacy_config = parse(
714+
&[(
715+
"config",
716+
"[buck2_re_client]\nrequest_metadata_tool_name = bazel\n",
717+
)],
718+
"config",
719+
)?;
720+
let config = Buck2OssReConfiguration::from_legacy_config(&legacy_config, Vec::new())?;
721+
722+
assert_eq!(config.request_metadata_tool_name.as_deref(), Some("bazel"));
723+
Ok(())
724+
}
725+
726+
#[test]
727+
fn oss_config_leaves_request_metadata_tool_name_unset_by_default() -> buck2_error::Result<()> {
728+
let legacy_config = parse(&[("config", "")], "config")?;
729+
let config = Buck2OssReConfiguration::from_legacy_config(&legacy_config, Vec::new())?;
730+
731+
assert_eq!(config.request_metadata_tool_name, None);
732+
Ok(())
733+
}
704734
}

docs/users/remote_execution.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ Keys supported include:
4242
interpolation syntax ($VAR). They will be substituted before reading the file.
4343
- `instance_name` - an instance name to pass on execution, action cache, and CAS
4444
requests.
45+
- `request_metadata_tool_name` - optional override for
46+
`RequestMetadata.tool_details.tool_name` in the Bazel remote execution request
47+
metadata. This defaults to `buck2`.
4548
- `capabilities` - whether Buck2 should query the RE capabilities service. This
4649
defaults to enabled.
4750
- `max_total_batch_size` - optional client-side cap for cumulative blob size in

0 commit comments

Comments
 (0)