Docker Container running out of memory

Template for a good new topic, formatted with Markdown:

  • Bitbucket Cloud
  • Scanner command used when applicable (private details masked)
  • Languages of the repository - PHP / JS
  • Error observed Docker out of memory
  • Steps to reproduce - as this is a private paid build - I can do it on demand but no public link

Using a 2x size for bit bucket (the largest available container) I still can’t get the build to run

Hi @ScottDutton, welcome to the community and thanks for posting!

An approach you may want to take is see if you can isolate one (or more) specific files that cause the analyzer to be stuck. Do you have any very large source file(s) in your project that stands out?

With that in mind you may want to exclude files or directories from the analysis until a culprit is isolated. See how to do this here.

Other than this, can you share specifics of your configuration that could help (e.g. scanner commands and outputs)?

2 Likes

See below for full output. I will exclude that file but its not a really big file

0b76c14080f1: Pulling fs layer
bf36e4ed36b8: Pulling fs layer
471f55e1f2b3: Pulling fs layer
71259b000269: Pulling fs layer
aa8c7fc6fdc0: Pulling fs layer
67c4e741e688: Waiting
783178df3a0c: Waiting
0684138f4cb6: Waiting
0b76c14080f1: Waiting
471f55e1f2b3: Waiting
bf36e4ed36b8: Waiting
71259b000269: Waiting
aa8c7fc6fdc0: Waiting
16d944e3d00d: Verifying Checksum
16d944e3d00d: Download complete
6aaf465b8930: Verifying Checksum
6aaf465b8930: Download complete
0684138f4cb6: Verifying Checksum
0684138f4cb6: Download complete
67c4e741e688: Download complete
27833a3ba0a5: Verifying Checksum
27833a3ba0a5: Download complete
bf36e4ed36b8: Verifying Checksum
bf36e4ed36b8: Download complete
0b76c14080f1: Verifying Checksum
0b76c14080f1: Download complete
71259b000269: Verifying Checksum
71259b000269: Download complete
27833a3ba0a5: Pull complete
16d944e3d00d: Pull complete
6aaf465b8930: Pull complete
aa8c7fc6fdc0: Verifying Checksum
aa8c7fc6fdc0: Download complete
471f55e1f2b3: Verifying Checksum
0684138f4cb6: Pull complete
783178df3a0c: Verifying Checksum
783178df3a0c: Download complete
67c4e741e688: Pull complete
783178df3a0c: Pull complete
0b76c14080f1: Pull complete
bf36e4ed36b8: Pull complete
471f55e1f2b3: Pull complete
71259b000269: Pull complete
aa8c7fc6fdc0: Pull complete
Digest: sha256:214dffb67340385ff0d251868f71a72f18e2fb92822b7d770ed50068c2a641d2
Status: Downloaded newer image for sonarsource/sonarcloud-scan:1.2.1
INFO: Scanner configuration file: /opt/sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarScanner 4.4.0.2170
INFO: Java 11.0.2 Oracle Corporation (64-bit)
INFO: Linux 5.4.92-flatcar amd64
INFO: Bitbucket Cloud Pipelines detected
INFO: User cache: /root/.sonar/cache
INFO: Scanner configuration file: /opt/sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: Analyzing on SonarQube server 8.8.0
INFO: Default locale: "en", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=568ms
INFO: Server id: 1BD809FA-AWHW8ct9-T_TB3XqouNu
INFO: User cache: /root/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=136ms
INFO: Load/download plugins (done) | time=25845ms
INFO: Loaded core extensions: developer-scanner
INFO: JavaScript/TypeScript frontend is enabled
INFO: Found an active CI vendor: 'Bitbucket Pipelines'
INFO: Detected project key 'sykescottagesltd_kepler' from 'Bitbucket Cloud Pipelines'
INFO: Detected organization key 'sykescottagesltd' from 'Bitbucket Cloud Pipelines'
INFO: Load project settings for component key: 'sykescottagesltd_kepler'
INFO: Load project settings for component key: 'sykescottagesltd_kepler' (done) | time=116ms
INFO: Process project properties
INFO: Execute project builders
INFO: Execute project builders (done) | time=1ms
INFO: Project key: sykescottagesltd_kepler
INFO: Base dir: /opt/atlassian/pipelines/agent/build
INFO: Working dir: /opt/atlassian/pipelines/agent/build/.scannerwork
INFO: Load project branches
INFO: Load project branches (done) | time=106ms
INFO: Check ALM binding of project 'sykescottagesltd_kepler'
INFO: Detected project binding: BOUND
INFO: Check ALM binding of project 'sykescottagesltd_kepler' (done) | time=102ms
INFO: Load project pull requests
INFO: Load project pull requests (done) | time=103ms
INFO: Load branch configuration
INFO: Detected analysis for branch 'feature/KEP-16785-add-in-sonarsource'
INFO: Auto-configuring branch feature/KEP-16785-add-in-sonarsource
INFO: Load branch configuration (done) | time=3ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=161ms
INFO: Load active rules
INFO: Load active rules (done) | time=3110ms
INFO: Organization key: sykescottagesltd
INFO: Branch name: feature/KEP-16785-add-in-sonarsource, type: short-lived
INFO: SCM collecting changed files in the branch
WARN: Could not find ref: master in refs/heads, refs/remotes/upstream or refs/remotes/origin
INFO: SCM collecting changed files in the branch (done) | time=157ms
INFO: Indexing files...
INFO: Project configuration:
INFO: Load project repositories
INFO: Load project repositories (done) | time=104ms
WARN: Invalid character encountered in file /opt/atlassian/pipelines/agent/build/public/contract/helpers/loaders.php at line 17 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
INFO: 13383 files indexed
INFO: 4 files ignored because of scm ignore settings
INFO: Quality profile for css: Sonar way
INFO: Quality profile for js: Sonar way
INFO: Quality profile for php: Sonar way
INFO: Quality profile for plsql: Sonar way
INFO: Quality profile for py: Sonar way
INFO: Quality profile for ruby: Sonar way
INFO: Quality profile for ts: Sonar way
INFO: Quality profile for web: Sonar way
INFO: Quality profile for xml: Sonar way
INFO: ------------- Run sensors on module sykescottagesltd_kepler
INFO: JavaScript/TypeScript frontend is enabled
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=105ms
INFO: Sensor CSS Metrics [cssfamily]
INFO: Sensor CSS Metrics [cssfamily] (done) | time=4326ms
INFO: Sensor CSS Rules [cssfamily]
INFO: 6445 source files to be analyzed
ERROR: Failed to parse file:///opt/atlassian/pipelines/agent/build/public/assets/static/dog-walking-guide/css/main.css, line 49, Unknown word
ERROR: Failed to parse file:///opt/atlassian/pipelines/agent/build/public/css/sass/sykes/letyourcottage/components/_cards.scss, line 20, Unclosed bracket
INFO: 1887/6445 files analyzed, current file: public/css/sass/white_label/mobile/_owner.scss
INFO: 3964/6445 files analyzed, current file: application/libraries/CopernicusV2/ResultsProcessors/Bachcare/BachcareLocationUrlsResultProcessor.php
WARN: Invalid character encountered in file /opt/atlassian/pipelines/agent/build/public/assets/static/fairytale/life-size-gingerbread-house.html at line 288 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
INFO: 6256/6445 files analyzed, current file: application/experiments/homepage/marketingstatement11352.php
INFO: 6445/6445 source files have been analyzed
INFO: Sensor CSS Rules [cssfamily] (done) | time=31790ms
INFO: Sensor PL/SQL Sensor [plsql]
WARN: The Data Dictionary is not configured for PLSQL analyzer which prevents rule(s) S3641, S3921, S3618, S3651 to raise issues. See https://sonarcloud.io/documentation/analysis/languages/plsql/
INFO: 2 source files to be analyzed
INFO: 0/2 files analyzed so far, currently analyzing: /opt/atlassian/pipelines/agent/build/sql/aristotle.sql
INFO: 0/2 files analyzed so far, currently analyzing: /opt/atlassian/pipelines/agent/build/sql/aristotle.sql
INFO: 0/2 files analyzed so far, currently analyzing: /opt/atlassian/pipelines/agent/build/sql/aristotle.sql
INFO: 0/2 files analyzed so far, currently analyzing: /opt/atlassian/pipelines/agent/build/sql/aristotle.sql
time="2021-05-23T04:52:56Z" level=error msg="error waiting for container: unexpected EOF"

Ive restricted a lot of files now and its still happening. I’m not sure we can realistic restrict much further. We used to run Rips which didnt have these issues, is there a mode to run a similar way to rips ?

Hi @ScottDutton,

I can see as well that the last message you shared is SQL related (aristotle.sql) - did you check this file and tried excluding it?

If that does not help, I would recommend insisting on narrowing down and isolating the culprit. For instance, were you able to the the PHP or the Javascript analysis to complete by excluding one of those languages?

1 Like

Yeah that one was excluded, it got further, repeated that until we got to the PHP section and its still failing, I cant really exclude anymore

What happens if you exclude all PHP files; do you succeed in getting the JS analyzed. What about the opposite?

Hi @ScottDutton ,

You may want to look into this thread, which might be a similar case to yours.

Essentially, it is possible that you don’t benefit from the 2x size container you picked and may have to explicitely grant it the amount of memory it deserves.

Let me know

INFO: High simulation costs for sink in /opt/atlassian/pipelines/agent/build/application/libraries/PDFMerger/fpdf/fpdf.php:271. Stop analysing this sink.
/usr/bin/run-scanner.sh: line 24:    11 Killed                  sonar-scanner "${ALL_ARGS[@]}" 2>&1
        12 Done                    | tee "${SCANNER_REPORT}"
✖ SonarCloud analysis failed.

It gets much further now, That setting makes the whole build cost more also, given we are already paying for the SaaS is there any option to use a hosted runner which would solve both issues here ?

Excluding that file and bumping the memory to 4096MB allows the build to run. So its working but way more costly that I had estimated.

Thanks for the help so far!

Hi @ScottDutton ,

(…) given we are already paying for the SaaS is there any option to use a hosted runner which would solve both issues here ?

Depending on your programming languages (and PHP and JavaScript are covered), you may consider :sonarcloud: automated analysis. It however requires that the Git repository is hosted on GitHub; I don’t know it is a workable option for you.

No this is not open source and we use the atlasian suite a lot so cant really switch

Understood about your Atlassian requirement.

For the record, projects don’t have to be open source for our Autmatic Analysis feature. Private repos are fully supported. Support for this feature on Bitbucket Cloud too is on our radars, but not really soon.