pants icon indicating copy to clipboard operation
pants copied to clipboard

Remove hardcoded `platform` in `execution_environment`

Open adam-singer opened this issue 8 months ago • 0 comments

Describe the bug

When configuring pants (2.21.0) to use remote execution and caching on macos for jvm based project (applies to others types) the platform property in execution_environment is not respected. The remote execution servers are run locally on macos to match source and target platform.

The source of the bug is the hard coded TODO https://github.com/pantsbuild/pants/blob/f8b6c4266eb3a94afec41c076e71843c62bad054/src/rust/engine/process_executor/src/main.rs#L449 of platform: Platform::Linux_x86_64. This setting will influence the platform cache key PANTS_CACHE_KEY_TARGET_PLATFORM and adversely influences other subsystems such as coursier resolvers trying to use linux but running on macos.

Pants version 2.21.0

OS local: macos remote execution server: macos

Additional info Seems this might be a known issue, couldn't find the exact issue, some relative issues around cache key/platform: https://github.com/pantsbuild/pants/issues/18450 https://github.com/pantsbuild/pants/issues/15764

Setup

Run nativelink locally on mac https://github.com/TraceMachina/nativelink?tab=readme-ov-file#-building-with-cargo

Setup basic remote execution in pants.remote-execution.toml in https://github.com/pantsbuild/example-jvm.git example app

[GLOBAL]
plugins = []
verify_config = false
remote_execution = true
remote_cache_read = true
remote_cache_write = true
remote_store_address = "grpc://127.0.0.1:50051"
remote_execution_address = "grpc://127.0.0.1:50051"
remote_instance_name = "main"
process_execution_remote_parallelism = 4
remote_provider = "reapi"

Setup remote_execution in BUILD file

local_environment(
  name="local",
  compatible_platforms=["macos_arm64"],
)
remote_environment(
  name="remote",
  platform='macos_arm64',
  description="Remote environment for macos_arm64",
  extra_platform_properties={},
  # don't want a fallback platform
  # fallback_environment="local",
)

Run

pants --no-pantsd --level=trace  --no-local-cache  --no-docker-execution --remote-execution  --pants-config-files=pants.remote-execution.toml test ::

Observe failures of downloading linux bins while on osx

7:13:33.09 [ERROR] 1 Exception encountered:

Engine traceback:
  in `test` goal

ProcessExecutionFailure: Process 'Fetching with coursier: com.martiansoftware:nailgun-server:0.9.1' failed with exit code 126.
stdout:
Running entrypoint.sh
Running command: __coursier/coursier_post_process_stderr.py /bin/bash __coursier/coursier_fetch_wrapper_script.sh __coursier/./cs-x86_64-pc-linux coursier_report.json --intransitive com.martiansoftware:nailgun-server:0.9.1

stderr:
+ coursier_exe=__coursier/./cs-x86_64-pc-linux
+ shift
+ json_output_file=coursier_report.json
+ shift
++ pwd
+ working_dir=/private/tmp/nativelink/work/77f7c5fec8ac3a63df67c74d50ff73fd033ae7a9752054b3139886fc4695381f
+ __coursier/./cs-x86_64-pc-linux fetch -r=https://maven-central.storage-download.googleapis.com/maven2 -r=https://repo1.maven.org/maven2 --no-default --json-output-file=coursier_report.json --intransitive com.martiansoftware:nailgun-server:0.9.1
__coursier/coursier_fetch_wrapper_script.sh: line 9: __coursier/./cs-x86_64-pc-linux: cannot execute binary file

Observed some of the request payloads contained EnvironmentVariable { name: "PANTS_CACHE_KEY_TARGET_PLATFORM", value: "linux_x86_64" }]

17:13:33.01 [DEBUG] built REv2 request (build_id=pants_run_2024_06_05_17_13_28_584_f5905430a06f4d4789a6d9b795ec2d00): action=Action { command_digest: Some(Digest { hash: "7d99470a23dd8d4141fdf394a199fb44baef875f00c0529709ea8c9b112b5fcf", size_bytes: 519 }), input_root_digest: Some(Digest { hash: "4b6d1f173dfca1f50a5c238caffb36cd203964cb290b47956748a9623ea9b49c", size_bytes: 85 }), timeout: None, do_not_cache: false, salt: b"", platform: None }; command=Command { arguments: ["__coursier/coursier_post_process_stderr.py", "/bin/bash", "__coursier/coursier_fetch_wrapper_script.sh", "__coursier/./cs-x86_64-pc-linux", "coursier_report.json", "--intransitive", "com.martiansoftware:nailgun-server:0.9.1"], environment_variables: [EnvironmentVariable { name: "COURSIER_ARCHIVE_CACHE", value: ".cache/arc" }, EnvironmentVariable { name: "COURSIER_CACHE", value: ".cache/82ce2b8f4bc8f448df4f6ed5355885af1faeecda677ab193fad51e95d47d1677/jdk" }, EnvironmentVariable { name: "COURSIER_JVM_CACHE", value: ".cache/v1" }, EnvironmentVariable { name: "PANTS_CACHE_KEY_EXECUTION_STRATEGY", value: "remote_execution" }, EnvironmentVariable { name: "PANTS_CACHE_KEY_TARGET_PLATFORM", value: "linux_x86_64" }], output_files: ["coursier_report.json"], output_directories: ["classpath"], output_paths: [], platform: Some(Platform { properties: [] }), working_directory: "", output_node_properties: [] }; execute_request=ExecuteRequest { instance_name: "main", skip_cache_lookup: true, action_digest: Some(Digest { hash: "090e661178941101b9db1c0792bba8a8a012d802df59b51e617b8925039788d9", size_bytes: 141 }), execution_policy: None, results_cache_policy: None }

adam-singer avatar Jun 06 '24 01:06 adam-singer