Make 0 equal unlimited for functions environment variables

This commit is contained in:
Bradley Schofield
2025-01-07 13:15:16 +09:00
parent 3b9cbcb671
commit a3fc3daf82
2 changed files with 4 additions and 2 deletions
+3 -1
View File
@@ -550,7 +550,9 @@ App::get('/v1/functions/specifications')
}
// Only add specs that are within the limits set by environment variables
if ($spec['cpus'] <= System::getEnv('_APP_FUNCTIONS_CPUS', 1) && $spec['memory'] <= System::getEnv('_APP_FUNCTIONS_MEMORY', 512)) {
if (
($spec['cpus'] <= System::getEnv('_APP_FUNCTIONS_CPUS', 1) || System::getEnv('_APP_FUNCTIONS_CPUS', 1) === 0) &&
($spec['memory'] <= System::getEnv('_APP_FUNCTIONS_MEMORY', 512)) || System::getEnv('_APP_FUNCTIONS_MEMORY', 512) === 0) {
$runtimeSpecs[] = $spec;
}
}
@@ -34,7 +34,7 @@ class RuntimeSpecification extends Validator
$allowedSpecifications = [];
foreach ($this->specifications as $size => $values) {
if ($values['cpus'] <= $this->maxCpus && $values['memory'] <= $this->maxMemory) {
if (($values['cpus'] <= $this->maxCpus || $this->maxCpus === 0) && ($values['memory'] <= $this->maxMemory || $this->maxMemory === 0)) {
if (!empty($this->plan) && array_key_exists('runtimeSpecifications', $this->plan)) {
if (!\in_array($size, $this->plan['runtimeSpecifications'])) {
continue;