Skip to content

Commit

Permalink
Ignore a hack property set by Bazel
Browse files Browse the repository at this point in the history
Bazel sets the "bazel-differentiate-workspace-cache" property when
building CPP on Windows. This is a hack to have different hash keys for
different workspaces (because header files sharing on Windows causing
some problems). It is not intended to mean anything to the remote
executor.

More about the property: bazelbuild/bazel#13339
  • Loading branch information
mou-hao committed Oct 25, 2021
1 parent 687d100 commit be11c53
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 33 deletions.
10 changes: 5 additions & 5 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ http_archive(
],
)

# gazelle:repository_macro go_dependencies.bzl%go_dependencies
load(":go_dependencies.bzl", "go_dependencies")

go_dependencies()

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

go_register_toolchains(version = "1.16")

# gazelle:repository_macro go_dependencies.bzl%go_dependencies
load(":go_dependencies.bzl", "go_dependencies")

go_dependencies()

load("@io_bazel_rules_docker//repositories:repositories.bzl", container_repositories = "repositories")

container_repositories()
Expand Down
2 changes: 1 addition & 1 deletion cmd/bb_runner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func main() {
"gRPC server failure: ",
bb_grpc.NewServersFromConfigurationAndServe(
configuration.GrpcServers,
func(s grpc.ServiceRegistrar) {
func(s *grpc.Server) {
runner_pb.RegisterRunnerServer(s, r)
}))
}()
Expand Down
6 changes: 3 additions & 3 deletions cmd/bb_scheduler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func main() {
"Client gRPC server failure: ",
bb_grpc.NewServersFromConfigurationAndServe(
configuration.ClientGrpcServers,
func(s grpc.ServiceRegistrar) {
func(s *grpc.Server) {
remoteexecution.RegisterCapabilitiesServer(s, buildQueue)
remoteexecution.RegisterExecutionServer(s, buildQueue)
}))
Expand All @@ -208,7 +208,7 @@ func main() {
"Worker gRPC server failure: ",
bb_grpc.NewServersFromConfigurationAndServe(
configuration.WorkerGrpcServers,
func(s grpc.ServiceRegistrar) {
func(s *grpc.Server) {
remoteworker.RegisterOperationQueueServer(s, buildQueue)
}))
}()
Expand All @@ -217,7 +217,7 @@ func main() {
"Build queue state gRPC server failure: ",
bb_grpc.NewServersFromConfigurationAndServe(
configuration.BuildQueueStateGrpcServers,
func(s grpc.ServiceRegistrar) {
func(s *grpc.Server) {
buildqueuestate.RegisterBuildQueueStateServer(s, buildQueue)
}))
}()
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
go.opentelemetry.io/otel v1.0.1
go.opentelemetry.io/otel/trace v1.0.1
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac
golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70
google.golang.org/genproto v0.0.0-20211008145708-270636b82663
google.golang.org/grpc v1.41.0
google.golang.org/protobuf v1.27.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,8 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac h1:oN6lz7iLW/YC7un8pq+9bOLyXrprv2+DKfkJY+2LJJw=
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70 h1:SeSEfdIxyvwGJliREIJhRPPXvW6sDlLT+UQ3B0hD0NA=
golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
4 changes: 2 additions & 2 deletions go_dependencies.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -800,8 +800,8 @@ def go_dependencies():
go_repository(
name = "org_golang_x_sys",
importpath = "golang.org/x/sys",
sum = "h1:oN6lz7iLW/YC7un8pq+9bOLyXrprv2+DKfkJY+2LJJw=",
version = "v0.0.0-20211007075335-d3039528d8ac",
sum = "h1:SeSEfdIxyvwGJliREIJhRPPXvW6sDlLT+UQ3B0hD0NA=",
version = "v0.0.0-20211023085530-d6a326fbbf70",
)
go_repository(
name = "org_golang_x_term",
Expand Down
20 changes: 18 additions & 2 deletions pkg/builder/in_memory_build_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,22 @@ func getRequestMetadata(ctx context.Context) *remoteexecution.RequestMetadata {
return nil
}

func pruneProperties(platform *remoteexecution.Platform) *remoteexecution.Platform {
ignorePropertiesMap := map[string]bool{
"bazel-differentiate-workspace-cache": true,
}
properties := platform.Properties
prunedProperties := make([]*remoteexecution.Platform_Property, 0, len(properties))
for _, property := range properties {
if ignorePropertiesMap[property.Name] {
continue
}
prunedProperties = append(prunedProperties, property)
}
platform.Properties = prunedProperties
return platform
}

// Execute an action by scheduling it in the build queue. This call
// blocks until the action is completed.
func (bq *InMemoryBuildQueue) Execute(in *remoteexecution.ExecuteRequest, out remoteexecution.Execution_ExecuteServer) error {
Expand Down Expand Up @@ -369,7 +385,7 @@ func (bq *InMemoryBuildQueue) Execute(in *remoteexecution.ExecuteRequest, out re
return util.StatusWrap(err, "Failed to obtain action")
}
action := actionMessage.(*remoteexecution.Action)
platformKey, err := platform.NewKey(instanceName, action.Platform)
platformKey, err := platform.NewKey(instanceName, pruneProperties(action.Platform))
if err != nil {
return err
}
Expand Down Expand Up @@ -403,7 +419,7 @@ func (bq *InMemoryBuildQueue) Execute(in *remoteexecution.ExecuteRequest, out re
// REv2.1 and older don't provide platform properties as
// part of the Action message.
if action.Platform == nil {
platformKey, err = platform.NewKey(instanceName, command.Platform)
platformKey, err = platform.NewKey(instanceName, pruneProperties(command.Platform))
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/proto/buildqueuestate/buildqueuestate.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/proto/remoteoutputservice/remote_output_service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/proto/remoteworker/remoteworker.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/proto/runner/runner.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/proto/tmp_installer/tmp_installer.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 3 additions & 13 deletions pkg/runner/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ go_library(
name = "runner",
srcs = [
"clean_runner.go",
"local_runner.go",
"local_runner_rss_bytes.go",
"local_runner_rss_kibibytes.go",
"local_runner.go",
"local_runner_unix.go",
"local_runner_windows.go",
"path_existence_checking_runner.go",
Expand All @@ -19,50 +19,40 @@ go_library(
"//pkg/cleaner",
"//pkg/proto/runner",
"//pkg/proto/tmp_installer",
"@com_github_buildbarn_bb_storage//pkg/filesystem",
"@com_github_buildbarn_bb_storage//pkg/filesystem/path",
"@com_github_buildbarn_bb_storage//pkg/util",
"@org_golang_google_grpc//codes",
"@org_golang_google_grpc//status",
"@org_golang_google_protobuf//types/known/emptypb",
] + select({
"@io_bazel_rules_go//go/platform:android": [
"//pkg/proto/resourceusage",
"@com_github_buildbarn_bb_storage//pkg/filesystem",
"@org_golang_google_grpc//status",
"@org_golang_google_protobuf//types/known/anypb",
"@org_golang_google_protobuf//types/known/durationpb",
],
"@io_bazel_rules_go//go/platform:darwin": [
"//pkg/proto/resourceusage",
"@com_github_buildbarn_bb_storage//pkg/filesystem",
"@org_golang_google_grpc//status",
"@org_golang_google_protobuf//types/known/anypb",
"@org_golang_google_protobuf//types/known/durationpb",
],
"@io_bazel_rules_go//go/platform:freebsd": [
"//pkg/proto/resourceusage",
"@com_github_buildbarn_bb_storage//pkg/filesystem",
"@org_golang_google_grpc//status",
"@org_golang_google_protobuf//types/known/anypb",
"@org_golang_google_protobuf//types/known/durationpb",
],
"@io_bazel_rules_go//go/platform:ios": [
"//pkg/proto/resourceusage",
"@com_github_buildbarn_bb_storage//pkg/filesystem",
"@org_golang_google_grpc//status",
"@org_golang_google_protobuf//types/known/anypb",
"@org_golang_google_protobuf//types/known/durationpb",
],
"@io_bazel_rules_go//go/platform:linux": [
"//pkg/proto/resourceusage",
"@com_github_buildbarn_bb_storage//pkg/filesystem",
"@org_golang_google_grpc//status",
"@org_golang_google_protobuf//types/known/anypb",
"@org_golang_google_protobuf//types/known/durationpb",
],
"@io_bazel_rules_go//go/platform:windows": [
"//pkg/proto/resourceusage",
"@com_github_buildbarn_bb_storage//pkg/filesystem",
"@org_golang_google_grpc//status",
"@org_golang_google_protobuf//types/known/anypb",
"@org_golang_google_protobuf//types/known/durationpb",
"@org_golang_x_sys//windows",
Expand Down

0 comments on commit be11c53

Please sign in to comment.