Error getting INODEs count in (some?) docker env

Issue #911 duplicate
Alexander Simonov created an issue

Hello.

I’m on version 2.3.4 FREE # 1507

I’ve noticed than in every several days I receive a mail from poste.io cron daemon about some PHP Division by zero Exception, originating from /opt/admin/bin/console check:free-space script.

Also, in manager UI on Server status tab, the number of INODEs was everytime as “NAN”.

I’ve tired getting these exception emails and started to dig in to see what is happening. By running /opt/admin/bin/console check:free-space script with -vvvvvvvvv flag I’ve noticed that Exception is in /opt/admin/src/Base/Server/System.php in function getFreeInodes(). Running df command with parameters from getFreeInodes() inside my container I’ve noticed that all number of inodes is always zeros… So, now it was clear for me why division by zero raised in getFreeInodes()…

I’ve slightly modified the function code resulting in this:

public function getFreeInodes(): float
{
    $result = $this->run('df -i "/data" | grep "/data"');
    $parts = preg_split('/\s+/', $result);

    $total_inodes = intval($parts[1]);
    $free_inodes = intval($parts[3]);

    if ($total_inodes == 0) {
        return 1.0;
    } else {
        return $free_inodes / $total_inodes;
    }
}

so now when it is getting total INODEs of “0” it hust returns “100% free”, or 1.0f, eliminating division by zero behavior.

I’ve injected modified System.php using docker-compose mount and now got no division by zero when executing /opt/admin/bin/console check:free-space script and also got 100% free INODEs in Server status UI instead of “NAN”s.

I know this is a kind of workaround and the case with getting 0 INODEs must be handled more thoroughly, but for me it works and stopped erroneous behavior.

Please check this and apply some changes to you codebase so this error will not migrate to upcoming versions.

Thanks.

Comments (2)

  1. Log in to comment