Don't count image downloading time towards engine timeout
Error Message
error: (CC::CLI::Analyze::EngineFailure) engine structure ran for 900 seconds and was killed
Description
I am getting consistently a timeout after 900 seconds of running codeclimate cli locally. Seems like it's attempting to download a HUGE collection of docker images, and times out because of this.
I installed the app locally from the brew tap indicated on README.md of this repo.
What is the expected behavior? Should I also manually install those images? Might run out of disk space tho... seems a bit strange.
Thanks! :)
Questions
- Is this an issue with codeclimate.com?
Nope, using codeclimate CLI
- Is this an issue with a specific engine?
Nope, using defaults
- Is this an issue with your Docker installation in general?
Nope, Docker looks happy
- Are you invoking
docker run codeclimate/codeclimatewithout other options?
No
- Are you having trouble using this project as a gem or not via Docker?
No
- Make sure your problem exists in the latest version of the CLI and any engines you're using, the following commands will update everything:
followed the steps, running latest and greatest
Reproduce
- Include the exact command you're running
CODECLIMATE_DEBUG=1 codeclimate analyze -f html > codeclimate.html
- and its complete output
I, [2018-09-04T11:51:19.712323 #1] INFO -- : starting engine structure
D, [2018-09-04T11:51:19.751383 #1] DEBUG -- : /config.json content: {"enabled"=>true, "channel"=>"stable", "include_paths"=>["migrations/", "nodemon.json", "CHANGELOG.md", "Dockerfile", "knexfile.js", "README.md", ".gitignore", "seeds/", ".prettierrc", ".eslintrc.js", "docker-compose.yml", "codeclimate.html", ".gitlab-ci.yml", "build/", ".env.example", ".flowconfig", "data/", ".codeclimate.yml", "src/"], "debug"=>"1"}
D, [2018-09-04T11:51:19.760459 #1] DEBUG -- : docker run: ["docker", "run", "--name", "cc-engines-structure-stable-aa3d9509-f4ee-43fd-a5e3-6cf16bce17c4", "--cap-drop", "all", "--label", "com.codeclimate.label=43032f74-4007-42b2-90fa-4f35ea1487f8", "--log-driver", "none", "--memory-swap", "-1", "--net", "none", "--rm", "--volume", "/Users/mati/Projects/kyc-provider-api:/code:ro", "--volume", "/tmp/cc/901a7814-090c-4303-819b-94b0756bb059:/config.json:ro", "--user", "9000:9000", "--memory", "1024000000", "codeclimate/codeclimate-structure"]
D, [2018-09-04T11:51:19.776825 #1] DEBUG -- : engine stderr: Unable to find image 'codeclimate/codeclimate-structure:latest' locally
D, [2018-09-04T11:51:21.690526 #1] DEBUG -- : engine stderr: latest: Pulling from codeclimate/codeclimate-structure
[attempts to download a loooooooooooooooooooong list of images]
[which obviously times out]
error: (CC::CLI::Analyze::EngineFailure) engine structure ran for 900 seconds and was killed
D, [2018-09-04T12:35:26.214527 #1] DEBUG -- : backtrace: /usr/src/app/lib/cc/analyzer/raising_container_listener.rb:14:in `finished'
/usr/src/app/lib/cc/analyzer/composite_container_listener.rb:13:in `block in finished'
/usr/src/app/lib/cc/analyzer/composite_container_listener.rb:13:in `each'
/usr/src/app/lib/cc/analyzer/composite_container_listener.rb:13:in `finished'
/usr/src/app/lib/cc/analyzer/bridge.rb:52:in `block (2 levels) in run'
/usr/src/app/lib/cc/analyzer/formatters/formatter.rb:31:in `engine_running'
/usr/src/app/lib/cc/analyzer/bridge.rb:37:in `block in run'
/usr/src/app/lib/cc/analyzer/bridge.rb:34:in `each'
/usr/src/app/lib/cc/analyzer/bridge.rb:34:in `run'
/usr/src/app/lib/cc/cli/analyze.rb:36:in `run'
/usr/src/app/lib/cc/cli/command.rb:73:in `execute'
/usr/src/app/lib/cc/cli/runner.rb:25:in `run'
/usr/src/app/lib/cc/cli/runner.rb:9:in `run'
/usr/src/app/bin/codeclimate:12:in `<main>'
- Indicate what you expected to happen and what happened instead
Expected: Analysis to run and be captured in a nicely formatted html file. Received: timeout :s
- Include your operating system, how you run Docker (e.g. Docker Machine) and the version of Docker you're using.
Mac OS High Sierra 10.13.6, Docker mac client
- Include the output of the following commands:
>>> uname -a
Darwin Matis-MBP.fritz.box 17.7.0 Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64
>>> docker version
Client:
Version: 18.06.1-ce
API version: 1.38
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:21:31 2018
OS/Arch: darwin/amd64
Experimental: false
Server:
Engine:
Version: 18.06.1-ce
API version: 1.38 (minimum version 1.12)
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:29:02 2018
OS/Arch: linux/amd64
Experimental: true
>>>env | grep "^DOCKER_"
Hi @sombreroEnPuntas,
Can you please try running codeclimate engines:install and then run your analyze command? engines:install pulls necessary docker images based on your config.
analyze will also pull docker images if they're not locally available, and it's unusual for it to be very slow, but if your internet connection isn't that fast it could cause a timeout since the analyze timeout code isn't optimized for this case and doesn't count the pull separately from everything else. engines:install does not have any timeouts aside from whatever docker pull does natively.
Hola @wfleming :) Thanks for the fast answer!
I understand this, but I would still consider it a bug.
Options to fix it would be:
- exclude
installstep from the timeout count, or even give it a separate count ⌛️ - optimize the
installstep, since it downloads a HUGE amount of files (even for a decent internet speed this is not good, and it will consume a lot of disk space anyway) and probably not all of them are needed or could be replaced by lighter "task targeted" versions.
For reference, this is the output of running codeclimate engines:install.
It seems to be too much.
Pulling docker images.
Using default tag: latest
latest: Pulling from codeclimate/codeclimate-structure
be8881be8156: Pulling fs layer
a3ed95caeb02: Pulling fs layer
b48068135ee8: Pulling fs layer
ae1b55f024b1: Pulling fs layer
ae1b55f024b1: Waiting
b41b6f1b5443: Pulling fs layer
73ad1c73069a: Pulling fs layer
bd3c952a7b55: Waiting
517f8d87afc0: Waiting
3b15e5686eca: Waiting
56c8a1afb315: Waiting
bedabba02a0e: Pull complete
cd72d8af5337: Pull complete
d30dbe85d092: Pull complete
85c3a26ee90a: Pull complete
011f46571a10: Pull complete
104c61d9bed9: Pull complete
0d7eb82823b0: Pull complete
47dec36717ad: Pull complete
938170e51a64: Pull complete
13323a75a80f: Pull complete
211e9bbfbe79: Pull complete
1d7a2a2b862a: Pull complete
169151d4490c: Pull complete
c2df740cb5e8: Pull complete
e5e7289c0972: Pull complete
51171b5718a3: Pull complete
e7f362e29f5b: Pull complete
76a0a48d0e5e: Pull complete
ec8af605c2b3: Pull complete
19c5c6a478e9: Pull complete
8c492be2e9f1: Pull complete
23cd489384fd: Pull complete
0775f16515c8: Pull complete
9f8ffdaad99c: Pull complete
d1bf773c1252: Pull complete
35ff3cd56458: Pull complete
437c75bc42f3: Pull complete
0417bfa73343: Pull complete
fcad30c8bfc5: Pull complete
d11a8cd3f0b9: Pull complete
8249bc0574ed: Pull complete
fddd70d15521: Pull complete
9a11cfd100c5: Pull complete
cc6cc5881bea: Pull complete
2323c8e1d206: Pull complete
b09678e77c1c: Pull complete
06a1845f5639: Pull complete
Digest: sha256:0ba4718a89c002ea7310e12b553e50a103d3c87c18d7e77a995d52e604725dbd
Status: Downloaded newer image for codeclimate/codeclimate-structure:latest
Using default tag: latest
latest: Pulling from codeclimate/codeclimate-duplication
be8881be8156: Already exists
a3ed95caeb02: Pulling fs layer
b48068135ee8: Pulling fs layer
ae1b55f024b1: Pulling fs layer
6f740d0522ac: Pulling fs layer
b41b6f1b5443: Pulling fs layer
73ad1c73069a: Pulling fs layer
bd3c952a7b55: Pulling fs layer
517f8d87afc0: Pulling fs layer
3b15e5686eca: Pulling fs layer
56c8a1afb315: Pulling fs layer
bedabba02a0e: Pulling fs layer
cd72d8af5337: Pulling fs layer
ae1b55f024b1: Downloading [==================================> ] 840.9MB/1.234GB
85c3a26ee90a: Download complete
011f46571a10: Download complete
104c61d9bed9: Download complete
0d7eb82823b0: Download complete
47dec36717ad: Download complete
938170e51a64: Download complete
13323a75a80f: Download complete
211e9bbfbe79: Download complete
1d7a2a2b862a: Download complete
169151d4490c: Download complete
c2df740cb5e8: Download complete
e5e7289c0972: Download complete
51171b5718a3: Download complete
e7f362e29f5b: Download complete
76a0a48d0e5e: Download complete
ec8af605c2b3: Download complete
19c5c6a478e9: Download complete
8c492be2e9f1: Download complete
23cd489384fd: Download complete
0775f16515c8: Download complete
9f8ffdaad99c: Download complete
d1bf773c1252: Download complete
35ff3cd56458: Download complete
437c75bc42f3: Download complete
0417bfa73343: Download complete
fcad30c8bfc5: Download complete
d11a8cd3f0b9: Download complete
8249bc0574ed: Download complete
fddd70d15521: Download complete
9a11cfd100c5: Download complete
b0d6738c29d9: Download complete
18bb9101aad7: Download complete
568bf39d97ae: Download complete
c060345f2354: Download complete
4bb3fc9a399d: Download complete
3e614cf707f5: Download complete
The structure & duplication engines are unfortunately fairly large right now because they package up the parsers for every language we support. Splitting them by language is something we'd like to do, but it's not on our immediate roadmap. We realize this is sub-optimal but we do not consider it a bug.
If you'd like to open a PR changing the timeout to not apply to the pull when it's necessary, I'd be happy to review it.
Does running engines:install allow you to run analyze successfully? We do recommend that users run engines:install directly as a general principle since analyze will never install updates to engines, while running engines:install occasionally will ensure you're running the most recent versions of analysis.
Hmmm... that is two bugs (feature requests if bug is not cool) then:
- current timeout too short for a HUGE amount of files to download; consider excluding the download step from timeout, or completely remove the step and require installation as a separate task
- not checking for updates on start-up; consider adding this check either to install step or as part of a separate install task
If I get some free time I'll try to send a PR. Thanks anyway! :D
FWIW, I also encountered this and would like codeclimate analyze to ignore downloading the images in the timeout calculations.
The path I took as a user was:
- Notice I had a codeclimate failure in GitHub
- Download and install with
brew - Run
codeclimate analyze - Spend way too long trying to figure out why it was taking "forever" to run
- Eventually find debug flag
- Rerun
analyzeevery 15 minutes because it kept timing out - Find this issue and realize I need to run
engines:install
Encountered this same problem today when running codeclimate analyze without debug flag. Wondering why it takes so long to run without any output. After few minutes it outputs timeout. I kinda feel that I would not know that I need to run codeclimate engines:install prior to analyze if I didn't find this issue. Maybe you should include this into README?
I came across this as well. Just updating the readme will be helpful for 95% of people.
FYI: In case you're using docker, codeclimate/codeclimate-structure image might be downloaded. It is 2 GB in size.
@skarpushin @wfleming
Sorry if this is a stupid question (docker related), but I run codeclimate with one line of docker run:
sudo docker run --env CODECLIMATE_DEBUG=1 --env CODECLIMATE_CODE="$PWD"
--volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock
--volume /tmp/cc:/tmp/cc codeclimate/codeclimate:latest analyze -f html > report.html
How would I add the codeclimate engines:install command to this sequence? If I replace the analyze command with the install command, then a different container is launched. Am I supposed to run the install command first with docker run and then re-enter the same container and run the analyze command next?
Any solution for this? Every analyze I need to download all images and they are huge(more than 5gb)...