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

Upload cylc-run artifact on test fail. #3939

Merged
merged 1 commit into from
Nov 13, 2020
Merged

Conversation

hjoliver
Copy link
Member

@hjoliver hjoliver commented Nov 12, 2020

@oliver-sanders this just adds an artifact upload section to the bash test config. Hoping it'll allow us to diagnose the broadcast/00-simple test problem. See comments from here: #3933 (comment) The change looks simple but all I did was copy your section from the other file, so you'd best check it.

[UPDATE: now for bash and main functional test actions]

@hjoliver hjoliver added this to the cylc-8.0a3 milestone Nov 12, 2020
@hjoliver hjoliver self-assigned this Nov 12, 2020
Copy link
Member

@kinow kinow left a comment

Choose a reason for hiding this comment

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

Nice! 🤓 wasn't aware of the upload-artifact action, #TIL

@hjoliver
Copy link
Member Author

Well this test failed here 🎉

But no artifact uploaded 😢

Warning: No files were found with the provided path: cylc-run. No artifacts will be uploaded.

uses: actions/upload-artifact@v2
with:
name: cylc-run
path: cylc-run
Copy link
Member

Choose a reason for hiding this comment

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

@hjoliver I think path is relative to where the action is running. In the log lines next to the error uploading file in the last run, we have

Test Summary Report
-------------------
tests/functional/broadcast/00-simple.t              (Wstat: 0 Tests: 5 Failed: 4)
  Failed tests:  2-5

I think tests/functional/broadcast/00-simple.t is relative to the working directory of the action. So the cylc-run would be probably somewhere like /root/cylc-run/ (from the error log line suite logs can be found under: /root/cylc-run/cylctb-20201112T101740Z/functional/broadcast/00-simple/log/suite/).

WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

Ah yes, this functionality hadn't been tested, yet.

Yes, my bad, looks like it's a relative path so ~/cylc-run, /root/cylc-run or possibly ../cylc-run.

@hjoliver
Copy link
Member Author

Run actions/upload-artifact@v2
  with:
    name: Upload cylc-run artifact
    path: /root/cylc-run
    if-no-files-found: warn
Error: EACCES: permission denied, lstat '/root/cylc-run'

@kinow
Copy link
Member

kinow commented Nov 12, 2020

Run actions/upload-artifact@v2
  with:
    name: Upload cylc-run artifact
    path: /root/cylc-run
    if-no-files-found: warn
Error: EACCES: permission denied, lstat '/root/cylc-run'

actions/upload-artifact#130

Maybe for now we just cp /root/cylc-flow /elsewhere followed by chmod 0777 /elsewhere? Then upload from /elsewhere instead?

@hjoliver
Copy link
Member Author

actions/upload-artifact#130

@kinow
Copy link
Member

kinow commented Nov 12, 2020

Warning: No files were found with the provided path: cylc-run. No artifacts will be uploaded.

😥 this issue is giving some trouble to fix. I bet it will be something really simple, a one-liner fix somewhere in our code base. A typical Friday 🐛 haha

@hjoliver
Copy link
Member Author

Yeah I don't think my cp -r command at the end of the Run step is being executed. If there are multiple commands and one fails, does the stop abort?

@kinow
Copy link
Member

kinow commented Nov 12, 2020

Yeah I don't think my cp -r command at the end of the Run step is being executed. If there are multiple commands and one fails, does the stop abort?

I think so. Maybe

tests/functional/broadcast/00-simple.t \
  & cp -r /root/cylc-run cylc-run

?

(ah, just saw your last commit defining the working directory 👍 )

@hjoliver
Copy link
Member Author

Ah, I screwed up the docker exec for cp command, and got this:

Error: No such container: cp
So I know it is being executed; trying again...

@hjoliver
Copy link
Member Author

Still no joy.

Ah, it's probably because the tests run inside a Docker container, but the Upload step doesn't.

@kinow
Copy link
Member

kinow commented Nov 12, 2020

Still no joy.

Ah, it's probably because the tests run inside a Docker container, but the Upload step doesn't.

I think you are right. But in that case you can just drop the docker exec.

The container has a volume mounted on /root/cylc-flow. The /root/cylc-flow inside the container, is actually the GitHub action clone of cylc-flow directory.

I think we just need to adjust the permissions, and try to upload it (files created by Docker are created as root). What about this one @hjoliver ?

docker exec -w /root/cylc-flow bash tar -zcvf cylc-run.tar.gz /root/cylc-run

I think that would tar the /root/cylc-run directory inside /root/cylc-flow/cylc-run.tar.gz. Then in the upload you could just tell it to upload cylc-run.tar.gz (I think a single file being uploaded might be faster, but never used that upload artifact action)

@hjoliver
Copy link
Member Author

My latest failure attempts to use docker cp to copy cylc-run out of the container:

   run: |                                                                                                                                                                                                     
          docker exec -w /root/cylc-flow bash \                                                                                                                                                                    
            ./etc/bin/run-functional-tests -v \                                                                                                                                                                    
            tests/functional/broadcast/00-simple.t                                                                                                                                                                 
          docker cp bash:/root/cylc-run .         

But the upload step still doesn't find cylc-run.

I thought that would work 😖 I'll try what you suggested now...

@hjoliver
Copy link
Member Author

But there's no evidence in the log that the docker cp command ran, weirdly.

@hjoliver hjoliver force-pushed the bash-test-upload branch 3 times, most recently from 50c44b0 to 8a1e177 Compare November 12, 2020 22:41
@kinow
Copy link
Member

kinow commented Nov 12, 2020

Yup, no way of copying a file out of the container in Docker (that I am aware of). That's normally done via mounted volumes. That was one of the things that took me a while to get used with Singularity.

@hjoliver
Copy link
Member Author

Yup, no way of copying a file out of the container in Docker (that I am aware of). That's normally done via mounted volumes. That was one of the things that took me a while to get used with Singularity.

No, there is! I tried it locally and it worked.

$ docker cp --help

Usage:  docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
        docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH

Copy files/folders between a container and the local filesystem

Use '-' as the source to read a tar archive from stdin
and extract it to a directory destination in a container.
Use '-' as the destination to stream a tar archive of a
container source to stdout.

Options:
  -a, --archive       Archive mode (copy all uid/gid information)
  -L, --follow-link   Always follow symbol link in SRC_PATH

@hjoliver
Copy link
Member Author

🎉 😂

Copy cylc-run out of container:

Run docker cp bash:/root/cylc-run .
  docker cp bash:/root/cylc-run .
  shell: /bin/bash -e {0}
1s

Upload

Run actions/upload-artifact@v2
With the provided path, there will be 23 file(s) uploaded
Total size of all the files uploaded is 23409 bytes
Finished uploading artifact Upload cylc-run artifact. Reported size is 23409 bytes. There were 0 items that failed to upload
Artifact Upload cylc-run artifact has been successfully uploaded!

@oliver-sanders
Copy link
Member

oliver-sanders commented Nov 12, 2020

If really stuck you could try sharing the cylc-run directory with the container to avoid having to copy stuff back.

'-v' "$HOME/cylc-run:/root/cylc-run"

@hjoliver
Copy link
Member Author

Not stuck, I just got it working (although your way might be a bit more efficient).

@hjoliver hjoliver changed the title Upload artifact on bash tests. Upload cylc-run artifact on test fail. Nov 12, 2020
@kinow
Copy link
Member

kinow commented Nov 12, 2020

And #TIL about the docker cp. I've always mapped volumes to have access to the files of containers. No idea why I never learned about this command! Thanks @hjoliver !

@hjoliver
Copy link
Member Author

@kinow - tests all passed, and I've verified that artifact upload works now. One review should do on this; if you agree, maybe you could merge this we can start using it to diagnose test failures better.

@hjoliver
Copy link
Member Author

(Follow up improvement might be to use a mapped volume instead of docker cp, but I don't think it matters much).

@kinow kinow merged commit a1bf8d4 into cylc:master Nov 13, 2020
@hjoliver hjoliver deleted the bash-test-upload branch November 13, 2020 01:38
oliver-sanders added a commit to oliver-sanders/cylc-flow that referenced this pull request Dec 30, 2020
oliver-sanders added a commit to oliver-sanders/cylc-flow that referenced this pull request Dec 30, 2020
oliver-sanders added a commit to oliver-sanders/cylc-flow that referenced this pull request Dec 30, 2020
@hjoliver hjoliver modified the milestones: cylc-8.0a3, cylc-8.0b0 Feb 25, 2021
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.

3 participants