Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support runfiles root_symlinks in images #2250

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wolfd
Copy link

@wolfd wolfd commented Apr 21, 2023

Fixes symlink support and adds root_symlink support.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

^ I'm not aware of docs that mention what specifically happens to runfiles.

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Previously I was seeing that runfiles.symlinks (regardless of whether the target file existed in runfiles.files), did not point to the correct location in the image (they were broken).

Additionally, root_symlinks were entirely ignored.

Issue Number: N/A

What is the new behavior?

The overall method we take here is to create real files where the [root_]symlink is declared if the target File is not seen in file_map.

We now use _final_file_path instead of layer_file_path. This seems to work, but I am not sure if I'm missing a use-case here.

This PR also adds some extra test functionality to check that symlinks point at the expected location.

Does this PR introduce a breaking change?

  • Yes
  • No

I don't think that the previous behavior is considered working, and I'm having trouble imagining a case where that broken behavior would be desired.

Other information

Fixes symlink support and adds root_symlink support. Previously I was
seeing that symlinks (regardless of whether the target file existed in
runfiles.file), did not point to the correct location in the image.

For that reason, we use `_final_file_path` instead of `layer_file_path`.
This seems to work, but I am not sure if I'm missing a use-case here.

The overall method we take here is to create real files where the
[root_]symlink is declared if the target `File` is not seen in
`file_map`.

This PR also adds some extra test functionality to check that symlinks
point at the expected location.
symlinks.update({
(_reference_dir(ctx) + "/" + s.path): layer_file_path(ctx, s.target_file)
for s in _default_symlinks(dep).to_list()
if hasattr(s, "path") # "path" and "target_file" are exposed to starlark since bazel 0.21.0.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figure that 0.21.0 is not worth worrying about anymore?

@wolfd
Copy link
Author

wolfd commented May 12, 2023

For what it's worth, using root_symlinks or symlinks without also including the real file in runfiles seems to be buggy when using --remote_download_toplevel, as mentioned here: bazelbuild/bazel#18249

Regardless, this PR can be used to make layers with or without the target file existing in the same runfiles object. Just thought I'd mention it.

Copy link

This Pull Request has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days.
Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_docker!

@github-actions github-actions bot added the Can Close? Will close in 30 days unless there is a comment indicating why not label Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Can Close? Will close in 30 days unless there is a comment indicating why not
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant