You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修复Buck2远程执行平台未实际远程运行的问题?

问题排查与修复方案

问题现象

已实现远程执行平台规则_remote_execution_platform_impl,完成多平台注册并在platforms/BUCK配置了远程平台,同时给sh_binary设置了对应兼容约束。执行命令:

buck2 run //utils:ip_test --target-platforms root//platforms:remote

预期输出远程执行器主机名,但实际输出本地主机名,且远程执行器无日志。已通过localhost:8980转发到远程执行器,Buck2配置如下:

[buck2_re_client]
action_cache_address = grpc://localhost:8980
engine_address = grpc://localhost:8980
cas_address = grpc://localhost:8980
tls = false

核心问题

当前_remote_execution_platform_impl生成的ExecutionPlatformInfo缺少远程执行器可识别的平台属性映射,导致Buck2无法正确将任务调度到远程执行器,最终 fallback 到本地执行。

修改方案

调整_remote_execution_platform_impl中的CommandExecutorConfig,补充远程执行平台的关键属性:

def _remote_execution_platform_impl(ctx: AnalysisContext) -> list[Provider]:
    constraint_list = [c[ConstraintValueInfo] for c in ctx.attrs.constraints]
    cfg = ConfigurationInfo(constraints = {c.setting.label: c for c in constraint_list}, values = {})

    name = ctx.label.raw_target()
    platform = ExecutionPlatformInfo(
        label = name,
        configuration = cfg,
        executor_config = CommandExecutorConfig(
            local_enabled = False,
            remote_enabled = True,
            # 新增:添加远程执行器需要的平台属性,需与远程执行器节点的属性匹配
            remote_execution_properties = {
                "os": "linux",  # 替换为远程执行器节点的实际操作系统
                "architecture": "x86_64",  # 替换为远程执行器节点的实际架构
                # 若远程执行器有自定义属性,也需在此添加
            },
            remote_execution_use_case="buck2",
            # 新增:指定远程执行器对应的平台名称(若远程执行器配置了平台别名)
            remote_execution_platform_name="linux-x86_64",
        ),
    )

    return [
        DefaultInfo(),
        platform,
        PlatformInfo(label = str(name), configuration = cfg)
    ]

remote_execution_platform = rule(
    impl = _remote_execution_platform_impl,
    attrs = {
        "constraints": attrs.list(attrs.dep(providers = [ConstraintValueInfo]))
    },
)

额外验证点

  1. 确保remote_execution_properties中的os和architecture与远程执行器的工作节点属性完全匹配,可通过远程执行器的API或管理界面查看节点属性。
  2. 确认远程执行器的服务端口8980正常监听,本地转发无异常:
grpcurl -plaintext localhost:8980 list
  1. 执行命令时添加--verbose参数,查看Buck2的调度日志,确认是否正确匹配到远程平台:
buck2 run //utils:ip_test --target-platforms root//platforms:remote --verbose

内容的提问来源于stack exchange,提问作者Ryan Z

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 13:07:20