Uploaded image for project: 'Percona Monitoring and Management'
  1. Percona Monitoring and Management
  2. PMM-2722

Memory auto-configuration for Prometheus evaluates to minimum of 128MB in entrypoint.sh

    Details

    • Type: Bug
    • Status: Done
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: 1.12.0
    • Fix Version/s: 1.13.0
    • Component/s: docker
    • Labels:
      None

      Description

      Hi, auto-configuration of memory for Prometheus is properly detecting resources available but is incorrectly evaluating what the memory allocation for Prometheus should be. The comparison operator < doesn't work as expected, which leads to METRICS_MEMORY_MULTIPLIED evaluating to 128MB. 

      For example I am hard-coding a host with 32GB of RAM TOTAL_MEMORY and also a very high MEMORY_LIMIT.  Here is the failing test using current logic from https://github.com/percona/pmm-server/blob/master/entrypoint.sh#L24-L32 :

      [root@control ~]# grep if test.sh
      if [[ $METRICS_MEMORY_MULTIPLIED < $((128*1024*1024)) ]] ; then
      [root@control ~]# sh test.sh
      MEMORY_LIMIT: 9223372036854771712
      TOTAL_MEMORY: 33736527872
      MEMORY_AVAIABLE: 33736527872
      METRICS_MEMORY_MULTIPLIED: 134217728

      I believe the issue is because of the use of square brackets, if instead we use double-parentheses we see a correct evaluation:

      [root@control ~]# grep if test.sh
      if (( $METRICS_MEMORY_MULTIPLIED < $((128*1024*1024)) )) ; then
      [root@control ~]# sh test.sh
      MEMORY_LIMIT: 9223372036854771712
      TOTAL_MEMORY: 33736527872
      MEMORY_AVAIABLE: 33736527872
      METRICS_MEMORY_MULTIPLIED: 13387236960

      The other option might be to use instead -lt as the comparison operator and stick with square brackets:

      [root@control ~]# grep if test.sh
      if [[ $METRICS_MEMORY_MULTIPLIED -lt $((128*1024*1024)) ]] ; then
      [root@control ~]# sh test.sh
      MEMORY_LIMIT: 9223372036854771712
      TOTAL_MEMORY: 33736527872
      MEMORY_AVAIABLE: 33736527872
      METRICS_MEMORY_MULTIPLIED: 13387236960

        Attachments

          Issue Links

            Expenses

              Activity

                People

                • Assignee:
                  nailya.kutlubaeva Nailya Kutlubaeva
                  Reporter:
                  michael.coburn@percona.com Michael Coburn
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Remaining Estimate - 0 minutes
                    0m
                    Logged:
                    Time Spent - 2 hours
                    2h