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

Throwing error "The directory is not empty." #662

Open
t8mas062184 opened this issue Sep 27, 2024 · 3 comments
Open

Throwing error "The directory is not empty." #662

t8mas062184 opened this issue Sep 27, 2024 · 3 comments

Comments

@t8mas062184
Copy link

SUMMARY

The issue is with win_get_url wherein it throws error sporadically on the same scenario on identical cicd VMs. We are utilizing an execution environment to run our playbooks within Ansible Automation Platform. So the info I have provided below came from the configs that are set to build the execution environment.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

ansible.windows.win_get_url

ANSIBLE VERSION
"ansible_distribution_version": "10.0.14393.0",
COLLECTION VERSION
  - name: ansible.windows
    version: 1.11.0
CONFIGURATION

OS / ENVIRONMENT

Target OS version is Windows 2019; our cicd server wherein we test our code before promoting it in our main branch.

STEPS TO REPRODUCE

Put a file in Azure blob container, generate sas token and encrypt in ansible-vault, utilize it on your playbook, same error and same location fails sporadically. It cannot be predicted and it is very intermittent. If only we could identify the root cause of it, probably we can put a retry on the ansible task. But the error that we are getting is some kind of a powershell script with a line number error which doesn't exist on our end. It seems like the win_get_url has this particular script and it is failing for a specific condition. Here is the code snippet that is failing sporadically:

- name: Fetch esob_secrets.txt to C:\appl\grafana-alloy-install
  ansible.windows.win_get_url:
    url: "{{ blob_container_uri }}/windows/secrets/esob_secrets.txt{{ esob_sas_key }}"
    dest: C:\appl\grafana-alloy-install\esob_secrets.txt
    force: true
  when: not alloy_service_name_stat_result.exists or not old_grafana_service_name_stat_result.exists
  notify: Reran_startup_script_windows
EXPECTED RESULTS

"msg": "OK",
"status_code": 200,
"checksum_src": "d22893a6c61b28fc9608f333c2b9ebe66ac70fe0",
"checksum_dest": "d22893a6c61b28fc9608f333c2b9ebe66ac70fe0",

ACTUAL RESULTS

{
"exception": "Exception calling "ExitJson" with "0" argument(s): "The directory is not empty.\r\n"\r\nAt line:299 char:1\r\n+ $module.ExitJson()\r\n+ ~~~~~~~~~~~~~~~~~~\r\n + CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException\r\n + FullyQualifiedErrorId : IOException\r\n\r\nScriptStackTrace:\r\nat , : line 299\r\n",
"msg": "Unhandled exception while executing module: Exception calling "ExitJson" with "0" argument(s): "The directory is not empty.\r\n"",
"_ansible_no_log": null,
"changed": false
}


@jborean93
Copy link
Collaborator

Can you share the Ansible version you are running with in your EE? Are you running the win_get_url module in parallel on the same host or this just fails randomly on the host?

@t8mas062184
Copy link
Author

we are utilizing the ee-minimal-rhel8:latest image when creating our EE. After checking, it utilizes v2.12
win_get_url module fails randomly on some hosts which we cannot identify the pattern. it is very sporadic

@jborean93
Copy link
Collaborator

ansible/ansible#80293 was merged into Ansible and is present in 2.13.x and newer. Unfortunately 2.12 doesn't include those changes so I recommended updating the Ansible version to one that includes the newer fixes in the temp dir handling. This should hopefully avoid this error but even if it failed to delete the file it'll warn rather than error now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants