caigy commented on code in PR #199:
URL: https://github.com/apache/rocketmq-operator/pull/199#discussion_r1434682128


##########
images/namesrv/alpine/runserver-customize.sh:
##########
@@ -55,12 +55,27 @@ calculate_heap_sizes()
     case "`uname`" in
         Linux)
             system_memory_in_mb=`free -m| sed -n '2p' | awk '{print $2}'`
-            system_memory_in_mb_in_docker=$(($(cat 
/sys/fs/cgroup/memory/memory.limit_in_bytes)/1024/1024))
+            if [ -f /sys/fs/cgroup/memory/memory.limit_in_bytes ]; then
+                system_memory_in_mb_in_docker=$(($(cat 
/sys/fs/cgroup/memory/memory.limit_in_bytes)/1024/1024))
+            elif [ -f /sys/fs/cgroup/memory.max ]; then
+                system_memory_in_mb_in_docker=$(($(cat 
/sys/fs/cgroup/memory.max)/1024/1024))
+            else
+                error_exit "Can not get memory, please check cgroup"
+            fi
             if [ $system_memory_in_mb_in_docker -lt $system_memory_in_mb ];then
               system_memory_in_mb=$system_memory_in_mb_in_docker
             fi
+
             system_cpu_cores=`egrep -c 'processor([[:space:]]+):.*' 
/proc/cpuinfo`
-            system_cpu_cores_in_docker=$(($(cat 
/sys/fs/cgroup/cpu/cpu.cfs_quota_us)/$(cat 
/sys/fs/cgroup/cpu/cpu.cfs_period_us)))
+            if [ -f /sys/fs/cgroup/cpu/cpu.cfs_quota_us ]; then
+                system_cpu_cores_in_docker=$(($(cat 
/sys/fs/cgroup/cpu/cpu.cfs_quota_us)/$(cat 
/sys/fs/cgroup/cpu/cpu.cfs_period_us)))
+            elif [ -f /sys/fs/cgroup/cpu.max ]; then
+                QUOTA=$(cut -d ' ' -f 1 /sys/fs/cgroup/cpu.max)
+                PERIOD=$(cut -d ' ' -f 2 /sys/fs/cgroup/cpu.max)
+                system_cpu_cores_in_docker=$(($QUOTA/$PERIOD))

Review Comment:
   It seems that 'QUOTA' may be 'max' instead of number? Pls refer 
[this](https://github.com/opencontainers/runc/issues/2243).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to