You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "RockteMQ-AI (via GitHub)" <gi...@apache.org> on 2026/08/05 15:37:11 UTC
Re: [PR] [ISSUE #229]when use cgroups v2, controller failed to start [rocketmq-operator]
RockteMQ-AI commented on code in PR #230:
URL: https://github.com/apache/rocketmq-operator/pull/230#discussion_r3721921980
##########
images/controller/alpine/runserver-customize.sh:
##########
@@ -55,12 +55,30 @@ 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
Review Comment:
**[Warning]** Inconsistent indentation: the `if` block uses 2-space indentation here, while the surrounding code and the CPU block below use 4-space indentation. Consider aligning to 4-space for consistency.
##########
images/controller/alpine/runserver-customize.sh:
##########
@@ -55,12 +55,30 @@ 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
Review Comment:
**[Critical]** The `memory.max` file in cgroups v2 can contain the literal string `max` (meaning unlimited), similar to how `cpu.max` handles it. When this happens, `$(($(cat /sys/fs/cgroup/memory.max)/1024/1024))` will fail with a bash arithmetic error.
Consider handling this case, similar to how you handled `cpu.max`:
```bash
elif [ -f /sys/fs/cgroup/memory.max ]; then
MEM_MAX=$(cat /sys/fs/cgroup/memory.max)
if [ "$MEM_MAX" == "max" ]; then
system_memory_in_mb_in_docker=$system_memory_in_mb
else
system_memory_in_mb_in_docker=$(($MEM_MAX/1024/1024))
fi
```
--
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-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org