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

Avoid relink if not having permissions #1045

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

bogdang989
Copy link
Member

Fixes #1042

@bogdang989 bogdang989 closed this Jan 24, 2019
@bogdang989 bogdang989 reopened this Jan 24, 2019
@codecov
Copy link

codecov bot commented Jan 24, 2019

Codecov Report

Merging #1045 into master will decrease coverage by 13.2%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #1045       +/-   ##
===========================================
- Coverage   79.05%   65.85%   -13.21%     
===========================================
  Files          30       30               
  Lines        6030     6030               
  Branches     1496     1496               
===========================================
- Hits         4767     3971      -796     
- Misses        883     1679      +796     
  Partials      380      380
Impacted Files Coverage Δ
cwltool/job.py 60.39% <100%> (-7.01%) ⬇️
cwltool/singularity.py 24.83% <0%> (-55.56%) ⬇️
cwltool/provenance.py 28.26% <0%> (-52.18%) ⬇️
cwltool/update.py 37.73% <0%> (-30.19%) ⬇️
cwltool/executors.py 63.4% <0%> (-15.47%) ⬇️
cwltool/mutation.py 70% <0%> (-15%) ⬇️
cwltool/docker.py 40.78% <0%> (-14.04%) ⬇️
cwltool/load_tool.py 71.28% <0%> (-12.88%) ⬇️
cwltool/argparser.py 76.3% <0%> (-9.48%) ⬇️
cwltool/factory.py 85.36% <0%> (-7.32%) ⬇️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6d29984...8725472. Read the comment docs.

@codecov
Copy link

codecov bot commented Jan 24, 2019

Codecov Report

Merging #1045 into master will increase coverage by 5.69%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1045      +/-   ##
==========================================
+ Coverage   73.33%   79.03%   +5.69%     
==========================================
  Files          34       30       -4     
  Lines        6855     6033     -822     
  Branches     1743     1496     -247     
==========================================
- Hits         5027     4768     -259     
+ Misses       1296      885     -411     
+ Partials      532      380     -152
Impacted Files Coverage Δ
cwltool/job.py 67.17% <66.66%> (+3.41%) ⬆️
cwltool/resolver.py 43.47% <0%> (-33.58%) ⬇️
cwltool/update.py 67.92% <0%> (-18.25%) ⬇️
cwltool/pack.py 83.75% <0%> (-0.11%) ⬇️
cwltool/context.py 97.29% <0%> (-0.05%) ⬇️
cwltool/__main__.py
cwltool/flatten.py
cwltool/main.py
cwltool/utils.py
cwltool/provenance.py 80.44% <0%> (+0.06%) ⬆️
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 708ba4b...9027bbd. Read the comment docs.

Copy link
Member

@mr-c mr-c left a comment

Choose a reason for hiding this comment

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

We need to fix the source of these root owned files, not ignore them and clutter the user's storage system.

$ cwltool stage_array_in_dir.cwl --infiles README.rst --infiles CODE_OF_CONDUCT.md 
/home/michael/cwltool/env3/bin/cwltool 1.0.20181221153915
Resolved 'stage_array_in_dir.cwl' to 'file:///home/michael/cwltool/stage_array_in_dir.cwl'
[job stage_array_in_dir.cwl] /tmp/4zbs2e73$ docker \
    run \
    -i \
    --volume=/tmp/4zbs2e73:/AYRcZJ:rw \
    --volume=/tmp/gar1cr_9:/tmp:rw \
    --volume=/home/michael/cwltool/README.rst:/AYRcZJ/staged/README.rst:ro \
    --volume=/home/michael/cwltool/CODE_OF_CONDUCT.md:/AYRcZJ/staged/CODE_OF_CONDUCT.md:ro \
    --workdir=/AYRcZJ \
    --read-only=true \
    --user=1000:1000 \
    --rm \
    --env=TMPDIR=/tmp \
    --env=HOME=/AYRcZJ \
    --cidfile=/tmp/f9ahyhbr/20190422184929-544639.cid \
    debian:stretch-slim \
    ls \
    staged
CODE_OF_CONDUCT.md
README.rst
[job stage_array_in_dir.cwl] Max memory used: 0MiB
Exception while running job
Traceback (most recent call last):
  File "/home/michael/cwltool/cwltool/job.py", line 333, in _execute
    inplace_update=self.inplace_update)
  File "/home/michael/cwltool/cwltool/job.py", line 148, in relink_initialworkdir
    os.remove(host_outdir_tgt)
PermissionError: [Errno 13] Permission denied: '/tmp/4zbs2e73/staged/README.rst'
[job stage_array_in_dir.cwl] completed permanentFail
{}
Final process status is permanentFail
(env3) michael@debian:~/cwltool$ ls -la /tmp/4zbs2e73/staged/
total 8
drwxr-xr-x 2 root    root    4096 Apr 22 18:49 .
drwx------ 3 michael michael 4096 Apr 22 18:49 ..
-rwxr-xr-x 1 root    root       0 Apr 22 18:49 CODE_OF_CONDUCT.md
-rwxr-xr-x 1 root    root       0 Apr 22 18:49 README.rst

@mr-c mr-c changed the base branch from master to main July 2, 2020 11:20
@alexiswl
Copy link

alexiswl commented Aug 10, 2021

We need to fix the source of these root owned files, not ignore them and clutter the user's storage system.

I don't think the source of the files are necessarily the issues, but the way that they're mounted on docker.

I have a quite complicated tool where I mount files through a listing and also use a complex js to set the input value for a schema

The docker command becomes as follows:

docker \
    run \
    -i \
    --mount=type=bind,source=/tmp/6if0my13,target=/SdfLVG \
    --mount=type=bind,source=/tmp/5prz__i8,target=/tmp \
    --mount=type=bind,source=/tmp/tmp.IylnrvsNFw/outputs/analysis_outputs/AlignCollapseFusionCaller/0pt2pctDragonMixv2_DNA_rep1,target=/SdfLVG/var/lib/cwl/stgf373ef55-5da0-4f9d-98bc-80b9b425ec15/0pt2pctDragonMixv2_DNA_rep1,readonly \
    --mount=type=bind,source=/tmp/tmp.IylnrvsNFw/outputs/analysis_outputs/StitchedRealigned/0pt2pctDragonMixv2_DNA_rep1,target=/SdfLVG/var/lib/cwl/stgbb136a5c-43aa-4dfd-877e-d41dc9141857/0pt2pctDragonMixv2_DNA_rep1,readonly \
    --mount=type=bind,source=/tmp/tmp.IylnrvsNFw/outputs/analysis_outputs/MergedAnnotation/0pt2pctDragonMixv2_DNA_rep1,target=/SdfLVG/var/lib/cwl/stg1780b2a0-cf8f-4350-95ee-be7c835e6eb1/0pt2pctDragonMixv2_DNA_rep1,readonly \
    --mount=type=bind,source=/tmp/s9py_pdm/0pt2pctDragonMixv2_DNA_rep1_Failed_Exon_coverage_QC.txt,target=/SdfLVG/var/lib/cwl/stg80f1ea23-73fd-4d1d-8739-3db9c101435f/0pt2pctDragonMixv2_DNA_rep1_Failed_Exon_coverage_QC.txt,readonly \
    --mount=type=bind,source=/tmp/jwzg252o/0pt2pctDragonMixv2_DNA_rep1.AlignCollapseFusionCaller_metrics.json.gz,target=/SdfLVG/var/lib/cwl/stgd48ad50b-7b59-4e5b-96b4-3d27825cd6d7/0pt2pctDragonMixv2_DNA_rep1.AlignCollapseFusionCaller_metrics.json.gz,readonly \
    --mount=type=bind,source=/tmp/sr5gxf0v/0pt2pctDragonMixv2_DNA_rep1.tar.gz,target=/SdfLVG/var/lib/cwl/stg2dfd35aa-f1f9-44de-bdd1-5b29c4f6dff7/0pt2pctDragonMixv2_DNA_rep1.tar.gz,readonly \
    --mount=type=bind,source=/tmp/gsq7uj8a/0pt2pctDragonMixv2_DNA_rep1.tar.gz,target=/SdfLVG/var/lib/cwl/stgabc1fa11-b3b1-46b2-ab64-baab8eadfde7/0pt2pctDragonMixv2_DNA_rep1.tar.gz,readonly \
    --mount=type=bind,source=/tmp/ufymeqhv/0pt2pctDragonMixv2_DNA_rep1.tar.gz,target=/SdfLVG/var/lib/cwl/stgc608e7c4-8447-481a-85cc-a0e7234b0570/0pt2pctDragonMixv2_DNA_rep1.tar.gz,readonly \
    --workdir=/SdfLVG \
    --read-only=true \
    --net=none \
    --user=1000:1000 \
    --rm \
    --env=TMPDIR=/tmp \
    --env=HOME=/SdfLVG \
    --cidfile=/tmp/igt9ibcg/20210810170514-913731.cid \
    umccr/alpine-pandas:1.2.2 \
    python \
    create-output-dir.py \
    '--custom-output-dir-entry={"copy_method":"copy_method","dir":"/SdfLVG/var/lib/cwl/stgf373ef55-5da0-4f9d-98bc-80b9b425ec15/0pt2pctDragonMixv2_DNA_rep1","files_list_str":["0pt2pctDragonMixv2_DNA_rep1.bam","0pt2pctDragonMixv2_DNA_rep1.bam.bai","0pt2pctDragonMixv2_DNA_rep1.bam.md5sum","evidence.0pt2pctDragonMixv2_DNA_rep1.bam","evidence.0pt2pctDragonMixv2_DNA_rep1.bam.bai"]}' \
    --output-directory-name \
    0pt2pctDragonMixv2_DNA_rep1 \
    '--custom-output-dir-entry={"copy_method":"copy_method","dir":"/SdfLVG/var/lib/cwl/stgbb136a5c-43aa-4dfd-877e-d41dc9141857/0pt2pctDragonMixv2_DNA_rep1","files_list_str":["0pt2pctDragonMixv2_DNA_rep1.stitched.bam","0pt2pctDragonMixv2_DNA_rep1.stitched.bam.bai"]}' \
    '--custom-output-dir-entry={"copy_method":"copy_method","dir":"/SdfLVG/var/lib/cwl/stg1780b2a0-cf8f-4350-95ee-be7c835e6eb1/0pt2pctDragonMixv2_DNA_rep1","files_list_str":["0pt2pctDragonMixv2_DNA_rep1_MergedSmallVariantsAnnotated.json.gz","0pt2pctDragonMixv2_DNA_rep1_MergedSmallVariantsAnnotated.json.gz.jsi"]}' \
    '--custom-output-dir-entry={"copy_method":"copy_method","file_list":["/SdfLVG/var/lib/cwl/stg80f1ea23-73fd-4d1d-8739-3db9c101435f/0pt2pctDragonMixv2_DNA_rep1_Failed_Exon_coverage_QC.txt","/SdfLVG/var/lib/cwl/stgd48ad50b-7b59-4e5b-96b4-3d27825cd6d7/0pt2pctDragonMixv2_DNA_rep1.AlignCollapseFusionCaller_metrics.json.gz"]}' \
    '--custom-output-dir-entry={"copy_method":"copy_method","tarball":"/SdfLVG/var/lib/cwl/stg2dfd35aa-f1f9-44de-bdd1-5b29c4f6dff7/0pt2pctDragonMixv2_DNA_rep1.tar.gz"}' \
    '--custom-output-dir-entry={"copy_method":"copy_method","tarball":"/SdfLVG/var/lib/cwl/stgabc1fa11-b3b1-46b2-ab64-baab8eadfde7/0pt2pctDragonMixv2_DNA_rep1.tar.gz"}' \
    '--custom-output-dir-entry={"copy_method":"copy_method","tarball":"/SdfLVG/var/lib/cwl/stgc608e7c4-8447-481a-85cc-a0e7234b0570/0pt2pctDragonMixv2_DNA_rep1.tar.gz"}'

Looking at the 3rd mount argument:

$ ls -lsrthd /tmp/tmp.IylnrvsNFw/outputs/analysis_outputs/AlignCollapseFusionCaller/0pt2pctDragonMixv2_DNA_rep1
4.0K drwxr-xr-x 5 alexiswl alexiswl 4.0K Aug  3 10:38 /tmp/tmp.IylnrvsNFw/outputs/analysis_outputs/AlignCollapseFusionCaller/0pt2pctDragonMixv2_DNA_rep1

Looks fine to me,

However the output directory (even if its not used)

$ ls -lsrthd /tmp/6if0my13/var/lib/cwl/stgf373ef55-5da0-4f9d-98bc-80b9b425ec15/0pt2pctDragonMixv2_DNA_rep1
4.0K drwxr-xr-x 2 root root 4.0K Aug 10 17:05 /tmp/6if0my13/var/lib/cwl/stgf373ef55-5da0-4f9d-98bc-80b9b425ec15/0pt2pctDragonMixv2_DNA_rep1

I'm running docker version 20.10.7 on a WSL2 backend?

This causes the following error:

ERROR Exception while running job
Traceback (most recent call last):
  File "/home/alexiswl/anaconda3/envs/cwl-ica/lib/python3.8/site-packages/cwltool/job.py", line 404, in _execute
    relink_initialworkdir(
  File "/home/alexiswl/anaconda3/envs/cwl-ica/lib/python3.8/site-packages/cwltool/job.py", line 157, in relink_initialworkdir
    shutil.rmtree(host_outdir_tgt)
  File "/home/alexiswl/anaconda3/envs/cwl-ica/lib/python3.8/shutil.py", line 722, in rmtree
    onerror(os.rmdir, path, sys.exc_info())
  File "/home/alexiswl/anaconda3/envs/cwl-ica/lib/python3.8/shutil.py", line 720, in rmtree
    os.rmdir(path)
PermissionError: [Errno 13] Permission denied: '/tmp/6if0my13/var/lib/cwl/stgf373ef55-5da0-4f9d-98bc-80b9b425ec15/0pt2pctDragonMixv2_DNA_rep1'
WARNING [job create_output_directory] completed permanentFail
DEBUG [job create_output_directory] outputs {}
ERROR [step create_output_directory] Output is missing expected field file:///c/Users/awluc/OneDrive/GitHub/UMCCR/cwl-ica/workflows/tso500-ctdna-post-processing-pipeline/1.0.0/tso500-ctdna-post-processing-pipeline__1.0.0.cwl#tso500-ctdna-post-processing-pipeline--1.0.0/create_output_directory/output_directory
DEBUG [step create_output_directory] produced output {}
WARNING [step create_output_directory] completed permanentFail
INFO [workflow ] completed permanentFail
DEBUG [workflow ] outputs {
    "post_processing_output_directory": null
}
DEBUG [job create_output_directory] Removing input staging directory /tmp/0j14kt6s
DEBUG [job create_output_directory] Removing temporary directory /tmp/5prz__i8
{
    "post_processing_output_directory": null
}
WARNING Final process status is permanentFail

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

Successfully merging this pull request may close these issues.

Staging input files in a non-writable sub-directory fails on Linux
3 participants