fix(deployment): use mainServer consistently instead of redundant original_server
Remove the redundant $original_server property and use $mainServer throughout ApplicationDeploymentJob. Both properties held the same value (the deployment target server), causing unnecessary duplication. Also fixes two bugs in generate_compose_file() where $this->server was used instead of $this->mainServer for isSwarm() and isLogDrainEnabled() checks. When using a build server, $this->server could point to the build server, causing incorrect configuration for the deployment target. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
162eaa9f0d
commit
81780d652f
1 changed files with 9 additions and 16 deletions
|
|
@ -87,9 +87,6 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
|
|||
|
||||
private bool $use_build_server = false;
|
||||
|
||||
// Save original server between phases
|
||||
private Server $original_server;
|
||||
|
||||
private Server $mainServer;
|
||||
|
||||
private bool $is_this_additional_server = false;
|
||||
|
|
@ -325,18 +322,14 @@ public function handle(): void
|
|||
if ($buildServers->count() === 0) {
|
||||
$this->application_deployment_queue->addLogEntry('No suitable build server found. Using the deployment server.');
|
||||
$this->build_server = $this->server;
|
||||
$this->original_server = $this->server;
|
||||
} else {
|
||||
$this->build_server = $buildServers->random();
|
||||
$this->application_deployment_queue->build_server_id = $this->build_server->id;
|
||||
$this->application_deployment_queue->addLogEntry("Found a suitable build server ({$this->build_server->name}).");
|
||||
$this->original_server = $this->server;
|
||||
$this->use_build_server = true;
|
||||
}
|
||||
} else {
|
||||
// Set build server & original_server to the same as deployment server
|
||||
$this->build_server = $this->server;
|
||||
$this->original_server = $this->server;
|
||||
}
|
||||
$this->detectBuildKitCapabilities();
|
||||
$this->decide_what_to_do();
|
||||
|
|
@ -937,7 +930,7 @@ private function write_deployment_configurations()
|
|||
{
|
||||
if ($this->preserveRepository) {
|
||||
if ($this->use_build_server) {
|
||||
$this->server = $this->original_server;
|
||||
$this->server = $this->mainServer;
|
||||
}
|
||||
if (str($this->configuration_dir)->isNotEmpty()) {
|
||||
$this->execute_remote_command(
|
||||
|
|
@ -960,7 +953,7 @@ private function write_deployment_configurations()
|
|||
}
|
||||
if (isset($this->docker_compose_base64)) {
|
||||
if ($this->use_build_server) {
|
||||
$this->server = $this->original_server;
|
||||
$this->server = $this->mainServer;
|
||||
}
|
||||
$readme = generate_readme_file($this->application->name, $this->application_deployment_queue->updated_at);
|
||||
|
||||
|
|
@ -1342,7 +1335,7 @@ private function save_runtime_environment_variables()
|
|||
|
||||
// Also create in configuration directory
|
||||
if ($this->use_build_server) {
|
||||
$this->server = $this->original_server;
|
||||
$this->server = $this->mainServer;
|
||||
$this->execute_remote_command(
|
||||
[
|
||||
"touch $this->configuration_dir/.env",
|
||||
|
|
@ -1359,7 +1352,7 @@ private function save_runtime_environment_variables()
|
|||
} else {
|
||||
// For non-Docker Compose deployments, clean up any existing .env files
|
||||
if ($this->use_build_server) {
|
||||
$this->server = $this->original_server;
|
||||
$this->server = $this->mainServer;
|
||||
$this->execute_remote_command(
|
||||
[
|
||||
'command' => "rm -f $this->configuration_dir/.env",
|
||||
|
|
@ -1407,7 +1400,7 @@ private function save_runtime_environment_variables()
|
|||
|
||||
// Write .env file to configuration directory
|
||||
if ($this->use_build_server) {
|
||||
$this->server = $this->original_server;
|
||||
$this->server = $this->mainServer;
|
||||
$this->execute_remote_command(
|
||||
[
|
||||
"echo '$envs_base64' | base64 -d | tee $this->configuration_dir/.env > /dev/null",
|
||||
|
|
@ -1744,7 +1737,7 @@ private function rolling_update()
|
|||
} else {
|
||||
if ($this->use_build_server) {
|
||||
$this->write_deployment_configurations();
|
||||
$this->server = $this->original_server;
|
||||
$this->server = $this->mainServer;
|
||||
}
|
||||
if (count($this->application->ports_mappings_array) > 0 || (bool) $this->application->settings->is_consistent_container_name_enabled || str($this->application->settings->custom_internal_name)->isNotEmpty() || $this->pull_request_id !== 0 || str($this->application->custom_docker_run_options)->contains('--ip') || str($this->application->custom_docker_run_options)->contains('--ip6')) {
|
||||
$this->application_deployment_queue->addLogEntry('----------------------------------------');
|
||||
|
|
@ -1913,7 +1906,7 @@ private function deploy_pull_request()
|
|||
private function create_workdir()
|
||||
{
|
||||
if ($this->use_build_server) {
|
||||
$this->server = $this->original_server;
|
||||
$this->server = $this->mainServer;
|
||||
$this->execute_remote_command(
|
||||
[
|
||||
'command' => "mkdir -p {$this->configuration_dir}",
|
||||
|
|
@ -2563,7 +2556,7 @@ private function generate_compose_file()
|
|||
if (! is_null($this->application->limits_cpuset)) {
|
||||
data_set($docker_compose, 'services.'.$this->container_name.'.cpuset', $this->application->limits_cpuset);
|
||||
}
|
||||
if ($this->server->isSwarm()) {
|
||||
if ($this->mainServer->isSwarm()) {
|
||||
data_forget($docker_compose, 'services.'.$this->container_name.'.container_name');
|
||||
data_forget($docker_compose, 'services.'.$this->container_name.'.expose');
|
||||
data_forget($docker_compose, 'services.'.$this->container_name.'.restart');
|
||||
|
|
@ -2613,7 +2606,7 @@ private function generate_compose_file()
|
|||
} else {
|
||||
$docker_compose['services'][$this->container_name]['labels'] = $labels;
|
||||
}
|
||||
if ($this->original_server->isLogDrainEnabled() && $this->application->isLogDrainEnabled()) {
|
||||
if ($this->mainServer->isLogDrainEnabled() && $this->application->isLogDrainEnabled()) {
|
||||
$docker_compose['services'][$this->container_name]['logging'] = generate_fluentd_configuration();
|
||||
}
|
||||
if ($this->application->settings->is_gpu_enabled) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue