-
Notifications
You must be signed in to change notification settings - Fork 40.7k
Enhance symlink handling in initialization script #130907
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
base: master
Are you sure you want to change the base?
Conversation
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Hi @build-bot-helper. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: build-bot-helper The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
else | ||
echo "$(pwd -P)/${f}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pwd -P should recursively resolves symlinks? -P stands for physical / resolve all symlinks. (which can only be for the current working directory because that's the only thing pwd looks at, so "all" clearly means recursive)
Are you sure this PR is necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BenTheElder correct, pwd -P
does recursively resolve all symlinks in the current working directory path.
The current kube::readlinkdashf
function doesn't handle chains of symlinks in the target file/directory before applying pwd -P
, so the issue I'm addressing here is a bit different (I should have clarified in the PR body).
For example, if /path/to/linkA
points to linkB
and linkB
points to an actual file, the current function only resolves the first symlink and returns linkB
, not the final target.
The improvement in this PR is that it resolves symlinks in the target path itself before using pwd -P
for the directory portion. This ensures that complex symlink chains are fully resolved to their final destination.
What type of PR is this?
/kind feature
What this PR does / why we need it:
The current hack/lib/init.sh script doesn't recursively follow multiple layers of symlinks. If there is a symlink pointing to another symlink, it will only resolve one level.
This PR adds recursively symlink handling to the script, while using a loop to prevent infinite recursion in the case of circular links.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: