Skip to content

Commit 8567f53

Browse files
krallinfacebook-github-bot
authored andcommitted
log host sharing requirements to buck2 logging
Summary: I would like to make this information available to buck2_test_actions in order to record somewhere which tests request specific host resources, so I need to add it here. I did this for tests only because I didn't want to make regular actions more expensive and didn't need it yet. Reviewed By: IanChilds Differential Revision: D73581677 fbshipit-source-id: ca533fa299346adeecbe405c35e3a42a1d6facbe
1 parent 74f740e commit 8567f53

File tree

11 files changed

+35
-3
lines changed

11 files changed

+35
-3
lines changed

app/buck2_cli_proto/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ fn main() -> io::Result<()> {
2020
".".to_owned(),
2121
"../buck2_data".to_owned(),
2222
"../buck2_subscription_proto".to_owned(),
23+
"../buck2_host_sharing_proto".to_owned(),
2324
]
2425
};
2526

app/buck2_data/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ version = "0.1.0"
77

88
[dependencies]
99
allocative = { workspace = true }
10+
buck2_host_sharing_proto = { workspace = true }
1011
derive_more = { workspace = true }
1112
hex = { workspace = true }
1213
prost = { workspace = true }

app/buck2_data/build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fn main() -> io::Result<()> {
1616
let includes = if let Ok(path) = env::var("BUCK_PROTO_SRCS") {
1717
vec![path]
1818
} else {
19-
vec![".".to_owned()]
19+
vec![".".to_owned(), "../buck2_host_sharing_proto".to_owned()]
2020
};
2121

2222
buck2_protoc_dev::configure()
@@ -266,5 +266,6 @@ fn main() -> io::Result<()> {
266266
.boxed("SpanEndEvent.data.action_execution")
267267
.boxed("SpanEndEvent.data.cache_upload")
268268
.boxed("InstantEvent.data.snapshot")
269+
.extern_path(".buck.host_sharing", "::buck2_host_sharing_proto")
269270
.compile(proto_files, &includes)
270271
}

app/buck2_data/data.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import "google/protobuf/duration.proto";
1313
import "google/protobuf/timestamp.proto";
1414
import "google/protobuf/empty.proto";
1515
import "error.proto";
16+
import "host_sharing.proto";
1617

1718
package buck.data;
1819

@@ -1800,6 +1801,8 @@ message TestDiscoveryEnd {
18001801
string suite_name = 1;
18011802
CommandExecution command_report = 2;
18021803
bool re_cache_enabled = 3;
1804+
optional buck.host_sharing.HostSharingRequirements
1805+
command_host_sharing_requirements = 4;
18031806
}
18041807

18051808
message TestRunStart {
@@ -1809,6 +1812,8 @@ message TestRunStart {
18091812
message TestRunEnd {
18101813
TestSuite suite = 1;
18111814
CommandExecution command_report = 2;
1815+
optional buck.host_sharing.HostSharingRequirements
1816+
command_host_sharing_requirements = 3;
18121817
}
18131818

18141819
message FileWatcherStart {

app/buck2_execute_impl/src/executors/local.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ impl LocalExecutor {
413413
value: v.into_string_lossy(),
414414
})
415415
.collect();
416+
416417
let stage = match worker {
417418
None => buck2_data::LocalExecute {
418419
command: Some(buck2_data::LocalCommand {

app/buck2_forkserver_proto/build.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ fn main() -> io::Result<()> {
1616
let includes = if let Ok(path) = env::var("BUCK_PROTO_SRCS") {
1717
vec![path]
1818
} else {
19-
vec![".".to_owned(), "../buck2_data".to_owned()]
19+
vec![
20+
".".to_owned(),
21+
"../buck2_data".to_owned(),
22+
"../buck2_host_sharing_proto".to_owned(),
23+
]
2024
};
2125

2226
buck2_protoc_dev::configure()

app/buck2_health_check_proto/build.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ fn main() -> io::Result<()> {
1616
let includes = if let Ok(path) = env::var("BUCK_PROTO_SRCS") {
1717
vec![path]
1818
} else {
19-
vec![".".to_owned(), "../buck2_data".to_owned()]
19+
vec![
20+
".".to_owned(),
21+
"../buck2_data".to_owned(),
22+
"../buck2_host_sharing_proto".to_owned(),
23+
]
2024
};
2125

2226
buck2_protoc_dev::configure()

app/buck2_host_sharing_proto/BUCK

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ rust_protobuf_library(
99
proto_srcs = ":host_sharing.proto",
1010
deps = [
1111
"fbsource//third-party/rust:prost-types",
12+
"fbsource//third-party/rust:serde",
1213
"fbsource//third-party/rust:tonic",
14+
"//buck2/allocative/allocative:allocative",
1315
],
1416
)
1517

app/buck2_host_sharing_proto/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ repository = { workspace = true }
77
version = "0.1.0"
88

99
[dependencies]
10+
allocative = { workspace = true }
1011
prost = { workspace = true }
1112
prost-types = { workspace = true }
13+
serde = { workspace = true }
1214
tonic = { workspace = true }
1315

1416
[build-dependencies]

app/buck2_host_sharing_proto/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ fn main() -> io::Result<()> {
2121

2222
buck2_protoc_dev::configure()
2323
.setup_protoc()
24+
.type_attribute(".", "#[derive(::allocative::Allocative)]")
25+
.type_attribute(".", "#[derive(::serde::Serialize, ::serde::Deserialize)]")
2426
.extern_path(".buck.data", "::buck2_data")
2527
.compile(proto_files, &includes)
2628
}

app/buck2_test/src/orchestrator.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ use futures::channel::mpsc::UnboundedSender;
148148
use futures::stream::FuturesUnordered;
149149
use futures::stream::StreamExt;
150150
use host_sharing::HostSharingRequirements;
151+
use host_sharing::convert::host_sharing_requirements_to_grpc;
151152
use indexmap::IndexMap;
152153
use indexmap::IndexSet;
153154
use indexmap::indexset;
@@ -1016,6 +1017,10 @@ impl BuckTestOrchestrator<'_> {
10161017
.to_command_execution_proto(true, true, false)
10171018
.await,
10181019
),
1020+
command_host_sharing_requirements: host_sharing_requirements_to_grpc(
1021+
prepared_command.request.host_sharing_requirements().clone(),
1022+
)
1023+
.ok(),
10191024
re_cache_enabled: *cacheable && re_cache_enabled,
10201025
};
10211026
((result, cached), end)
@@ -1068,6 +1073,10 @@ impl BuckTestOrchestrator<'_> {
10681073
.to_command_execution_proto(true, true, false)
10691074
.await,
10701075
),
1076+
command_host_sharing_requirements: host_sharing_requirements_to_grpc(
1077+
prepared_command.request.host_sharing_requirements().clone(),
1078+
)
1079+
.ok(),
10711080
};
10721081
(result, end)
10731082
})

0 commit comments

Comments
 (0)