Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: cpuset limits was determined in a way that apps only used 1 CPU max, ehh, sorry.

Andras Bacsai5e7c6906b388
diff --git a/app/Actions/Database/StartMariadb.php b/app/Actions/Database/StartMariadb.php
index 2788f2bf32..bb8cd99939 100644
--- a/app/Actions/Database/StartMariadb.php
+++ b/app/Actions/Database/StartMariadb.php
@@ -57,7 +57,6 @@ class StartMariadb
'mem_swappiness' => $this->database->limits_memory_swappiness,
'mem_reservation' => $this->database->limits_memory_reservation,
'cpus' => (float) $this->database->limits_cpus,
- 'cpuset' => $this->database->limits_cpuset,
'cpu_shares' => $this->database->limits_cpu_shares,
]
],
@@ -69,6 +68,9 @@ class StartMariadb
]
]
];
+ if ($this->database->limits_cpuset !== 0) {
+ data_set($docker_compose, "services.{$container_name}.cpuset", $this->database->limits_cpuset);
+ }
if ($this->database->destination->server->isLogDrainEnabled() && $this->database->isLogDrainEnabled()) {
$docker_compose['services'][$container_name]['logging'] = [
'driver' => 'fluentd',
diff --git a/app/Actions/Database/StartMongodb.php b/app/Actions/Database/StartMongodb.php
index c15f3f3706..e20973b71e 100644
--- a/app/Actions/Database/StartMongodb.php
+++ b/app/Actions/Database/StartMongodb.php
@@ -64,7 +64,6 @@ class StartMongodb
'mem_swappiness' => $this->database->limits_memory_swappiness,
'mem_reservation' => $this->database->limits_memory_reservation,
'cpus' => (float) $this->database->limits_cpus,
- 'cpuset' => $this->database->limits_cpuset,
'cpu_shares' => $this->database->limits_cpu_shares,
]
],
@@ -76,6 +75,9 @@ class StartMongodb
]
]
];
+ if ($this->database->limits_cpuset !== 0) {
+ data_set($docker_compose, "services.{$container_name}.cpuset", $this->database->limits_cpuset);
+ }
if ($this->database->destination->server->isLogDrainEnabled() && $this->database->isLogDrainEnabled()) {
$docker_compose['services'][$container_name]['logging'] = [
'driver' => 'fluentd',
diff --git a/app/Actions/Database/StartMysql.php b/app/Actions/Database/StartMysql.php
index 1298555db4..f566cff55a 100644
--- a/app/Actions/Database/StartMysql.php
+++ b/app/Actions/Database/StartMysql.php
@@ -57,7 +57,6 @@ class StartMysql
'mem_swappiness' => $this->database->limits_memory_swappiness,
'mem_reservation' => $this->database->limits_memory_reservation,
'cpus' => (float) $this->database->limits_cpus,
- 'cpuset' => $this->database->limits_cpuset,
'cpu_shares' => $this->database->limits_cpu_shares,
]
],
@@ -69,6 +68,9 @@ class StartMysql
]
]
];
+ if ($this->database->limits_cpuset !== 0) {
+ data_set($docker_compose, "services.{$container_name}.cpuset", $this->database->limits_cpuset);
+ }
if ($this->database->destination->server->isLogDrainEnabled() && $this->database->isLogDrainEnabled()) {
$docker_compose['services'][$container_name]['logging'] = [
'driver' => 'fluentd',
diff --git a/app/Actions/Database/StartPostgresql.php b/app/Actions/Database/StartPostgresql.php
index 0f579719b1..2a1f854bba 100644
--- a/app/Actions/Database/StartPostgresql.php
+++ b/app/Actions/Database/StartPostgresql.php
@@ -67,7 +67,6 @@ class StartPostgresql
'mem_swappiness' => $this->database->limits_memory_swappiness,
'mem_reservation' => $this->database->limits_memory_reservation,
'cpus' => (float) $this->database->limits_cpus,
- 'cpuset' => $this->database->limits_cpuset,
'cpu_shares' => $this->database->limits_cpu_shares,
]
],
@@ -79,6 +78,9 @@ class StartPostgresql
]
]
];
+ if ($this->database->limits_cpuset !== 0) {
+ data_set($docker_compose, "services.{$container_name}.cpuset", $this->database->limits_cpuset);
+ }
if ($this->database->destination->server->isLogDrainEnabled() && $this->database->isLogDrainEnabled()) {
ray('Log Drain Enabled');
$docker_compose['services'][$container_name]['logging'] = [
diff --git a/app/Actions/Database/StartRedis.php b/app/Actions/Database/StartRedis.php
index a186fbbc9e..88f9576c94 100644
--- a/app/Actions/Database/StartRedis.php
+++ b/app/Actions/Database/StartRedis.php
@@ -66,7 +66,6 @@ class StartRedis
'mem_swappiness' => $this->database->limits_memory_swappiness,
'mem_reservation' => $this->database->limits_memory_reservation,
'cpus' => (float) $this->database->limits_cpus,
- 'cpuset' => $this->database->limits_cpuset,
'cpu_shares' => $this->database->limits_cpu_shares,
]
],
@@ -78,6 +77,9 @@ class StartRedis
]
]
];
+ if ($this->database->limits_cpuset !== 0) {
+ data_set($docker_compose, "services.{$container_name}.cpuset", $this->database->limits_cpuset);
+ }
if ($this->database->destination->server->isLogDrainEnabled() && $this->database->isLogDrainEnabled()) {
$docker_compose['services'][$container_name]['logging'] = [
'driver' => 'fluentd',
diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php
index e846f9f610..3672591ae3 100644
--- a/app/Jobs/ApplicationDeploymentJob.php
+++ b/app/Jobs/ApplicationDeploymentJob.php
@@ -1016,7 +1016,6 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
'mem_swappiness' => $this->application->limits_memory_swappiness,
'mem_reservation' => $this->application->limits_memory_reservation,
'cpus' => (float) $this->application->limits_cpus,
- 'cpuset' => $this->application->limits_cpuset,
'cpu_shares' => $this->application->limits_cpu_shares,
]
],
@@ -1028,6 +1027,9 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
]
]
];
+ if ($this->application->limits_cpuset !== 0) {
+ data_set($docker_compose, 'services.' . $this->container_name . '.cpuset', $this->application->limits_cpuset);
+ }
if ($this->server->isSwarm()) {
data_forget($docker_compose, 'services.' . $this->container_name . '.container_name');
data_forget($docker_compose, 'services.' . $this->container_name . '.expose');
diff --git a/app/Livewire/Project/Shared/ResourceLimits.php b/app/Livewire/Project/Shared/ResourceLimits.php
index 692c5f741e..747478f07d 100644
--- a/app/Livewire/Project/Shared/ResourceLimits.php
+++ b/app/Livewire/Project/Shared/ResourceLimits.php
@@ -44,9 +44,6 @@ class ResourceLimits extends Component
if (!$this->resource->limits_cpus) {
$this->resource->limits_cpus = "0";
}
- if (!$this->resource->limits_cpuset) {
- $this->resource->limits_cpuset = "0";
- }
if (!$this->resource->limits_cpu_shares) {
$this->resource->limits_cpu_shares = 1024;
}
diff --git a/app/Models/Application.php b/app/Models/Application.php
index c16adc7e6f..97b7f1736a 100644
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@ -429,7 +429,7 @@ class Application extends BaseModel
}
public function isConfigurationChanged($save = false)
{
- $newConfigHash = $this->fqdn . $this->git_repository . $this->git_branch . $this->git_commit_sha . $this->build_pack . $this->static_image . $this->install_command . $this->build_command . $this->start_command . $this->port_exposes . $this->port_mappings . $this->base_directory . $this->publish_directory . $this->health_check_path . $this->health_check_port . $this->health_check_host . $this->health_check_method . $this->health_check_return_code . $this->health_check_scheme . $this->health_check_response_text . $this->health_check_interval . $this->health_check_timeout . $this->health_check_retries . $this->health_check_start_period . $this->health_check_enabled . $this->limits_memory . $this->limits_swap . $this->limits_swappiness . $this->limits_reservation . $this->limits_cpus . $this->limits_cpuset . $this->limits_cpu_shares . $this->dockerfile . $this->dockerfile_location . $this->custom_labels;
+ $newConfigHash = $this->fqdn . $this->git_repository . $this->git_branch . $this->git_commit_sha . $this->build_pack . $this->static_image . $this->install_command . $this->build_command . $this->start_command . $this->port_exposes . $this->port_mappings . $this->base_directory . $this->publish_directory . $this->dockerfile . $this->dockerfile_location . $this->custom_labels;
if ($this->pull_request_id === 0 || $this->pull_request_id === null) {
$newConfigHash .= json_encode($this->environment_variables->all());
} else {
@@ -642,7 +642,6 @@ class Application extends BaseModel
'mem_swappiness' => $this->limits_memory_swappiness,
'mem_reservation' => $this->limits_memory_reservation,
'cpus' => (float) $this->limits_cpus,
- 'cpuset' => $this->limits_cpuset,
'cpu_shares' => $this->limits_cpu_shares,
]
],
@@ -654,6 +653,9 @@ class Application extends BaseModel
]
]
];
+ if ($this->limits_cpuset !== 0) {
+ data_set($docker_compose, "services.{$container_name}.cpuset", $this->limits_cpuset);
+ }
if ($server->isSwarm()) {
data_forget($docker_compose, 'services.' . $container_name . '.container_name');
data_forget($docker_compose, 'services.' . $container_name . '.expose');
diff --git a/bootstrap/helpers/applications.php b/bootstrap/helpers/applications.php
index d3e28d5249..0779c872fa 100644
--- a/bootstrap/helpers/applications.php
+++ b/bootstrap/helpers/applications.php
@@ -167,7 +167,6 @@ function generateComposeFile(string $deploymentUuid, Server $server, string $net
'mem_swappiness' => $application->limits_memory_swappiness,
'mem_reservation' => $application->limits_memory_reservation,
'cpus' => (int) $application->limits_cpus,
- 'cpuset' => $application->limits_cpuset,
'cpu_shares' => $application->limits_cpu_shares,
]
],
@@ -179,6 +178,9 @@ function generateComposeFile(string $deploymentUuid, Server $server, string $net
]
]
];
+ if ($application->limits_cpuset !== 0) {
+ data_set($docker_compose, "services.{$containerName}.cpuset", $application->limits_cpuset);
+ }
if ($server->isLogDrainEnabled() && $application->isLogDrainEnabled()) {
$docker_compose['services'][$containerName]['logging'] = [
'driver' => 'fluentd',
diff --git a/config/sentry.php b/config/sentry.php
index 2d526fb854..9426b30762 100644
--- a/config/sentry.php
+++ b/config/sentry.php
@@ -7,7 +7,7 @@ return [
// The release version of your application
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
- 'release' => '4.0.0-beta.189',
+ 'release' => '4.0.0-beta.190',
// When left empty or `null` the Laravel environment will be used
'environment' => config('app.env'),
diff --git a/config/version.php b/config/version.php
index dec4e2c54f..0e5343e990 100644
--- a/config/version.php
+++ b/config/version.php
@@ -1,3 +1,3 @@
<?php
-return '4.0.0-beta.189';
+return '4.0.0-beta.190';
diff --git a/database/migrations/2024_01_12_123422_update_cpuset_limits.php b/database/migrations/2024_01_12_123422_update_cpuset_limits.php
new file mode 100644
index 0000000000..5f94559bc6
--- /dev/null
+++ b/database/migrations/2024_01_12_123422_update_cpuset_limits.php
@@ -0,0 +1,76 @@
+<?php
+
+use App\Models\Application;
+use App\Models\StandaloneMariadb;
+use App\Models\StandaloneMongodb;
+use App\Models\StandaloneMysql;
+use App\Models\StandalonePostgresql;
+use App\Models\StandaloneRedis;
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+ /**
+ * Run the migrations.
+ */
+ public function up(): void
+ {
+ Schema::table('applications', function (Blueprint $table) {
+ $table->string('limits_cpuset')->nullable()->default(null)->change();
+ });
+ Schema::table('standalone_postgresqls', function (Blueprint $table) {
+ $table->string('limits_cpuset')->nullable()->default(null)->change();
+ });
+ Schema::table('standalone_redis', function (Blueprint $table) {
+ $table->string('limits_cpuset')->nullable()->default(null)->change();
+ });
+ Schema::table('standalone_mariadbs', function (Blueprint $table) {
+ $table->string('limits_cpuset')->nullable()->default(null)->change();
+ });
+ Schema::table('standalone_mysqls', function (Blueprint $table) {
+ $table->string('limits_cpuset')->nullable()->default(null)->change();
+ });
+ Schema::table('standalone_mongodbs', function (Blueprint $table) {
+ $table->string('limits_cpuset')->nullable()->default(null)->change();
+ });
+ Application::where('limits_cpuset', '0')->update(['limits_cpuset' => null]);
+ StandalonePostgresql::where('limits_cpuset', '0')->update(['limits_cpuset' => null]);
+ StandaloneRedis::where('limits_cpuset', '0')->update(['limits_cpuset' => null]);
+ StandaloneMariadb::where('limits_cpuset', '0')->update(['limits_cpuset' => null]);
+ StandaloneMysql::where('limits_cpuset', '0')->update(['limits_cpuset' => null]);
+ StandaloneMongodb::where('limits_cpuset', '0')->update(['limits_cpuset' => null]);
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('applications', function (Blueprint $table) {
+ $table->string('limits_cpuset')->nullable()->default("0")->change();
+ });
+ Schema::table('standalone_postgresqls', function (Blueprint $table) {
+ $table->string('limits_cpuset')->nullable()->default("0")->change();
+ });
+ Schema::table('standalone_redis', function (Blueprint $table) {
+ $table->string('limits_cpuset')->nullable()->default("0")->change();
+ });
+ Schema::table('standalone_mariadbs', function (Blueprint $table) {
+ $table->string('limits_cpuset')->nullable()->default("0")->change();
+ });
+ Schema::table('standalone_mysqls', function (Blueprint $table) {
+ $table->string('limits_cpuset')->nullable()->default("0")->change();
+ });
+ Schema::table('standalone_mongodbs', function (Blueprint $table) {
+ $table->string('limits_cpuset')->nullable()->default("0")->change();
+ });
+ Application::where('limits_cpuset', null)->update(['limits_cpuset' => '0']);
+ StandalonePostgresql::where('limits_cpuset', null)->update(['limits_cpuset' => '0']);
+ StandaloneRedis::where('limits_cpuset', null)->update(['limits_cpuset' => '0']);
+ StandaloneMariadb::where('limits_cpuset', null)->update(['limits_cpuset' => '0']);
+ StandaloneMysql::where('limits_cpuset', null)->update(['limits_cpuset' => '0']);
+ StandaloneMongodb::where('limits_cpuset', null)->update(['limits_cpuset' => '0']);
+ }
+};
diff --git a/resources/views/livewire/project/shared/resource-limits.blade.php b/resources/views/livewire/project/shared/resource-limits.blade.php
index 0251604599..0b03d1cddb 100644
--- a/resources/views/livewire/project/shared/resource-limits.blade.php
+++ b/resources/views/livewire/project/shared/resource-limits.blade.php
@@ -7,9 +7,15 @@
<div class="">Limit your container resources by CPU & memory.</div>
<h3 class="pt-4">Limit CPUs</h3>
<div class="flex gap-2">
- <x-forms.input placeholder="1.5" label="Number of CPUs" id="resource.limits_cpus" />
- <x-forms.input placeholder="0-2" label="CPU sets to use" id="resource.limits_cpuset" />
- <x-forms.input placeholder="1024" label="CPU Weight" id="resource.limits_cpu_shares" />
+ <x-forms.input placeholder="1.5"
+ helper="0 means use all CPUs. Floating point number, like 0.002 or 1.5. More info <a target='_blank' href='https://docs.docker.com/engine/reference/run/#cpu-share-constraint'>here</a>."
+ label="Number of CPUs" id="resource.limits_cpus" />
+ <x-forms.input placeholder="0-2"
+ helper="Empty means, use all CPU sets. 0-2 will use CPU 0, CPU 1 and CPU 2. More info <a target='_blank' href='https://docs.docker.com/engine/reference/run/#cpu-share-constraint'>here</a>."
+ label="CPU sets to use" id="resource.limits_cpuset" />
+ <x-forms.input placeholder="1024"
+ helper="More info <a target='_blank' href='https://docs.docker.com/engine/reference/run/#cpu-share-constraint'>here</a>."
+ label="CPU Weight" id="resource.limits_cpu_shares" />
</div>
<h3 class="pt-4">Limit Memory</h3>
<div class="flex gap-2">
diff --git a/versions.json b/versions.json
index a8d4bd6490..04da3a38c2 100644
--- a/versions.json
+++ b/versions.json
@@ -4,7 +4,7 @@
"version": "3.12.36"
},
"v4": {
- "version": "4.0.0-beta.189"
+ "version": "4.0.0-beta.190"
}
}
}