Closed Yannik closed 1 month ago
Part of executing modules is to compile a helper module util that is written in C#. This C# util requires compilation and internally uses csc.exe to produce a temporary dll. The error indicated here CS1610 would indicate it failed to remove the temporary files from this operation but the cause behind it is not really seen. While I can investigate potentially turning this error into a warning there is not much we can do to solve the underlying cause as the delete part happens under a process not under our control.
@jborean93 It would be greatly appreciated if this could be turned into a warning instead of an error.
This is really causing a headache since it results in regular (but unpredictable) job failures.
Just out of curiosity: it seems like this helper module compilation/deletion is done on every task. Is that really efficient?
Just out of curiosity: it seems like this helper module compilation/deletion is done on every task. Is that really efficient?
There are a few things that come into play with file deletion and Ansible
This happens when the controller needs to create a temporary directory for an action invocation. For example using win_copy/win_template
to copy a file it will
This also can happen if pipelining is disabled but for Windows and the winrm/psrp/ssh
connection plugin you really have to go out of your way to disable pipelining so this won't apply.
This happens when the module using the Ansible.Basic
module wrapper asks for a temporary directory and there is no controller managed tempdir. When the module is finished it will delete the tempdir and any files that were created. This is all done in the same process so should be quite efficient.
This particular problem is somewhat separate from the other two types of tempdirs. When modules run a module_util that is written in C# the code needs to be compiled. Internally we essentially call something similar to the Add-Type cmdlet so the actual creation of this temporary file and trying to delete it is really outside of our control. I'll have to play around with this a bit more to see what knobs I have to control this particular failure.
Just out of curiosity: it seems like this helper module compilation/deletion is done on every task. Is that really efficient?
We do this on every task because each task should be self contained and not leave any leftover artifacts. Outside of the controller side tempdir (which should be somewhat uncommon on Windows) managing the module side tempdir is a fairly inexpensive (and also uncommon task).
I need to spend some more time in figuring out a good way to test it out but I hope https://github.com/ansible/ansible/pull/83080 should improve the situation for you. Unfortunately the error comes from csc.exe
which the .NET API is calling which I have no control off. Ignoring the error code and manually trying to delete the directory should help with this situation.
Thanks, that looks great!
@jborean93 Any chance to get this merged soon? This keeps breaking large playbook runs for me. :(
Sorry for the delay, it has been merged and backports have been created.
@jborean93 Thank you so much!
SUMMARY
In addition to the winrm connection issues discussed in #597, there is another intermittent issue that is starting to show up more often with growing host count. I would say this happens once in every 5000 task executions. It happens to all types of ansible.windows modules, so it seems to be some type of general problem with how ansible executes powershell on windows.
Here are some sample errors:
ISSUE TYPE
COMPONENT NAME
winrm
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
Target OS: windows server 2022
pywinrm-0.4.3 pykerberos-1.2.4