Repository: common-workflow-language/cwltool

Issue:
Error accessing docker start file under Windows
```
(cwl) C:\CWL>cwl-runner 1st-tool.cwl test.yaml
[30mINFO[0m C:\Users\user\Anaconda3\envs\cwl\Scripts\cwl-runner 1.0.20190815141648
[30mINFO[0m Resolved '1st-tool.cwl' to 'file:///C:/CWL/1st-tool.cwl'
[30mWARNING[0m [33m
We are on Microsoft Windows and not all components of this CWL description have a
container specified. This means that these steps will be executed in the default container,
which is frolvlad/alpine-bash.

Note, this could affect portability if this CWL description relies on non-POSIX features
or commands in this container. For best results add the following to your CWL
description's hints section:

hints:
  DockerRequirement:
    dockerPull: frolvlad/alpine-bash
[0m
INFO [job 1st-tool.cwl] C:\Users\user\AppData\Local\Temp\4ahxulbx$ docker \
    run \
    -i \
    --volume=/C/Users/user/AppData/Local/Temp/4ahxulbx:/rvfrvb:rw \
    --volume=/C/Users/user/AppData/Local/Temp/ekuzqnhf:/tmp:rw \
    --workdir=/rvfrvb \
    --read-only=true \
    --rm \
    --env=TMPDIR=/tmp \
    --env=HOME=/rvfrvb \
    --cidfile=C:\Users\user\AppData\Local\Temp\9el4tl5z\20190830152952-110282.cid \
    frolvlad/alpine-bash \
    echo \
    'Hello world!'
ERROR Exception while running job
Traceback (most recent call last):
  File "c:\users\user\anaconda3\envs\cwl\lib\site-packages\cwltool\job.py", line 321, in _execute
    monitor_function=monitor_function
  File "c:\users\user\anaconda3\envs\cwl\lib\site-packages\cwltool\job.py", line 785, in _job_popen
    monitor_function(sproc)
  File "c:\users\user\anaconda3\envs\cwl\lib\site-packages\cwltool\job.py", line 708, in docker_monitor
    with open(stats_file.name, mode="w") as stats_file_handle:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\user\\AppData\\Local\\Temp\\0_8ctckh'
WARNING [job 1st-tool.cwl] completed permanentFail
{}
WARNING Final process status is permanentFail
```


Discussion:

Resolving patch:
diff --git a/cwltool/job.py b/cwltool/job.py
--- a/cwltool/job.py
+++ b/cwltool/job.py
@@ -705,8 +705,11 @@ def docker_monitor(self, cidfile, tmpdir_prefix, cleanup_cidfile, process):
             time.sleep(1)
             if process.returncode is not None:
                 if cleanup_cidfile:
-                    os.remove(cidfile)
-                return
+                    try:
+                        os.remove(cidfile)
+                    except OSError as exc:
+                        _logger.warn("Ignored error cleaning up Docker cidfile: %s", exc)
+                    return
             try:
                 with open(cidfile) as cidhandle:
                     cid = cidhandle.readline().strip()
@@ -715,12 +718,16 @@ def docker_monitor(self, cidfile, tmpdir_prefix, cleanup_cidfile, process):
         max_mem = psutil.virtual_memory().total
         tmp_dir, tmp_prefix = os.path.split(tmpdir_prefix)
         stats_file = tempfile.NamedTemporaryFile(prefix=tmp_prefix, dir=tmp_dir)
-        with open(stats_file.name, mode="w") as stats_file_handle:
-            stats_proc = subprocess.Popen(
-                ['docker', 'stats', '--no-trunc', '--format', '{{.MemPerc}}',
-                 cid], stdout=stats_file_handle, stderr=subprocess.DEVNULL)
-            process.wait()
-            stats_proc.kill()
+        try:
+            with open(stats_file.name, mode="w") as stats_file_handle:
+                stats_proc = subprocess.Popen(
+                    ['docker', 'stats', '--no-trunc', '--format', '{{.MemPerc}}',
+                     cid], stdout=stats_file_handle, stderr=subprocess.DEVNULL)
+                process.wait()
+                stats_proc.kill()
+        except OSError as exc:
+            _logger.warn("Ignored error with docker stats: %s", exc)
+            return
         max_mem_percent = 0
         with open(stats_file.name, mode="r") as stats:
             for line in stats:


Test patch:
diff --git a/tests/test_udocker.py b/tests/test_udocker.py
--- a/tests/test_udocker.py
+++ b/tests/test_udocker.py
@@ -10,7 +10,8 @@
 LINUX = sys.platform in ('linux', 'linux2')
 
 
-@pytest.mark.skipif(not LINUX, reason="LINUX only")
+#@pytest.mark.skipif(not LINUX, reason="LINUX only")
+@pytest.mark.skip("Udocker install is broken, see https://github.com/indigo-dc/udocker/issues/221")
 class TestUdocker:
     udocker_path = None