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

Hardlink follow #34228

Open
wants to merge 4 commits into
base: devel
Choose a base branch
from
Open

Hardlink follow #34228

wants to merge 4 commits into from

Conversation

odra
Copy link

@odra odra commented Dec 26, 2017

SUMMARY

Uses os.readlink to retrieve the link's full path when hard linking a soft link (using follow: true).

Fixes #33911

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

File

ANSIBLE VERSION
ansible 2.5.0
  config file = None
  configured module search path = [u'/home/lrossetti/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/lrossetti/Work/ansible/venv/lib/python2.7/site-packages/ansible-2.5.0-py2.7.egg/ansible
  executable location = /home/lrossetti/Work/ansible/venv/bin/ansible
  python version = 2.7.14 (default, Nov  3 2017, 10:55:25) [GCC 7.2.1 20170915 (Red Hat 7.2.1-2)]
ADDITIONAL INFORMATION

I created an additional task in the module's integration test, sample usage:

-
  hosts: localhost
  tasks:
    - 
      name: Run hard link test
      include_role:
        name: file_test
        tasks_from: hard_link_follow.yml
  vars:
    output_dir: ~/tmp

Note: not sure if this is the best approach to test this, I tried to use the file role test (main.yml) but it failed a couple of times to me + this test felt like it should be an isolated test case on its own.

@ansibot ansibot added affects_2.5 This issue/PR affects Ansible v2.5 bugfix_pull_request core_review In order to be merged, this PR must follow the core review workflow. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests. labels Dec 26, 2017
@jborean93 jborean93 removed the test This PR relates to tests. label Jan 4, 2018
@ansibot ansibot added stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. and removed needs_triage Needs a first human triage before being processed. labels Jan 4, 2018
@caphrim007 caphrim007 requested review from Akasurde and removed request for Akasurde Jan 9, 2018
@caphrim007
Copy link
Contributor

@odra what were the failures you mentioned that prevent it from being in the file target?

@@ -422,6 +422,8 @@ def main():
else:
try:
if state == 'hard':
if follow and os.path.islink(b_src):
b_src = os.readlink(b_src)
Copy link
Member

@bcoca bcoca Jan 9, 2018

Choose a reason for hiding this comment

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

islink and readlink only works with symlinks. Also, this makes no sense for hardlinks, they don't have a canonical source, both entries ARE the file.

Copy link
Author

@odra odra Jan 9, 2018

Choose a reason for hiding this comment

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

It is failing to create a hard link when using a symlink path as its src, that's why I used those functions to retrieve the symlink original path.

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Jan 9, 2018
@odra
Copy link
Author

odra commented Jan 9, 2018

@caphrim007 the first error I get is this one:

fatal: [localhost]: FAILED! => {
    "assertion": "file3_result.mode == '0644'", 
    "changed": false, 
    "evaluated_to": false
}

It creates an empty file with a different permission than the expected one, if I comment that particular check, it fails on this step:

fatal: [localhost]: FAILED! => {
    "assertion": "file4_result.changed == true", 
    "changed": false, 
    "evaluated_to": false
}

@ansibot ansibot added the new_contributor This PR is the first contribution by a new community member. label Jan 25, 2018
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bugfix_pull_request labels Mar 2, 2018
@ansibot ansibot removed the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Mar 3, 2018
@ansibot ansibot added stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. stale_review Updates were made after the last review and the last review is more than 7 days old. labels Mar 13, 2018
@odra
Copy link
Author

odra commented Apr 23, 2018

Hello @bcoca I have removed the hard link so the change is applied for both link types.

@ansibot ansibot removed the stale_review Updates were made after the last review and the last review is more than 7 days old. label May 17, 2018
@ansibot ansibot added the needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html label May 17, 2018
@ansibot ansibot added the files Files category label Mar 5, 2019
@goneri goneri added the needs_verified This issue needs to be verified/reproduced by maintainer label Sep 20, 2019
@samdoran samdoran self-assigned this Sep 20, 2019
@ansibot ansibot added pre_azp This PR was last tested before migration to Azure Pipelines. and removed stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Dec 6, 2020
@samdoran samdoran removed their assignment Jan 7, 2021
bcoca
bcoca approved these changes Apr 28, 2021
@samdoran
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Pull request contains merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. files Files category module This issue/PR relates to a module. needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. needs_verified This issue needs to be verified/reproduced by maintainer new_contributor This PR is the first contribution by a new community member. pre_azp This PR was last tested before migration to Azure Pipelines. small_patch support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

file module does not honour follow when hard linking
7 participants