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

Incorrect volume mapping in docker run for engines #1023

Open
viddagrava opened this issue Jun 9, 2021 · 7 comments
Open

Incorrect volume mapping in docker run for engines #1023

viddagrava opened this issue Jun 9, 2021 · 7 comments
Assignees

Comments

@viddagrava
Copy link

viddagrava commented Jun 9, 2021

Hey guys,
thanks a lot for the good work. Nonetheless, I believe there's an issue with how the wrapper runs the engines.
I am trying to run the container in a gitlab pipeline with the following:

code_quality:
  stage: test
  variables:
    NETWORK_MODE: host
  image:
    name: codeclimate/codeclimate
    entrypoint: ["/bin/ash", "-c"]
  script:
    - CODECLIMATE_DOCKER=1 CODECLIMATE_DEBUG=1 CODECLIMATE_CODE=/builds/<workspace>/<project>/ /usr/src/app/bin/codeclimate analyze

and this is the output I get:

$ CODECLIMATE_DOCKER=1 CODECLIMATE_DEBUG=1 CODECLIMATE_CODE=/builds/<workspace>/<project>/ /usr/src/app/bin/codeclimate analyze
I, [2021-06-09T09:27:28.492917 #9]  INFO -- : starting engine structure
D, [2021-06-09T09:27:28.496019 #9] DEBUG -- : /config.json content: {"enabled"=>true, "channel"=>"stable", "include_paths"=>["<file from repo>"], "debug"=>"1"}
D, [2021-06-09T09:27:28.504171 #9] DEBUG -- : docker run: ["docker", "run", "--name", "cc-engines-structure-stable-009c6e74-434d-44df-a7c6-aa577b45f33b", "--cap-drop", "all", "--label", "com.codeclimate.label=63ddc812-5acd-4d0e-a2f3-f334af8a660b", "--log-driver", "none", "--memory-swap", "-1", "--net", "none", "--rm", "--volume", "/builds/<workspace>/<project>/:/code:ro", "--volume", "/tmp/cc/18cfcc2e-704c-4334-9912-7525b306d2fc:/config.json:ro", "--user", "9000:9000", "--memory", "1024000000", "codeclimate/codeclimate-structure"]
D, [2021-06-09T09:27:28.780563 #9] DEBUG -- : engine stderr: 12
D, [2021-06-09T09:27:28.780684 #9] DEBUG -- : engine stderr: Parser process id: 12
D, [2021-06-09T09:27:28.781085 #9] DEBUG -- : engine stderr: codeclimate-parser socket not present
D, [2021-06-09T09:27:28.781149 #9] DEBUG -- : engine stderr: waiting 1s...
D, [2021-06-09T09:27:30.163807 #9] DEBUG -- : engine stderr: bin/structure:21:in `read': Is a directory @ io_fread - /config.json (Errno::EISDIR)
D, [2021-06-09T09:27:30.163935 #9] DEBUG -- : engine stderr: 	from bin/structure:21:in `<main>'
I, [2021-06-09T09:27:30.260833 #9]  INFO -- : finished engine structure`

why is the tmp folder path mapped to config.json (/tmp/cc/18cfcc2e-704c-4334-9912-7525b306d2fc:/config.json:ro)?

I guess the problem lies here (codeclimate/lib/cc/analyzer/engine.rb: line 76-92):
especially line 85:
"--volume", "#{config_file.host_path}:/config.json:ro",

Thanks in advance.
David

@filipesperandio
Copy link
Contributor

Hi @viddagrava,

I think it is possible that we might be having a mismatch when passing a CODECLIMATE_CODE env var that is different from $PWD. The most common cases for running analysis is to trigger them from the current directory can I suggest an easy fix for this being a change on how you invoke the tool?
Please, try:

cd /builds/<workspace>/<project> && CODECLIMATE_DOCKER=1 CODECLIMATE_DEBUG=1  /usr/src/app/bin/codeclimate analyze

@viddagrava
Copy link
Author

Hey @filipesperandio,

Thanks a lot for your fast reply, I already tried it, and unfortunately it does not help. Same error and with my very little understanding I don't think the $PWD has an impact on that seemingly incorrect volume mapping, nonetheless, I have to say locally on Docker for Mac it works...

@Spaider
Copy link

Spaider commented Jul 26, 2021

@filipesperandio looks like the reason and workaround you gave is not working. Must be something else.

@cmdjulian
Copy link

I'm facing the same issue regarding gitlab ci, any news so far?

@filipesperandio
Copy link
Contributor

Ugh, not so fast follow up, sorry.

Do you all still see the same errors? Even if you drop the CODECLIMATE_CODE env var in favor of doing a cd ... before triggering it?
The other thing I can think of is if Docker doesn't have access to the directory where the code you are trying to analyze lives.
Could you post up-to-date logs of the errors you see and the commands you invoke?

@schusplunk
Copy link

Any news for this?
I am seeing same on gitlab ci on 0.96.0 version

@schusplunk
Copy link

commands I invoked: CODECLIMATE_DOCKER=1 CODECLIMATE_DEBUG=1 CODECLIMATE_CODE=${CI_PROJECT_DIR} codeclimate analyze

issue: in read': Is a directory @ io_fread - /config.json`

logs:
I, [2023-12-16T01:41:46.216433 #105] INFO -- : starting engine structure
D, [2023-12-16T01:41:46.507421 #105] DEBUG -- : /config.json content: {"enabled"=>true, "channel"=>"stable", "include_paths"=>[""], "debug"=>"1"}
...
"com.codeclimate.label=96229067-914d-49fb-9c78-be513f4cc058", "--log-driver", "none", "--memory-swap", "-1", "--net", "none", "--rm", "--volume", "/builds/phantom/phantom:/code:ro", "--volume", "/tmp/cc/635e1484-c681-4a5f-a68f-061ac47f309a:/config.json:ro", "--user", "9000:9000", "--memory", "1024000000", "xxx"]
Starting analysis
D, [2023-12-16T01:42:09.930853 #105] DEBUG -- : engine stderr: 12
D, [2023-12-16T01:42:09.930972 #105] DEBUG -- : engine stderr: Parser process id: 12
D, [2023-12-16T01:42:09.931382 #105] DEBUG -- : engine stderr: codeclimate-parser socket not present
engine stderr: waiting 1s...
D, [2023-12-16T01:42:11.047854 #105] DEBUG -- : engine stderr: /home/app/.rubies/ruby-3.1.4/lib/ruby/gems/3.1.0/gems/bundler-1.16.4/lib/bundler/shared_helpers.rb:29: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2.
D, [2023-12-16T01:42:11.047998 #105] DEBUG -- : engine stderr: /home/app/.rubies/ruby-3.1.4/lib/ruby/gems/3.1.0/gems/bundler-1.16.4/lib/bundler/shared_helpers.rb:118: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2.
D, [2023-12-16T01:42:11.048708 #105] DEBUG -- : engine stderr: /home/app/.rubies/ruby-3.1.4/lib/ruby/gems/3.1.0/gems/bundler-1.16.4/lib/bundler/shared_helpers.rb:118: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2.
D, [2023-12-16T01:42:11.060978 #105] DEBUG -- : engine stderr: /home/app/.rubies/ruby-3.1.4/lib/ruby/gems/3.1.0/gems/bundler-1.16.4/lib/bundler/shared_helpers.rb:35: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2.
D, [2023-12-16T01:42:11.061078 #105] DEBUG -- : engine stderr: /home/app/.rubies/ruby-3.1.4/lib/ruby/gems/3.1.0/gems/bundler-1.16.4/lib/bundler/shared_helpers.rb:35: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2.
D, [2023-12-16T01:42:11.061122 #105] DEBUG -- : engine stderr: /home/app/.rubies/ruby-3.1.4/lib/ruby/gems/3.1.0/gems/bundler-1.16.4/lib/bundler/shared_helpers.rb:44: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2.
D, [2023-12-16T01:42:11.067197 #105] DEBUG -- : engine stderr: /home/app/.rubies/ruby-3.1.4/lib/ruby/gems/3.1.0/gems/bundler-1.16.4/lib/bundler/shared_helpers.rb:118: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2.
D, [2023-12-16T01:42:11.376227 #105] DEBUG -- : engine stderr: bin/structure:21:in read': Is a directory @ io_fread - /config.json (Errno::EISDIR) D, [2023-12-16T01:42:11.376313 #105] DEBUG -- : engine stderr: from bin/structure:21:in

'
I, [2023-12-16T01:42:11.488330 #105] INFO -- : finished engine structure
error: (CC::CLI::Analyze::EngineFailure) engine structure failed with status 1 and stderr
12
Parser process id: 12
codeclimate-parser socket not present
waiting 1s...
/home/app/.rubies/ruby-3.1.4/lib/ruby/gems/3.1.0/gems/bundler-1.16.4/lib/bundler/shared_helpers.rb:29: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2.
/home/app/.rubies/ruby-3.1.4/lib/ruby/gems/3.1.0/gems/bundler-1.16.4/lib/bundler/shared_helpers.rb:118: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2.
/home/app/.rubies/ruby-3.1.4/lib/ruby/gems/3.1.0/gems/bundler-1.16.4/lib/bundler/shared_helpers.rb:118: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2.
/home/app/.rubies/ruby-3.1.4/lib/ruby/gems/3.1.0/gems/bundler-1.16.4/lib/bundler/shared_helpers.rb:35: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2.
/home/app/.rubies/ruby-3.1.4/lib/ruby/gems/3.1.0/gems/bundler-1.16.4/lib/bundler/shared_helpers.rb:35: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2.
/home/app/.rubies/ruby-3.1.4/lib/ruby/gems/3.1.0/gems/bundler-1.16.4/lib/bundler/shared_helpers.rb:44: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2.
/home/app/.rubies/ruby-3.1.4/lib/ruby/gems/3.1.0/gems/bundler-1.16.4/lib/bundler/shared_helpers.rb:118: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2.
bin/structure:21:in read': Is a directory @ io_fread - /config.json (Errno::EISDIR) from bin/structure:21:in '
...
/usr/src/app/lib/cc/analyzer/raising_container_listener.rb:23: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/plain_text_formatter.rb:63:in with_spinner'
/usr/src/app/lib/cc/analyzer/formatters/plain_text_formatter.rb:41:in block in engine_running' /usr/src/app/lib/cc/analyzer/formatters/formatter.rb:31:in engine_running'
/usr/src/app/lib/cc/analyzer/formatters/plain_text_formatter.rb:40: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 `'

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

No branches or pull requests

5 participants