bazel icon indicating copy to clipboard operation
bazel copied to clipboard

Inject metadata when calling RemoteActionFileSystem#createSymbolicLink for a non-symlink artifact.

Open tjgq opened this issue 3 years ago • 0 comments

A ctx.actions.symlink whose output is a declare_file or declare_directory (as opposed to a declare_symlink) has "copy" semantics, i.e., the output artifact is indistinguishable from the referent except for its name; the symlink is just a filesystem-level optimization to avoid an actual copy, and is transparently resolved when collecting the action output metadata.

When the symlink points to a directory that was built remotely and without the bytes, we currently must download the directory contents before executing the symlink action, so that the output metadata can be constructed from the local filesystem. This change short-circuits the filesystem traversal by injecting the input metadata into the output, thus avoiding the download.

(An alternative would have been to teach all of the RemoteActionFileSystem methods to resolve symlinks by patching together the local and remote metadata, but that results in an awful lot of complexity.)

Fixes https://github.com/bazelbuild/bazel/issues/15678.

tjgq avatar Sep 15 '22 12:09 tjgq